File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed
rabbitmq_amqp_python_client Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class CommonValues(enum.Enum):
18
18
key = "key"
19
19
queue = "queues"
20
20
bindings = "bindings"
21
+ path_tokens = "/auth/tokens"
21
22
22
23
23
24
class ExchangeType (enum .Enum ):
Original file line number Diff line number Diff line change @@ -383,3 +383,8 @@ def active_producers(self) -> int:
383
383
def active_consumers (self ) -> int :
384
384
"""Returns the number of active consumers"""
385
385
return len (self ._consumers )
386
+
387
+ def refresh_token (self , token : str ) -> None :
388
+
389
+ management = self .management ()
390
+ management .refresh_token (token )
Original file line number Diff line number Diff line change @@ -573,3 +573,14 @@ def queue_info(self, name: str) -> QueueInfo:
573
573
message_count = queue_info ["message_count" ],
574
574
consumer_count = queue_info ["consumer_count" ],
575
575
)
576
+
577
+ def refresh_token (self , token : str ) -> None :
578
+
579
+ self .request (
580
+ token .encode (),
581
+ CommonValues .path_tokens .value ,
582
+ CommonValues .command_put .value ,
583
+ [
584
+ CommonValues .response_code_204 .value ,
585
+ ],
586
+ )
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ def test_connection_ssl(ssl_context) -> None:
44
44
environment .close ()
45
45
46
46
47
- def test_connection_auth (environment_auth : Environment ) -> None :
47
+ def test_connection_oauth (environment_auth : Environment ) -> None :
48
48
49
49
connection = environment_auth .connection ()
50
50
connection .dial ()
@@ -54,7 +54,7 @@ def test_connection_auth(environment_auth: Environment) -> None:
54
54
connection .close ()
55
55
56
56
57
- def test_connection_auth_with_timeout (environment_auth : Environment ) -> None :
57
+ def test_connection_oauth_with_timeout (environment_auth : Environment ) -> None :
58
58
59
59
connection = environment_auth .connection ()
60
60
connection .dial ()
@@ -65,10 +65,32 @@ def test_connection_auth_with_timeout(environment_auth: Environment) -> None:
65
65
try :
66
66
management = connection .management ()
67
67
management .declare_queue (QuorumQueueSpecification (name = "test-queue" ))
68
+ management .close ()
68
69
except Exception :
69
70
raised = True
70
71
71
72
assert raised is True
73
+
74
+ connection .close ()
75
+
76
+
77
+ def test_connection_oauth_refresh_token (environment_auth : Environment ) -> None :
78
+
79
+ connection = environment_auth .connection ()
80
+ connection .dial ()
81
+ # let the token expire
82
+ time .sleep (3 )
83
+ raised = False
84
+ # token expired, refresh
85
+ connection .refresh_token ("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGH" )
86
+
87
+ try :
88
+ management = connection .management ()
89
+ management .declare_queue (QuorumQueueSpecification (name = "test-queue" ))
90
+ except Exception :
91
+ raised = True
92
+
93
+ assert raised is False
72
94
connection .close ()
73
95
74
96
You can’t perform that action at this time.
0 commit comments