-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coap-gateway: Fixing device status to offline when the access token expires #1255
Conversation
WalkthroughThe recent modifications focus on enhancing the device status update mechanism within a CoAP gateway service. A significant update includes the introduction of a Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- coap-gateway/service/devicesStatusUpdater_test.go (5 hunks)
- coap-gateway/service/signIn.go (1 hunks)
Additional comments: 6
coap-gateway/service/devicesStatusUpdater_test.go (5)
- 31-31: The addition of the
wait time.Duration
parameter to theonboardDeviceAndGetDevice
function is a significant change. It allows for more precise control over the simulation of access token expiration scenarios in tests. This change enhances the testing framework's ability to mimic real-world conditions more accurately.- 49-55: The logic for shutting down the OAuth server, waiting for a specified duration, and then restarting it is a clever way to simulate the expiration of access tokens in a controlled environment. This approach ensures that the tests can accurately assess the system's behavior in scenarios where access tokens are about to expire.
- 69-80: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [77-86]
Renaming the test function to
TestDevicesStatusAccessTokenHasNoExpiration
and adjusting the call toonboardDeviceAndGetDevice
to include thewait
duration parameter improves the clarity and specificity of the test. It makes it evident that this test is focused on scenarios where access tokens do not have an expiration time.
- 97-121: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [91-102]
Similarly, renaming the test function to
TestDevicesStatusAccessTokenHasExpiration
and adjusting the call to include thewait
duration parameter clarifies the intent of the test. It focuses on scenarios where access tokens have an expiration time, allowing for a more targeted assessment of the system's behavior.
- 107-120: The addition of the
TestDevicesStatusAccessTokenHasExpirationAndTokenWillExpire
test function is a valuable enhancement to the test suite. It specifically targets scenarios where access tokens are on the verge of expiring, providing a critical assessment of the system's ability to handle such situations effectively.coap-gateway/service/signIn.go (1)
- 232-236: The updated logic in
getSignInDataFromClaims
for calculatingvalidUntil
based on the access token's expiration time is a critical improvement. It proactively identifies situations where the remaining validity of an access token is insufficient, thereby preventing potential issues related to abrupt device disconnections. This change enhances the system's reliability by ensuring that devices are prompted to sign off in a timely manner before their access tokens expire.
Quality Gate failedFailed conditions |
Summary by CodeRabbit