1818package com .rabbitmq .client .amqp .impl ;
1919
2020import static com .rabbitmq .client .amqp .impl .Assertions .assertThat ;
21+ import static com .rabbitmq .client .amqp .impl .TestConditions .BrokerVersion .RABBITMQ_4_1_0 ;
2122import static com .rabbitmq .client .amqp .impl .TestUtils .*;
2223import static java .lang .System .currentTimeMillis ;
2324import static java .time .Duration .ofMillis ;
2425import static java .time .Duration .ofSeconds ;
2526import static org .assertj .core .api .Assertions .assertThatThrownBy ;
2627
2728import com .rabbitmq .client .amqp .*;
29+ import com .rabbitmq .client .amqp .impl .TestConditions .BrokerVersionAtLeast ;
2830import com .rabbitmq .client .amqp .impl .TestUtils .DisabledIfOauth2AuthBackendNotEnabled ;
2931import com .rabbitmq .client .amqp .impl .TestUtils .Sync ;
3032import java .time .Duration ;
@@ -48,22 +50,23 @@ public class Oauth2Test {
4850 Environment environment ;
4951
5052 @ Test
51- void expiredTokenShouldFail () throws Exception {
53+ void expiredTokenShouldFail () throws JoseException {
5254 String expiredToken = token (currentTimeMillis () - 1000 );
5355 assertThatThrownBy (
5456 () -> environment .connectionBuilder ().username ("" ).password (expiredToken ).build ())
5557 .isInstanceOf (AmqpException .AmqpSecurityException .class );
5658 }
5759
5860 @ Test
59- void validTokenShouldSucceed () throws Exception {
61+ void validTokenShouldSucceed () throws JoseException {
6062 String validToken = token (currentTimeMillis () + Duration .ofMinutes (10 ).toMillis ());
6163 try (Connection ignored =
6264 environment .connectionBuilder ().username ("" ).password (validToken ).build ()) {}
6365 }
6466
6567 @ Test
66- void connectionShouldBeClosedWhenTokenExpires (TestInfo info ) throws Exception {
68+ @ BrokerVersionAtLeast (RABBITMQ_4_1_0 )
69+ void connectionShouldBeClosedWhenTokenExpires (TestInfo info ) throws JoseException {
6770 String q = TestUtils .name (info );
6871 long expiry = currentTimeMillis () + ofSeconds (2 ).toMillis ();
6972 String token = token (expiry );
0 commit comments