Skip to content

Commit a0b6e47

Browse files
authored
Remove oauth test cases which could not been compiled with jdk8 or jdk11 (#15489)
1 parent 11c151f commit a0b6e47

1 file changed

Lines changed: 1 addition & 73 deletions

File tree

dubbo-plugin/dubbo-spring-security/src/test/java/org/apache/dubbo/spring/security/jackson/ObjectMapperCodecTest.java

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,18 @@
1818

1919
import java.time.Duration;
2020
import java.time.Instant;
21-
import java.util.Collections;
2221

2322
import org.junit.jupiter.api.Assertions;
2423
import org.junit.jupiter.api.Test;
25-
import org.junit.jupiter.api.condition.EnabledForJreRange;
26-
import org.junit.jupiter.api.condition.JRE;
27-
import org.springframework.security.core.authority.SimpleGrantedAuthority;
2824
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
2925
import org.springframework.security.oauth2.client.registration.ClientRegistration;
3026
import org.springframework.security.oauth2.core.AuthorizationGrantType;
3127
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
32-
import org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal;
3328
import org.springframework.security.oauth2.core.OAuth2AccessToken;
34-
import org.springframework.security.oauth2.core.OAuth2AccessToken.TokenType;
35-
import org.springframework.security.oauth2.server.authorization.authentication.OAuth2ClientAuthenticationToken;
36-
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
37-
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
38-
import org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat;
39-
import org.springframework.security.oauth2.server.authorization.settings.TokenSettings;
40-
import org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication;
4129

4230
public class ObjectMapperCodecTest {
4331

44-
private final ObjectMapperCodec mapper = new ObjectMapperCodec();
32+
private ObjectMapperCodec mapper = new ObjectMapperCodec();
4533

4634
@Test
4735
public void testOAuth2AuthorizedClientCodec() {
@@ -56,66 +44,6 @@ public void testOAuth2AuthorizedClientCodec() {
5644
Assertions.assertNotNull(deserialize);
5745
}
5846

59-
@EnabledForJreRange(min = JRE.JAVA_17)
60-
@Test
61-
public void bearerTokenAuthenticationTest() {
62-
BearerTokenAuthentication bearerTokenAuthentication = new BearerTokenAuthentication(
63-
new DefaultOAuth2AuthenticatedPrincipal(
64-
"principal-name",
65-
Collections.singletonMap("name", "kali"),
66-
Collections.singleton(new SimpleGrantedAuthority("1"))),
67-
new OAuth2AccessToken(TokenType.BEARER, "111", Instant.MIN, Instant.MAX),
68-
Collections.emptyList());
69-
String content = mapper.serialize(bearerTokenAuthentication);
70-
71-
BearerTokenAuthentication deserialize = mapper.deserialize(content.getBytes(), BearerTokenAuthentication.class);
72-
73-
Assertions.assertNotNull(deserialize);
74-
}
75-
76-
@EnabledForJreRange(min = JRE.JAVA_17)
77-
@Test
78-
public void oAuth2ClientAuthenticationTokenTest() {
79-
OAuth2ClientAuthenticationToken oAuth2ClientAuthenticationToken = new OAuth2ClientAuthenticationToken(
80-
"client-id", ClientAuthenticationMethod.CLIENT_SECRET_POST, "111", Collections.emptyMap());
81-
82-
String content = mapper.serialize(oAuth2ClientAuthenticationToken);
83-
84-
OAuth2ClientAuthenticationToken deserialize =
85-
mapper.deserialize(content.getBytes(), OAuth2ClientAuthenticationToken.class);
86-
87-
Assertions.assertNotNull(deserialize);
88-
}
89-
90-
@EnabledForJreRange(min = JRE.JAVA_17)
91-
@Test
92-
public void registeredClientTest() {
93-
RegisteredClient registeredClient = RegisteredClient.withId("id")
94-
.clientId("client-id")
95-
.clientName("client-name")
96-
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
97-
.redirectUri("https://example.com")
98-
.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_JWT)
99-
.clientSecret("client-secret")
100-
.clientIdIssuedAt(Instant.MIN)
101-
.clientSecretExpiresAt(Instant.MAX)
102-
.tokenSettings(TokenSettings.builder()
103-
.accessTokenFormat(OAuth2TokenFormat.REFERENCE)
104-
.accessTokenTimeToLive(Duration.ofSeconds(1000))
105-
.build())
106-
.clientSettings(ClientSettings.builder()
107-
.setting("name", "value")
108-
.requireProofKey(true)
109-
.build())
110-
.build();
111-
112-
String content = mapper.serialize(registeredClient);
113-
114-
RegisteredClient deserialize = mapper.deserialize(content.getBytes(), RegisteredClient.class);
115-
116-
Assertions.assertNotNull(deserialize);
117-
}
118-
11947
public static ClientRegistration.Builder clientRegistration() {
12048
// @formatter:off
12149
return ClientRegistration.withRegistrationId("registration-id")

0 commit comments

Comments
 (0)