From d0c7b74973d006362d334ae6ece4ac425f3e9501 Mon Sep 17 00:00:00 2001 From: wwan13 Date: Fri, 7 Jun 2024 00:36:29 +0900 Subject: [PATCH] refactor : Rename module authorizedRequest to authPatterns --- .../AuthPatterns.java} | 4 +-- .../Permissions.java | 2 +- .../Requests.java | 2 +- .../support/AuthPatternsApplier.java} | 10 +++--- .../support/AuthPatternsRegistry.java} | 34 +++++++++---------- .../provider/HttpRequestAccessManager.java | 12 +++---- .../config/AuthConfiguration.java | 6 ++-- .../config/AuthorizedRequestRegistrar.java | 13 ++++--- .../config/SecureRequestConfigurer.java | 4 +-- .../AuthPatternsTest.java} | 26 +++++++------- .../PermissionsTest.java | 2 +- .../RequestsTest.java | 2 +- .../support/AuthPatternsApplierTest.java} | 12 +++---- .../support/AuthPatternsRegistryTest.java} | 10 +++--- .../InterceptorAuthProcessorTest.java | 12 +++---- .../HttpRequestAccessManagerTest.java | 12 +++---- .../AllConfiguresTestConfigure.java | 4 +-- .../SecureRequestTestConfig.java | 4 +-- 18 files changed, 85 insertions(+), 86 deletions(-) rename src/main/java/io/wwan13/wintersecurity/auth/{authorizedrequest/AuthorizedRequest.java => authpattern/AuthPatterns.java} (93%) rename src/main/java/io/wwan13/wintersecurity/auth/{authorizedrequest => authpattern}/Permissions.java (96%) rename src/main/java/io/wwan13/wintersecurity/auth/{authorizedrequest => authpattern}/Requests.java (95%) rename src/main/java/io/wwan13/wintersecurity/auth/{authorizedrequest/support/AuthorizedRequestApplier.java => authpattern/support/AuthPatternsApplier.java} (71%) rename src/main/java/io/wwan13/wintersecurity/auth/{authorizedrequest/support/AuthorizedRequestRegistry.java => authpattern/support/AuthPatternsRegistry.java} (80%) rename src/test/java/io/wwan13/wintersecurity/auth/{authorizedrequest/AuthorizedRequestTest.java => authpattern/AuthPatternsTest.java} (82%) rename src/test/java/io/wwan13/wintersecurity/auth/{authorizedrequest => authpattern}/PermissionsTest.java (98%) rename src/test/java/io/wwan13/wintersecurity/auth/{authorizedrequest => authpattern}/RequestsTest.java (97%) rename src/test/java/io/wwan13/wintersecurity/auth/{authorizedrequest/support/AuthorizedRequestApplierTest.java => authpattern/support/AuthPatternsApplierTest.java} (70%) rename src/test/java/io/wwan13/wintersecurity/auth/{authorizedrequest/support/AuthorizedRequestRegistryTest.java => authpattern/support/AuthPatternsRegistryTest.java} (77%) diff --git a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/AuthorizedRequest.java b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/AuthPatterns.java similarity index 93% rename from src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/AuthorizedRequest.java rename to src/main/java/io/wwan13/wintersecurity/auth/authpattern/AuthPatterns.java index 57195c7..ee1c90a 100644 --- a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/AuthorizedRequest.java +++ b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/AuthPatterns.java @@ -14,14 +14,14 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest; +package io.wwan13.wintersecurity.auth.authpattern; import org.springframework.http.HttpMethod; import java.util.Map; import java.util.Set; -public record AuthorizedRequest( +public record AuthPatterns( Map registered, boolean isElseRequestPermit ) { diff --git a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/Permissions.java b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/Permissions.java similarity index 96% rename from src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/Permissions.java rename to src/main/java/io/wwan13/wintersecurity/auth/authpattern/Permissions.java index c914f61..8e02c4c 100644 --- a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/Permissions.java +++ b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/Permissions.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest; +package io.wwan13.wintersecurity.auth.authpattern; import io.wwan13.wintersecurity.constant.DefaultAuthPattern; diff --git a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/Requests.java b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/Requests.java similarity index 95% rename from src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/Requests.java rename to src/main/java/io/wwan13/wintersecurity/auth/authpattern/Requests.java index 0143b41..c0d6fda 100644 --- a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/Requests.java +++ b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/Requests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest; +package io.wwan13.wintersecurity.auth.authpattern; import org.springframework.http.HttpMethod; import org.springframework.util.AntPathMatcher; diff --git a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestApplier.java b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsApplier.java similarity index 71% rename from src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestApplier.java rename to src/main/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsApplier.java index 9b67463..0c64594 100644 --- a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestApplier.java +++ b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsApplier.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest.support; +package io.wwan13.wintersecurity.auth.authpattern.support; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; -public class AuthorizedRequestApplier { +public class AuthPatternsApplier { - private AuthorizedRequestApplier() { + private AuthPatternsApplier() { throw new IllegalStateException("Cannot instantiate a utility class!"); } - public static AuthorizedRequest apply(AuthorizedRequestRegistry registry) { + public static AuthPatterns apply(AuthPatternsRegistry registry) { return registry.apply(); } } diff --git a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestRegistry.java b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsRegistry.java similarity index 80% rename from src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestRegistry.java rename to src/main/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsRegistry.java index 87bdaa5..3f007f3 100644 --- a/src/main/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestRegistry.java +++ b/src/main/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsRegistry.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest.support; +package io.wwan13.wintersecurity.auth.authpattern.support; -import io.wwan13.wintersecurity.auth.authorizedrequest.Permissions; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; -import io.wwan13.wintersecurity.auth.authorizedrequest.Requests; +import io.wwan13.wintersecurity.auth.authpattern.Permissions; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; +import io.wwan13.wintersecurity.auth.authpattern.Requests; import io.wwan13.wintersecurity.constant.RegistryOptions; import org.springframework.http.HttpMethod; @@ -27,12 +27,12 @@ import java.util.Set; import java.util.stream.Collectors; -public class AuthorizedRequestRegistry { +public class AuthPatternsRegistry { private final Map registered; private boolean isElseRequestPermit; - public AuthorizedRequestRegistry( + public AuthPatternsRegistry( Map registered, boolean isElseRequestPermit ) { @@ -40,8 +40,8 @@ public AuthorizedRequestRegistry( this.isElseRequestPermit = isElseRequestPermit; } - public static AuthorizedRequestRegistry of() { - return new AuthorizedRequestRegistry( + public static AuthPatternsRegistry of() { + return new AuthPatternsRegistry( new LinkedHashMap<>(), RegistryOptions.DEFAULT_ELSE_REQUEST_OPTION ); @@ -59,16 +59,16 @@ public void elseRequestAuthenticated() { this.isElseRequestPermit = false; } - protected AuthorizedRequest apply() { - return new AuthorizedRequest(registered, isElseRequestPermit); + protected AuthPatterns apply() { + return new AuthPatterns(registered, isElseRequestPermit); } public static class HttpMethodAppender { - private final AuthorizedRequestRegistry registry; + private final AuthPatternsRegistry registry; private final Set uriPatterns; - HttpMethodAppender(AuthorizedRequestRegistry registry, Set uriPatterns) { + HttpMethodAppender(AuthPatternsRegistry registry, Set uriPatterns) { this.registry = registry; this.uriPatterns = uriPatterns; } @@ -104,12 +104,12 @@ public RolesAppender httpMethodDelete() { public static class RolesAppender { - private final AuthorizedRequestRegistry registry; + private final AuthPatternsRegistry registry; private final Set uriPatterns; private final Set httpMethods; RolesAppender( - AuthorizedRequestRegistry registry, + AuthPatternsRegistry registry, Set uriPatterns, Set httpMethods ) { @@ -118,17 +118,17 @@ public static class RolesAppender { this.httpMethods = httpMethods; } - public AuthorizedRequestRegistry permitAll() { + public AuthPatternsRegistry permitAll() { appendRolesPerPattern(RegistryOptions.ALL_ROLES); return registry; } - public AuthorizedRequestRegistry authenticated() { + public AuthPatternsRegistry authenticated() { appendRolesPerPattern(RegistryOptions.EMPTY_ROLES); return registry; } - public AuthorizedRequestRegistry hasRoles(Object... roles) { + public AuthPatternsRegistry hasRoles(Object... roles) { appendRolesPerPattern(Set.of(roles)); return registry; } diff --git a/src/main/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManager.java b/src/main/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManager.java index 8ed73fd..dc8f9b5 100644 --- a/src/main/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManager.java +++ b/src/main/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManager.java @@ -17,7 +17,7 @@ package io.wwan13.wintersecurity.auth.provider; import io.wwan13.wintersecurity.auth.RequestAccessManager; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; import io.wwan13.wintersecurity.constant.DefaultAuthPattern; import io.wwan13.wintersecurity.exception.forbidden.ForbiddenException; import io.wwan13.wintersecurity.exception.unauthirized.UnauthorizedException; @@ -28,10 +28,10 @@ public class HttpRequestAccessManager implements RequestAccessManager { - private final AuthorizedRequest authorizedRequest; + private final AuthPatterns authPatterns; - public HttpRequestAccessManager(AuthorizedRequest authorizedRequest) { - this.authorizedRequest = authorizedRequest; + public HttpRequestAccessManager(AuthPatterns authPatterns) { + this.authPatterns = authPatterns; } public void manageWithAuthentication( @@ -39,7 +39,7 @@ public void manageWithAuthentication( String uri, Set roles ) { - if (!authorizedRequest.isAccessibleRequest(method, uri, roles)) { + if (!authPatterns.isAccessibleRequest(method, uri, roles)) { throw new ForbiddenException(); } } @@ -47,7 +47,7 @@ public void manageWithAuthentication( public void manageWithoutAuthentication(HttpMethod method, String uri) { Set role = Collections.singleton(DefaultAuthPattern.ANONYMOUS_ROLE); - if (!authorizedRequest.isAccessibleRequest(method, uri, role)) { + if (!authPatterns.isAccessibleRequest(method, uri, role)) { throw new UnauthorizedException(); } } diff --git a/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java b/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java index c8f5157..502682e 100644 --- a/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java +++ b/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java @@ -18,7 +18,7 @@ import io.wwan13.wintersecurity.auth.RequestAccessManager; import io.wwan13.wintersecurity.auth.TokenExtractor; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; import io.wwan13.wintersecurity.auth.processor.AbstractInterceptorAuthProcessor; import io.wwan13.wintersecurity.auth.processor.InterceptorAuthProcessor; import io.wwan13.wintersecurity.auth.provider.BearerTokenExtractor; @@ -45,8 +45,8 @@ public TokenExtractor tokenExtractor() { } @Bean - public RequestAccessManager requestAccessManager(AuthorizedRequest authorizedRequest) { - return new HttpRequestAccessManager(authorizedRequest); + public RequestAccessManager requestAccessManager(AuthPatterns authPatterns) { + return new HttpRequestAccessManager(authPatterns); } @Bean diff --git a/src/main/java/io/wwan13/wintersecurity/config/AuthorizedRequestRegistrar.java b/src/main/java/io/wwan13/wintersecurity/config/AuthorizedRequestRegistrar.java index 46454b9..1716894 100644 --- a/src/main/java/io/wwan13/wintersecurity/config/AuthorizedRequestRegistrar.java +++ b/src/main/java/io/wwan13/wintersecurity/config/AuthorizedRequestRegistrar.java @@ -16,10 +16,9 @@ package io.wwan13.wintersecurity.config; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestApplier; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsApplier; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import org.springframework.context.annotation.Bean; public class AuthorizedRequestRegistrar { @@ -31,9 +30,9 @@ public AuthorizedRequestRegistrar(SecureRequestConfigurer secureRequestConfigure } @Bean - public AuthorizedRequest authorizedRequest() { - AuthorizedRequestRegistry registry = AuthorizedRequestRegistry.of(); + public AuthPatterns authorizedRequest() { + AuthPatternsRegistry registry = AuthPatternsRegistry.of(); secureRequestConfigurer.registerAuthPatterns(registry); - return AuthorizedRequestApplier.apply(registry); + return AuthPatternsApplier.apply(registry); } } diff --git a/src/main/java/io/wwan13/wintersecurity/config/SecureRequestConfigurer.java b/src/main/java/io/wwan13/wintersecurity/config/SecureRequestConfigurer.java index f79f522..924b65b 100644 --- a/src/main/java/io/wwan13/wintersecurity/config/SecureRequestConfigurer.java +++ b/src/main/java/io/wwan13/wintersecurity/config/SecureRequestConfigurer.java @@ -16,12 +16,12 @@ package io.wwan13.wintersecurity.config; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import io.wwan13.wintersecurity.resolve.support.TargetAnnotationsRegistry; public interface SecureRequestConfigurer extends SecretKeyConfigurer { - void registerAuthPatterns(AuthorizedRequestRegistry registry); + void registerAuthPatterns(AuthPatternsRegistry registry); void registerTargetAnnotations(TargetAnnotationsRegistry registry); } diff --git a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/AuthorizedRequestTest.java b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/AuthPatternsTest.java similarity index 82% rename from src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/AuthorizedRequestTest.java rename to src/test/java/io/wwan13/wintersecurity/auth/authpattern/AuthPatternsTest.java index c5edd93..4ce7898 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/AuthorizedRequestTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/AuthPatternsTest.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest; +package io.wwan13.wintersecurity.auth.authpattern; import io.wwan13.wintersecurity.UnitTest; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestApplier; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsApplier; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springframework.http.HttpMethod; @@ -29,7 +29,7 @@ import static org.springframework.http.HttpMethod.GET; import static org.springframework.http.HttpMethod.POST; -class AuthorizedRequestTest extends UnitTest { +class AuthPatternsTest extends UnitTest { @ParameterizedTest @CsvSource({ @@ -48,7 +48,7 @@ void should_JudgeRequestIsAccessible( final boolean expected ) { // given - AuthorizedRequestRegistry registry = AuthorizedRequestRegistry.of(); + AuthPatternsRegistry registry = AuthPatternsRegistry.of(); registry .uriPatterns("/api/admin/**") .httpMethods(GET, POST) @@ -72,10 +72,10 @@ void should_JudgeRequestIsAccessible( .elseRequestAuthenticated(); - AuthorizedRequest authorizedRequest = AuthorizedRequestApplier.apply(registry); + AuthPatterns authPatterns = AuthPatternsApplier.apply(registry); // when - boolean result = authorizedRequest + boolean result = authPatterns .isAccessibleRequest(HttpMethod.resolve(requestMethod), requestUri, Set.of(requestRole)); // then @@ -97,7 +97,7 @@ void should_AcceptUnregisteredRequest_when_AnyRequestPermitAll( final boolean expected ) { // given - AuthorizedRequestRegistry registry = AuthorizedRequestRegistry.of(); + AuthPatternsRegistry registry = AuthPatternsRegistry.of(); registry .uriPatterns("/api/test") .httpMethods(GET) @@ -105,10 +105,10 @@ void should_AcceptUnregisteredRequest_when_AnyRequestPermitAll( .elseRequestPermit(); - AuthorizedRequest authorizedRequest = AuthorizedRequestApplier.apply(registry); + AuthPatterns authPatterns = AuthPatternsApplier.apply(registry); // when - boolean result = authorizedRequest + boolean result = authPatterns .isAccessibleRequest(HttpMethod.resolve(requestMethod), requestUri, Set.of(requestRole)); // then @@ -131,7 +131,7 @@ void should_BlockUnregisteredRequest_when_AnyRequestAuthenticated( final boolean expected ) { // given - AuthorizedRequestRegistry registry = AuthorizedRequestRegistry.of(); + AuthPatternsRegistry registry = AuthPatternsRegistry.of(); registry .uriPatterns("/api/test") .httpMethods(GET) @@ -139,10 +139,10 @@ void should_BlockUnregisteredRequest_when_AnyRequestAuthenticated( .elseRequestAuthenticated(); - AuthorizedRequest authorizedRequest = AuthorizedRequestApplier.apply(registry); + AuthPatterns authPatterns = AuthPatternsApplier.apply(registry); // when - boolean result = authorizedRequest + boolean result = authPatterns .isAccessibleRequest(HttpMethod.resolve(requestMethod), requestUri, Set.of(requestRole)); // then diff --git a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/PermissionsTest.java b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/PermissionsTest.java similarity index 98% rename from src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/PermissionsTest.java rename to src/test/java/io/wwan13/wintersecurity/auth/authpattern/PermissionsTest.java index a87da4d..943a790 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/PermissionsTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/PermissionsTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest; +package io.wwan13.wintersecurity.auth.authpattern; import io.wwan13.wintersecurity.UnitTest; import io.wwan13.wintersecurity.constant.DefaultAuthPattern; diff --git a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/RequestsTest.java b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/RequestsTest.java similarity index 97% rename from src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/RequestsTest.java rename to src/test/java/io/wwan13/wintersecurity/auth/authpattern/RequestsTest.java index 9a91aa7..4976690 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/RequestsTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/RequestsTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest; +package io.wwan13.wintersecurity.auth.authpattern; import io.wwan13.wintersecurity.UnitTest; import org.junit.jupiter.api.Test; diff --git a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestApplierTest.java b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsApplierTest.java similarity index 70% rename from src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestApplierTest.java rename to src/test/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsApplierTest.java index b66be51..28c84b4 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestApplierTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsApplierTest.java @@ -14,20 +14,20 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest.support; +package io.wwan13.wintersecurity.auth.authpattern.support; import io.wwan13.wintersecurity.UnitTest; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -class AuthorizedRequestApplierTest extends UnitTest { +class AuthPatternsApplierTest extends UnitTest { @Test void should_CreateAuthorizedRequest_when_RegistryEntered() { // given - final AuthorizedRequestRegistry registry = AuthorizedRequestRegistry.of(); + final AuthPatternsRegistry registry = AuthPatternsRegistry.of(); registry .uriPatterns("/api/test") .allHttpMethods() @@ -35,9 +35,9 @@ void should_CreateAuthorizedRequest_when_RegistryEntered() { .elseRequestPermit(); // when - AuthorizedRequest authorizedRequest = AuthorizedRequestApplier.apply(registry); + AuthPatterns authPatterns = AuthPatternsApplier.apply(registry); // then - assertThat(authorizedRequest).isInstanceOf(AuthorizedRequest.class); + assertThat(authPatterns).isInstanceOf(AuthPatterns.class); } } \ No newline at end of file diff --git a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestRegistryTest.java b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsRegistryTest.java similarity index 77% rename from src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestRegistryTest.java rename to src/test/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsRegistryTest.java index 946fbe5..a21822a 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/authorizedrequest/support/AuthorizedRequestRegistryTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/authpattern/support/AuthPatternsRegistryTest.java @@ -14,16 +14,16 @@ * limitations under the License. */ -package io.wwan13.wintersecurity.auth.authorizedrequest.support; +package io.wwan13.wintersecurity.auth.authpattern.support; import io.wwan13.wintersecurity.UnitTest; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import static org.assertj.core.api.Assertions.assertThat; -class AuthorizedRequestRegistryTest extends UnitTest { +class AuthPatternsRegistryTest extends UnitTest { @Test void should_CreateAuthorizedRequest_when_UsingRegistry() { @@ -33,13 +33,13 @@ void should_CreateAuthorizedRequest_when_UsingRegistry() { final String role = "role"; // when - AuthorizedRequest authorizedRequest = AuthorizedRequestRegistry.of() + AuthPatterns authPatterns = AuthPatternsRegistry.of() .uriPatterns(uriPattern) .httpMethods(httpMethod) .hasRoles(role) .apply(); // then - assertThat(authorizedRequest).isInstanceOf(AuthorizedRequest.class); + assertThat(authPatterns).isInstanceOf(AuthPatterns.class); } } \ No newline at end of file diff --git a/src/test/java/io/wwan13/wintersecurity/auth/processor/InterceptorAuthProcessorTest.java b/src/test/java/io/wwan13/wintersecurity/auth/processor/InterceptorAuthProcessorTest.java index 8aff75b..dbd6a95 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/processor/InterceptorAuthProcessorTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/processor/InterceptorAuthProcessorTest.java @@ -19,9 +19,9 @@ import io.wwan13.wintersecurity.UnitTest; import io.wwan13.wintersecurity.auth.AuthTestContainer; import io.wwan13.wintersecurity.auth.RequestAccessManager; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestApplier; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsApplier; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import io.wwan13.wintersecurity.auth.provider.HttpRequestAccessManager; import io.wwan13.wintersecurity.auth.stub.StubHttpServletRequest; import io.wwan13.wintersecurity.exception.forbidden.ForbiddenException; @@ -37,8 +37,8 @@ class InterceptorAuthProcessorTest extends UnitTest { - static AuthorizedRequest authorizedRequest = AuthorizedRequestApplier.apply( - AuthorizedRequestRegistry.of() + static AuthPatterns authPatterns = AuthPatternsApplier.apply( + AuthPatternsRegistry.of() .uriPatterns("/api/user") .httpMethods(HttpMethod.POST, HttpMethod.GET) .hasRoles("ROLE_USER") @@ -52,7 +52,7 @@ class InterceptorAuthProcessorTest extends UnitTest { .permitAll() ); - static RequestAccessManager accessManager = new HttpRequestAccessManager(authorizedRequest); + static RequestAccessManager accessManager = new HttpRequestAccessManager(authPatterns); static InterceptorAuthProcessor interceptorAuthProcessor = new InterceptorAuthProcessor( AuthTestContainer.tokenExtractor, diff --git a/src/test/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManagerTest.java b/src/test/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManagerTest.java index 370dd81..f0a84b2 100644 --- a/src/test/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManagerTest.java +++ b/src/test/java/io/wwan13/wintersecurity/auth/provider/HttpRequestAccessManagerTest.java @@ -17,9 +17,9 @@ package io.wwan13.wintersecurity.auth.provider; import io.wwan13.wintersecurity.UnitTest; -import io.wwan13.wintersecurity.auth.authorizedrequest.AuthorizedRequest; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestApplier; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; +import io.wwan13.wintersecurity.auth.authpattern.AuthPatterns; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsApplier; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import io.wwan13.wintersecurity.exception.forbidden.ForbiddenException; import io.wwan13.wintersecurity.exception.unauthirized.UnauthorizedException; import org.junit.jupiter.api.Test; @@ -32,8 +32,8 @@ class HttpRequestAccessManagerTest extends UnitTest { - static AuthorizedRequest authorizedRequest = AuthorizedRequestApplier.apply( - AuthorizedRequestRegistry.of() + static AuthPatterns authPatterns = AuthPatternsApplier.apply( + AuthPatternsRegistry.of() .uriPatterns("/api/test") .httpMethods(HttpMethod.POST, HttpMethod.GET) .hasRoles("ROLE_USER") @@ -43,7 +43,7 @@ class HttpRequestAccessManagerTest extends UnitTest { .permitAll() ); - static HttpRequestAccessManager accessManager = new HttpRequestAccessManager(authorizedRequest); + static HttpRequestAccessManager accessManager = new HttpRequestAccessManager(authPatterns); @Test void should_PassWithoutException_when_ValidRequestEnteredWithAuthentication() { diff --git a/src/test/java/io/wwan13/wintersecurity/context/allconfigures/AllConfiguresTestConfigure.java b/src/test/java/io/wwan13/wintersecurity/context/allconfigures/AllConfiguresTestConfigure.java index d336dad..2363cc3 100644 --- a/src/test/java/io/wwan13/wintersecurity/context/allconfigures/AllConfiguresTestConfigure.java +++ b/src/test/java/io/wwan13/wintersecurity/context/allconfigures/AllConfiguresTestConfigure.java @@ -16,7 +16,7 @@ package io.wwan13.wintersecurity.context.allconfigures; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import io.wwan13.wintersecurity.config.EnableJwtProvider; import io.wwan13.wintersecurity.config.EnableSecureRequest; import io.wwan13.wintersecurity.config.JwtProviderConfigurer; @@ -48,7 +48,7 @@ public void configureSecretKey(SecretKeyRegistry registry) { } @Override - public void registerAuthPatterns(AuthorizedRequestRegistry registry) { + public void registerAuthPatterns(AuthPatternsRegistry registry) { registry .uriPatterns("/api/test/**") .allHttpMethods() diff --git a/src/test/java/io/wwan13/wintersecurity/context/securerequest/SecureRequestTestConfig.java b/src/test/java/io/wwan13/wintersecurity/context/securerequest/SecureRequestTestConfig.java index dba38d0..2f8d517 100644 --- a/src/test/java/io/wwan13/wintersecurity/context/securerequest/SecureRequestTestConfig.java +++ b/src/test/java/io/wwan13/wintersecurity/context/securerequest/SecureRequestTestConfig.java @@ -16,7 +16,7 @@ package io.wwan13.wintersecurity.context.securerequest; -import io.wwan13.wintersecurity.auth.authorizedrequest.support.AuthorizedRequestRegistry; +import io.wwan13.wintersecurity.auth.authpattern.support.AuthPatternsRegistry; import io.wwan13.wintersecurity.config.EnableSecureRequest; import io.wwan13.wintersecurity.config.SecureRequestConfigurer; import io.wwan13.wintersecurity.resolve.RequestUserId; @@ -36,7 +36,7 @@ public void configureSecretKey(SecretKeyRegistry registry) { } @Override - public void registerAuthPatterns(AuthorizedRequestRegistry registry) { + public void registerAuthPatterns(AuthPatternsRegistry registry) { registry .uriPatterns("/api/test/**") .allHttpMethods()