Skip to content

Commit 7d7574a

Browse files
Added a reason parameter to the update secret connection method
1 parent b31ed47 commit 7d7574a

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

RMQClient/RMQConnection.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@
247247
* This method updates the secret used to authenticate this connection.
248248
* It is used when secrets have an expiration date and need to be renewed, like OAuth 2 tokens.
249249
* @param secret The new secret.
250+
* @param reason The reason for the secret update.
250251
*/
251-
- (void)updateSecret:(nonnull NSString *)secret;
252+
- (void)updateSecret:(nonnull NSString *)secret
253+
reason:(nonnull NSString *)reason;
252254

253255
@end

RMQClient/RMQConnection.m

+6-4
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,10 @@ - (void)start {
609609
}
610610

611611
- (void)updateSecret:(NSString *)secret
612+
reason:(NSString *)reason
612613
{
613614
[self.commandQueue enqueue:^{
614-
[self sendFrameset:[[RMQFrameset alloc] initWithChannelNumber:@0 method:[self methodForUpdateSecret:secret]]];
615+
[self sendFrameset:[[RMQFrameset alloc] initWithChannelNumber:@0 method:[self methodForUpdateSecret:secret reason:reason]]];
615616
}];
616617
}
617618

@@ -753,11 +754,12 @@ - (void)closeAllUserChannels {
753754
}
754755
}
755756

756-
- (RMQConnectionUpdateSecret *)methodForUpdateSecret:(NSString *)secret {
757+
- (RMQConnectionUpdateSecret *)methodForUpdateSecret:(NSString *)secret
758+
reason:(NSString *)reason {
757759
RMQLongstr *secretLongstr = [[RMQLongstr alloc] init:secret];
758-
RMQShortstr *reason = [[RMQShortstr alloc] init:@"ObjC client needs it"];
760+
RMQShortstr *reasonShortstr = [[RMQShortstr alloc] init:reason];
759761
return [[RMQConnectionUpdateSecret alloc] initWithSecret:secretLongstr
760-
reason:reason];
762+
reason:reasonShortstr];
761763
}
762764

763765
- (RMQConnectionClose *)amqClose {

RMQClientTests/ConnectionUpdateSecretTest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ final class ConnectionUpdateSecretTest: XCTestCase {
1414
let (transport, q, conn, _) = ConnectionWithFakesHelper.connectionAfterHandshake()
1515

1616
let secret = "someSecret"
17-
let reason = "ObjC client needs it"
17+
let reason = "some test reason"
1818

19-
conn.updateSecret(secret)
19+
conn.updateSecret(secret, reason: reason);
2020

2121
try? q.step()
2222

0 commit comments

Comments
 (0)