From 4f44256d36a82acd36565e4aeeb06716e4387c66 Mon Sep 17 00:00:00 2001 From: fuhouyu Date: Wed, 9 Oct 2024 18:59:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20maven=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/security/SecurityAutoConfigure.java | 3 +++ .../fuhouyu/framework/security/TokenStoreTest.java | 14 +++++++------- pom.xml | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/base-framework-security-starter/src/main/java/com/fuhouyu/framework/security/SecurityAutoConfigure.java b/base-framework-security-starter/src/main/java/com/fuhouyu/framework/security/SecurityAutoConfigure.java index e34ab4a..a8c9049 100644 --- a/base-framework-security-starter/src/main/java/com/fuhouyu/framework/security/SecurityAutoConfigure.java +++ b/base-framework-security-starter/src/main/java/com/fuhouyu/framework/security/SecurityAutoConfigure.java @@ -16,10 +16,12 @@ package com.fuhouyu.framework.security; +import com.fuhouyu.framework.cache.CacheAutoConfigure; import com.fuhouyu.framework.cache.service.CacheService; import com.fuhouyu.framework.security.core.passwordencoder.PasswordEncoderFactory; import com.fuhouyu.framework.security.token.TokenStore; import com.fuhouyu.framework.security.token.TokenStoreCache; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -44,6 +46,7 @@ */ @ComponentScan(basePackageClasses = SecurityAutoConfigure.class) @Import({OpenPlatformAutoConfigure.class}) +@AutoConfigureAfter(CacheAutoConfigure.class) public class SecurityAutoConfigure { /** diff --git a/base-framework-security-starter/src/test/java/com/fuhouyu/framework/security/TokenStoreTest.java b/base-framework-security-starter/src/test/java/com/fuhouyu/framework/security/TokenStoreTest.java index 308b86f..ace3db1 100644 --- a/base-framework-security-starter/src/test/java/com/fuhouyu/framework/security/TokenStoreTest.java +++ b/base-framework-security-starter/src/test/java/com/fuhouyu/framework/security/TokenStoreTest.java @@ -21,6 +21,7 @@ import com.fuhouyu.framework.security.token.DefaultOAuth2Token; import com.fuhouyu.framework.security.token.TokenStore; import com.fuhouyu.framework.security.token.TokenStoreCache; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +32,6 @@ import org.springframework.security.oauth2.core.OAuth2AccessToken; import org.springframework.security.oauth2.core.OAuth2RefreshToken; import org.springframework.test.context.TestPropertySource; -import org.springframework.util.Assert; import java.util.Collections; @@ -68,22 +68,22 @@ void setup() { void testTokenStore() { DefaultOAuth2Token accessToken = tokenStore.createToken(authentication, 60, 60); - Assert.notNull(accessToken, "生成的token不能为空"); + Assertions.assertNotNull(accessToken, "生成的token不能为空"); Authentication tokenAuthentication = tokenStore.readAuthentication(accessToken); - Assert.notNull(tokenAuthentication, "未获取到token认证的对象"); + Assertions.assertNotNull(tokenAuthentication, "未获取到token认证的对象"); OAuth2RefreshToken oAuth2RefreshToken = tokenStore.readRefreshToken(accessToken.getAuth2RefreshToken().getTokenValue()); - Assert.notNull(oAuth2RefreshToken, "未获取到刷新令牌对象"); + Assertions.assertNotNull(oAuth2RefreshToken, "未获取到刷新令牌对象"); Authentication authenticationByRefreshToken = tokenStore.readAuthenticationForRefreshToken(oAuth2RefreshToken); - Assert.notNull(authenticationByRefreshToken, "未通过刷新令牌获取到认证对象"); + Assertions.assertNotNull(authenticationByRefreshToken, "未通过刷新令牌获取到认证对象"); tokenStore.removeAllToken(accessToken); OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(accessToken.getTokenValue()); - Assert.isNull(oAuth2AccessToken, "access token 未被清除"); + Assertions.assertNull(oAuth2AccessToken, "access token 未被清除"); - Assert.isNull(tokenStore.readRefreshToken(accessToken.getAuth2RefreshToken().getTokenValue()), "refresh token 未被清除"); + Assertions.assertNull(tokenStore.readRefreshToken(accessToken.getAuth2RefreshToken().getTokenValue()), "refresh token 未被清除"); } } diff --git a/pom.xml b/pom.xml index 22e7715..8e5e24f 100644 --- a/pom.xml +++ b/pom.xml @@ -420,10 +420,12 @@ org.springframework.boot spring-boot-autoconfigure-processor + ${spring-boot-dependencies.version} org.springframework.boot spring-boot-configuration-processor + ${spring-boot-dependencies.version} org.projectlombok