You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by zr...@apache.org on 2025/06/25 14:53:10 UTC
(dubbo) branch 3.3 updated: Remove oauth test cases which could not been compiled with jdk8 or jdk11 (#15489)
This is an automated email from the ASF dual-hosted git repository.
zrlw pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new a0b6e479fd Remove oauth test cases which could not been compiled with jdk8 or jdk11 (#15489)
a0b6e479fd is described below
commit a0b6e479fd479498d675626a26053df27a969de2
Author: zrlw <zr...@sina.com>
AuthorDate: Wed Jun 25 22:53:04 2025 +0800
Remove oauth test cases which could not been compiled with jdk8 or jdk11 (#15489)
---
.../security/jackson/ObjectMapperCodecTest.java | 74 +---------------------
1 file changed, 1 insertion(+), 73 deletions(-)
diff --git a/dubbo-plugin/dubbo-spring-security/src/test/java/org/apache/dubbo/spring/security/jackson/ObjectMapperCodecTest.java b/dubbo-plugin/dubbo-spring-security/src/test/java/org/apache/dubbo/spring/security/jackson/ObjectMapperCodecTest.java
index 780a7add65..ea2d613ec6 100644
--- a/dubbo-plugin/dubbo-spring-security/src/test/java/org/apache/dubbo/spring/security/jackson/ObjectMapperCodecTest.java
+++ b/dubbo-plugin/dubbo-spring-security/src/test/java/org/apache/dubbo/spring/security/jackson/ObjectMapperCodecTest.java
@@ -18,30 +18,18 @@ package org.apache.dubbo.spring.security.jackson;
import java.time.Duration;
import java.time.Instant;
-import java.util.Collections;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledForJreRange;
-import org.junit.jupiter.api.condition.JRE;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.registration.ClientRegistration;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
-import org.springframework.security.oauth2.core.DefaultOAuth2AuthenticatedPrincipal;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
-import org.springframework.security.oauth2.core.OAuth2AccessToken.TokenType;
-import org.springframework.security.oauth2.server.authorization.authentication.OAuth2ClientAuthenticationToken;
-import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
-import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
-import org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat;
-import org.springframework.security.oauth2.server.authorization.settings.TokenSettings;
-import org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthentication;
public class ObjectMapperCodecTest {
- private final ObjectMapperCodec mapper = new ObjectMapperCodec();
+ private ObjectMapperCodec mapper = new ObjectMapperCodec();
@Test
public void testOAuth2AuthorizedClientCodec() {
@@ -56,66 +44,6 @@ public class ObjectMapperCodecTest {
Assertions.assertNotNull(deserialize);
}
- @EnabledForJreRange(min = JRE.JAVA_17)
- @Test
- public void bearerTokenAuthenticationTest() {
- BearerTokenAuthentication bearerTokenAuthentication = new BearerTokenAuthentication(
- new DefaultOAuth2AuthenticatedPrincipal(
- "principal-name",
- Collections.singletonMap("name", "kali"),
- Collections.singleton(new SimpleGrantedAuthority("1"))),
- new OAuth2AccessToken(TokenType.BEARER, "111", Instant.MIN, Instant.MAX),
- Collections.emptyList());
- String content = mapper.serialize(bearerTokenAuthentication);
-
- BearerTokenAuthentication deserialize = mapper.deserialize(content.getBytes(), BearerTokenAuthentication.class);
-
- Assertions.assertNotNull(deserialize);
- }
-
- @EnabledForJreRange(min = JRE.JAVA_17)
- @Test
- public void oAuth2ClientAuthenticationTokenTest() {
- OAuth2ClientAuthenticationToken oAuth2ClientAuthenticationToken = new OAuth2ClientAuthenticationToken(
- "client-id", ClientAuthenticationMethod.CLIENT_SECRET_POST, "111", Collections.emptyMap());
-
- String content = mapper.serialize(oAuth2ClientAuthenticationToken);
-
- OAuth2ClientAuthenticationToken deserialize =
- mapper.deserialize(content.getBytes(), OAuth2ClientAuthenticationToken.class);
-
- Assertions.assertNotNull(deserialize);
- }
-
- @EnabledForJreRange(min = JRE.JAVA_17)
- @Test
- public void registeredClientTest() {
- RegisteredClient registeredClient = RegisteredClient.withId("id")
- .clientId("client-id")
- .clientName("client-name")
- .authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
- .redirectUri("https://example.com")
- .clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_JWT)
- .clientSecret("client-secret")
- .clientIdIssuedAt(Instant.MIN)
- .clientSecretExpiresAt(Instant.MAX)
- .tokenSettings(TokenSettings.builder()
- .accessTokenFormat(OAuth2TokenFormat.REFERENCE)
- .accessTokenTimeToLive(Duration.ofSeconds(1000))
- .build())
- .clientSettings(ClientSettings.builder()
- .setting("name", "value")
- .requireProofKey(true)
- .build())
- .build();
-
- String content = mapper.serialize(registeredClient);
-
- RegisteredClient deserialize = mapper.deserialize(content.getBytes(), RegisteredClient.class);
-
- Assertions.assertNotNull(deserialize);
- }
-
public static ClientRegistration.Builder clientRegistration() {
// @formatter:off
return ClientRegistration.withRegistrationId("registration-id")