Skip to content

Commit 80dabad

Browse files
committed
Run token expiration test only on RabbitMQ 4.1+
1 parent 9f14d9d commit 80dabad

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.github/workflows/test-pr.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
cache: 'maven'
2525
- name: Start broker
2626
run: ci/start-broker.sh
27-
env:
28-
RABBITMQ_IMAGE: 'pivotalrabbitmq/rabbitmq:main'
2927
- name: Start toxiproxy
3028
run: ci/start-toxiproxy.sh
3129
- name: Display Java version

src/test/java/com/rabbitmq/client/amqp/impl/Oauth2Test.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
package com.rabbitmq.client.amqp.impl;
1919

2020
import static com.rabbitmq.client.amqp.impl.Assertions.assertThat;
21+
import static com.rabbitmq.client.amqp.impl.TestConditions.BrokerVersion.RABBITMQ_4_1_0;
2122
import static com.rabbitmq.client.amqp.impl.TestUtils.*;
2223
import static java.lang.System.currentTimeMillis;
2324
import static java.time.Duration.ofMillis;
2425
import static java.time.Duration.ofSeconds;
2526
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2627

2728
import com.rabbitmq.client.amqp.*;
29+
import com.rabbitmq.client.amqp.impl.TestConditions.BrokerVersionAtLeast;
2830
import com.rabbitmq.client.amqp.impl.TestUtils.DisabledIfOauth2AuthBackendNotEnabled;
2931
import com.rabbitmq.client.amqp.impl.TestUtils.Sync;
3032
import 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

Comments
 (0)