-
Notifications
You must be signed in to change notification settings - Fork 31
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
[ECO-4330] Feature - server initiated auth #661
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes involve enhancements to the authorization and connection management processes within the Ably library. Key modifications include the introduction of error handling in authorization callbacks, improved connection state management during reauthorization, and the addition of new logging and action constants. These updates aim to ensure compliance with the specified API design and improve the robustness of the connection lifecycle. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Auth
participant Connection
Client->>Auth: Request Token
Auth->>Connection: Authorize with Token
Connection-->>Auth: Token Valid
Auth-->>Client: Token Granted
Client->>Connection: Connect
Connection->>Client: Connection Established
Client->>Connection: Reauthorize with new Token
Connection->>Auth: Request New Token
Auth-->>Connection: New Token Granted
Connection-->>Client: Reconnection Successful
Assessment against linked issues
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
…integration test for client initiated auth
8dabea2
to
9bea0c0
Compare
cfce4b2
to
0352214
Compare
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- ably/ably_test.go (1 hunks)
- ably/auth.go (3 hunks)
- ably/export_test.go (2 hunks)
- ably/proto_protocol_message.go (1 hunks)
- ably/realtime_conn.go (6 hunks)
- ably/realtime_conn_spec_integration_test.go (4 hunks)
Additional comments not posted (13)
ably/export_test.go (2)
265-267
: LGTM!The code changes are approved.
317-317
: LGTM!The code changes are approved.
ably/proto_protocol_message.go (1)
186-188
: LGTM!The code changes are approved. The new case for handling
actionAuth
in theString
method of theprotocolMessage
struct is correctly implemented and improves the method's functionality by allowing it to represent authentication-related messages distinctly. This change enhances the clarity and utility of the output for debugging or logging purposes.ably/ably_test.go (1)
264-280
: LGTM!The new
CheckIfReceived
method looks good:
- It correctly checks if a specified action has been received a certain number of times.
- It handles the case when
times
is zero correctly by returningtrue
if thecounter
is also zero.- It returns
false
if the specified number of occurrences is not found, which is the expected behavior.- The function is named appropriately and the parameters are clear and well-defined.
- The function is well-structured and easy to understand.
Great job!
ably/auth.go (2)
85-85
: LGTM!The code changes are approved:
- The
onExplicitAuthorize
field in theAuth
struct has been updated to return an error, matching the new function signature.- The
newAuth
constructor correctly initializes theonExplicitAuthorize
field with a function that returns nil error.Also applies to: 96-96
317-320
: LGTM!The code changes are approved:
- The
Authorize
method now handles the error returned by theonExplicitAuthorize
callback.- It correctly propagates the error if
onExplicitAuthorize
returns a non-nil error.These changes improve the error handling by allowing the callback to signal failure conditions.
ably/realtime_conn.go (3)
Line range hint
114-124
: LGTM!The code changes are approved.
Line range hint
758-878
: LGTM!The code changes are approved. The error handling logic is correct and follows the Ably protocol.
Line range hint
938-1013
: LGTM!The code changes are approved. The
onExplicitAuthorize
method handles the client-requested authorization correctly in different connection states.ably/realtime_conn_spec_integration_test.go (4)
1591-1596
: Looks good!The changes improve the test by expecting and verifying the correct connection state transitions from
Disconnected
toConnecting
during a reauthorization and reconnection attempt.
1674-1681
: LGTM!The changes align with the previous segment and correctly verify the expected connection state transitions from
Disconnected
toConnecting
during reauthorization.
1697-1702
: Approved.The changes correctly verify that after transitioning to the "Connecting" state, a successful reconnection results in a "CONNECTED" event being emitted.
1709-1784
: New test function looks great!The new
TestRealtimeConn_RTN15h3_Success
function covers an important scenario where the connection encounters a non-fatal disconnection (status code 506) and is expected to reconnect successfully with the existing token.The test verifies the correct connection state transitions:
- Disconnected due to the non-fatal error
- Transition to "Connecting" state for reconnection attempt
- Successful reconnection with the existing token, emitting a "CONNECTED" event
Adding this test improves the coverage of the realtime connection behavior.
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
ably/export_test.go (1)
269-271
: Add Documentation forLogger()
MethodThe
Logger()
method in theRealtime
struct is not documented in the Go file, and there is no mention of it in the markdown files for API design documentation. It is important to document this method to ensure clarity and consistency in the public API.
- Add documentation for the
Logger()
method inably/export_test.go
.- Ensure that the
Logger()
method is included in the API design documentation to align with the project's API design principles.Analysis chain
LGTM!
The code changes are approved.
Verify if the method is documented and follows the API design principles.
Since the
Logger()
method is exported and part of the public API, ensure that it is well-documented and follows the API design principles established in the 1.2 API design documentation.Run the following script to verify the documentation and API design compliance:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: # - Verify if the `Logger()` method is documented. # - Verify if the `Logger()` method follows the API design principles. # Test 1: Search for the method documentation. Expect: Documentation for the `Logger()` method. rg --type go -A 5 $'func \(r \*Realtime\) Logger\(\)' # Test 2: Search for the API design documentation. Expect: API design principles for the `Logger()` method. rg --type md -A 5 $'Logger\(\)'Length of output: 704
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- README.md (1 hunks)
- ably/auth.go (3 hunks)
- ably/export_test.go (2 hunks)
- ably/realtime_conn.go (6 hunks)
- ably/realtime_conn_spec_integration_test.go (4 hunks)
Files skipped from review due to trivial changes (1)
- README.md
Files skipped from review as they are similar to previous changes (1)
- ably/auth.go
Additional comments not posted (12)
ably/export_test.go (1)
326-326
: LGTM!The code changes are approved.
Verify if the constant is documented and follows the API design principles.
Since the
ActionAuth
constant is exported and part of the public API, ensure that it is well-documented and follows the API design principles established in the 1.2 API design documentation.Run the following script to verify the documentation and API design compliance:
Verify if the constant is used correctly in the implementation of the server-initiated reauthentication feature.
The
ActionAuth
constant is related to the server-initiated reauthentication feature (RTN22) mentioned in the PR objectives. Ensure that the constant is used correctly in the implementation of the feature.Run the following script to verify the usage of the constant:
ably/realtime_conn.go (6)
Line range hint
115-125
: LGTM!The code changes are approved.
Line range hint
783-789
: LGTM!The code changes are approved.
833-835
: LGTM!The code changes are approved.
891-913
: LGTM!The code changes are approved.
921-924
: LGTM!The code changes are approved.
Line range hint
963-1038
: LGTM!The code changes are approved.
ably/realtime_conn_spec_integration_test.go (5)
1525-1530
: LGTM!The code correctly waits for and asserts the expected connection state transitions from
Disconnected
toConnecting
before a reauthorization and reconnection attempt.
1608-1615
: LGTM!The code correctly waits for and asserts the expected connection state transitions from
Disconnected
toConnecting
before a reauthorization and reconnection attempt. It also verifies that the connection state isConnecting
after the transition.
1631-1636
: LGTM!The code correctly waits for and asserts the expected CONNECTED event after the connection transitions to CONNECTING state.
1686-1693
: LGTM!The code correctly waits for and asserts the expected connection state transitions from
Disconnected
toConnecting
before a reconnection attempt. It also verifies that the connection state isConnecting
after the transition.
1708-1714
: LGTM!The code correctly waits for and asserts the expected CONNECTED event after the connection transitions to CONNECTING state.
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.
nice work.
Fixed #228
Summary by CodeRabbit
New Features
Improvements
Tests