From ae703fdda11fb828ece871a7f3c440db9b7c36ce Mon Sep 17 00:00:00 2001 From: mrflick72 Date: Tue, 22 Oct 2024 21:57:09 +0200 Subject: [PATCH] repackaging --- .../server/account/api/AccountEndPoint.kt | 2 +- .../emailverification/EMailVerificationEndPoint.kt | 2 +- .../repository/dynamodb/DynamoDbAccountRepository.kt | 2 +- .../vauthenticator/server/account/signup/SignUpUse.kt | 2 +- .../server/account/welcome/WelcomeMailEndPoint.kt | 2 +- .../com/vauthenticator/server/config/AccountConfig.kt | 2 +- .../vauthenticator/server/config/PermissionConfig.kt | 4 ++-- .../server/mfa/api/MfaChallengeEndPoint.kt | 2 +- .../server/mfa/api/MfaMethodsEnrolmentEndPoint.kt | 2 +- .../oauth2/clientapp/api/ClientApplicationEndPoint.kt | 2 +- .../password/resetpassword/RestePasswordEndPoint.kt | 2 +- .../server/role/adapter/CachedRoleRepository.kt | 4 ++-- .../dynamodb/DynamoDbRoleMapper.kt} | 11 ++--------- .../role/adapter/dynamodb/DynamoDbRoleRepository.kt | 7 +++---- .../server/role/adapter/jdbc/JdbcRoleRepository.kt | 6 +++--- .../server/role/{ => api}/RoleEndPoint.kt | 5 ++++- .../server/role/{ => domain}/PermissionValidator.kt | 2 +- .../vauthenticator/server/role/{ => domain}/Role.kt | 2 +- .../server/role/domain/RoleRepository.kt | 10 ++++++++++ .../server/account/api/AccountEndPointTest.kt | 2 +- .../account/api/AdminApiAccountApiConverterTest.kt | 2 +- .../emailverification/MailVerificationEndPointTest.kt | 2 +- .../repository/AbstractAccountRepositoryTest.kt | 8 ++++---- .../dynamodb/DynamoDbAbstractAccountRepositoryTest.kt | 4 ++-- .../repository/jdbc/JdbcAccountRepositoryTest.kt | 4 ++-- .../server/account/signup/SignUpUseTest.kt | 2 +- .../account/welcome/WelcomeEMailEndPointTest.kt | 2 +- .../mfa/api/MfaChallengeEndPointApiUsageTest.kt | 2 +- .../mfa/api/MfaChallengeEndPointWebUsageTest.kt | 2 +- .../mfa/api/MfaEnrolmentAssociationEndPointTest.kt | 2 +- .../clientapp/api/ClientApplicationEndPointTest.kt | 2 +- .../resetpassword/ResetPasswordEndPointTest.kt | 2 +- .../server/role/adapter/AbstractRoleRepositoryTest.kt | 6 +++--- .../server/role/adapter/CachedRoleRepositoryTest.kt | 6 +++++- .../{ => adapter}/RoleCacheContentConverterTest.kt | 11 +++++++---- .../adapter/dynamodb/DynamoDbRoleRepositoryTest.kt | 4 ++-- .../role/adapter/jdbc/JdbcRoleRepositoryTest.kt | 4 ++-- .../server/role/{ => api}/RoleEndPointTest.kt | 4 +++- .../role/{ => domain}/PermissionValidatorTest.kt | 2 +- .../server/support/AccountTestFixture.kt | 2 +- .../server/{role => support}/RoleFixture.kt | 4 +++- 41 files changed, 83 insertions(+), 67 deletions(-) rename src/main/kotlin/com/vauthenticator/server/role/{RoleRepository.kt => adapter/dynamodb/DynamoDbRoleMapper.kt} (89%) rename src/main/kotlin/com/vauthenticator/server/role/{ => api}/RoleEndPoint.kt (80%) rename src/main/kotlin/com/vauthenticator/server/role/{ => domain}/PermissionValidator.kt (98%) rename src/main/kotlin/com/vauthenticator/server/role/{ => domain}/Role.kt (94%) create mode 100644 src/main/kotlin/com/vauthenticator/server/role/domain/RoleRepository.kt rename src/test/kotlin/com/vauthenticator/server/role/{ => adapter}/RoleCacheContentConverterTest.kt (72%) rename src/test/kotlin/com/vauthenticator/server/role/{ => api}/RoleEndPointTest.kt (93%) rename src/test/kotlin/com/vauthenticator/server/role/{ => domain}/PermissionValidatorTest.kt (98%) rename src/test/kotlin/com/vauthenticator/server/{role => support}/RoleFixture.kt (72%) diff --git a/src/main/kotlin/com/vauthenticator/server/account/api/AccountEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/account/api/AccountEndPoint.kt index 7972d7e2..862d21fd 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/api/AccountEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/api/AccountEndPoint.kt @@ -10,7 +10,7 @@ import com.vauthenticator.server.extentions.oauth2ClientId import com.vauthenticator.server.oauth2.clientapp.domain.ClientAppId import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import jakarta.servlet.http.HttpSession import org.slf4j.Logger import org.slf4j.LoggerFactory diff --git a/src/main/kotlin/com/vauthenticator/server/account/emailverification/EMailVerificationEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/account/emailverification/EMailVerificationEndPoint.kt index 8768342d..855390dc 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/emailverification/EMailVerificationEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/emailverification/EMailVerificationEndPoint.kt @@ -4,7 +4,7 @@ import com.vauthenticator.server.i18n.I18nMessageInjector import com.vauthenticator.server.i18n.I18nScope import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import jakarta.servlet.http.HttpSession import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity.badRequest diff --git a/src/main/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAccountRepository.kt b/src/main/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAccountRepository.kt index eed03454..32962ff1 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAccountRepository.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAccountRepository.kt @@ -7,7 +7,7 @@ import com.vauthenticator.server.account.repository.dynamodb.DynamoAccountConver import com.vauthenticator.server.account.repository.dynamodb.DynamoAccountQueryFactory.findAccountQueryForUserName import com.vauthenticator.server.account.repository.dynamodb.DynamoAccountQueryFactory.storeAccountQueryFor import com.vauthenticator.server.extentions.filterEmptyMetadata -import com.vauthenticator.server.role.RoleRepository +import com.vauthenticator.server.role.domain.RoleRepository import software.amazon.awssdk.services.dynamodb.DynamoDbClient import software.amazon.awssdk.services.dynamodb.model.ConditionalCheckFailedException import java.util.* diff --git a/src/main/kotlin/com/vauthenticator/server/account/signup/SignUpUse.kt b/src/main/kotlin/com/vauthenticator/server/account/signup/SignUpUse.kt index 1bbca64e..9c9fee9e 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/signup/SignUpUse.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/signup/SignUpUse.kt @@ -9,7 +9,7 @@ import com.vauthenticator.server.oauth2.clientapp.domain.ClientAppId import com.vauthenticator.server.password.Password import com.vauthenticator.server.password.PasswordPolicy import com.vauthenticator.server.password.VAuthenticatorPasswordEncoder -import com.vauthenticator.server.role.Role +import com.vauthenticator.server.role.domain.Role import java.time.Instant open class SignUpUse( diff --git a/src/main/kotlin/com/vauthenticator/server/account/welcome/WelcomeMailEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/account/welcome/WelcomeMailEndPoint.kt index be26db7f..68749af6 100644 --- a/src/main/kotlin/com/vauthenticator/server/account/welcome/WelcomeMailEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/account/welcome/WelcomeMailEndPoint.kt @@ -3,7 +3,7 @@ package com.vauthenticator.server.account.welcome import com.vauthenticator.server.account.AccountNotFoundException import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import jakarta.servlet.http.HttpSession import org.springframework.http.ResponseEntity import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken diff --git a/src/main/kotlin/com/vauthenticator/server/config/AccountConfig.kt b/src/main/kotlin/com/vauthenticator/server/config/AccountConfig.kt index ab225e93..413864b0 100644 --- a/src/main/kotlin/com/vauthenticator/server/config/AccountConfig.kt +++ b/src/main/kotlin/com/vauthenticator/server/config/AccountConfig.kt @@ -10,7 +10,7 @@ import com.vauthenticator.server.account.repository.dynamodb.DynamoDbAccountRepo import com.vauthenticator.server.account.repository.jdbc.JdbcAccountRepository import com.vauthenticator.server.cache.CacheOperation import com.vauthenticator.server.cache.RedisCacheOperation -import com.vauthenticator.server.role.RoleRepository +import com.vauthenticator.server.role.domain.RoleRepository import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.context.annotation.Bean diff --git a/src/main/kotlin/com/vauthenticator/server/config/PermissionConfig.kt b/src/main/kotlin/com/vauthenticator/server/config/PermissionConfig.kt index aadfeb60..94f5b419 100644 --- a/src/main/kotlin/com/vauthenticator/server/config/PermissionConfig.kt +++ b/src/main/kotlin/com/vauthenticator/server/config/PermissionConfig.kt @@ -4,8 +4,8 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.vauthenticator.server.cache.CacheOperation import com.vauthenticator.server.cache.RedisCacheOperation import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository -import com.vauthenticator.server.role.PermissionValidator -import com.vauthenticator.server.role.RoleCacheContentConverter +import com.vauthenticator.server.role.domain.PermissionValidator +import com.vauthenticator.server.role.domain.RoleCacheContentConverter import com.vauthenticator.server.role.adapter.CachedRoleRepository import com.vauthenticator.server.role.adapter.dynamodb.DynamoDbRoleRepository import com.vauthenticator.server.role.adapter.jdbc.JdbcRoleRepository diff --git a/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPoint.kt index 17413c59..740c7a95 100644 --- a/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPoint.kt @@ -4,7 +4,7 @@ import com.vauthenticator.server.mfa.domain.MfaChallengeSender import com.vauthenticator.server.mfa.domain.MfaDeviceId import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import jakarta.servlet.http.HttpSession import org.springframework.security.core.Authentication import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken diff --git a/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaMethodsEnrolmentEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaMethodsEnrolmentEndPoint.kt index c384ea3b..994ce78a 100644 --- a/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaMethodsEnrolmentEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/mfa/api/MfaMethodsEnrolmentEndPoint.kt @@ -4,7 +4,7 @@ import com.vauthenticator.server.extentions.clientAppId import com.vauthenticator.server.mfa.domain.* import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity.* diff --git a/src/main/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPoint.kt index a8be7765..ba6726da 100644 --- a/src/main/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPoint.kt @@ -1,7 +1,7 @@ package com.vauthenticator.server.oauth2.clientapp.api import com.vauthenticator.server.oauth2.clientapp.domain.* -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import org.springframework.http.ResponseEntity import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken import org.springframework.web.bind.annotation.* diff --git a/src/main/kotlin/com/vauthenticator/server/password/resetpassword/RestePasswordEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/password/resetpassword/RestePasswordEndPoint.kt index a0f0d9c2..fb46254f 100644 --- a/src/main/kotlin/com/vauthenticator/server/password/resetpassword/RestePasswordEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/password/resetpassword/RestePasswordEndPoint.kt @@ -5,7 +5,7 @@ import com.vauthenticator.server.i18n.I18nMessageInjector import com.vauthenticator.server.i18n.I18nScope import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.ticket.TicketId import jakarta.servlet.http.HttpSession import org.springframework.http.ResponseEntity diff --git a/src/main/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepository.kt b/src/main/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepository.kt index f5099d29..32e2c4a0 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepository.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepository.kt @@ -2,8 +2,8 @@ package com.vauthenticator.server.role.adapter import com.vauthenticator.server.cache.CacheContentConverter import com.vauthenticator.server.cache.CacheOperation -import com.vauthenticator.server.role.Role -import com.vauthenticator.server.role.RoleRepository +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository private const val ROLES_CACHE_KEY = "roles" diff --git a/src/main/kotlin/com/vauthenticator/server/role/RoleRepository.kt b/src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleMapper.kt similarity index 89% rename from src/main/kotlin/com/vauthenticator/server/role/RoleRepository.kt rename to src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleMapper.kt index da75b332..b5dfd23c 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/RoleRepository.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleMapper.kt @@ -1,20 +1,13 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.adapter.dynamodb import com.vauthenticator.server.extentions.asDynamoAttribute import com.vauthenticator.server.extentions.valueAsStringFor +import com.vauthenticator.server.role.domain.Role import software.amazon.awssdk.services.dynamodb.model.AttributeValue import software.amazon.awssdk.services.dynamodb.model.DeleteItemRequest import software.amazon.awssdk.services.dynamodb.model.PutItemRequest import software.amazon.awssdk.services.dynamodb.model.ScanRequest -interface RoleRepository { - - fun findAll(): List - fun save(role: Role) - fun delete(role: String) - -} - object DynamoDbRoleMapper { fun findAllRequestFor(tableName: String): ScanRequest = ScanRequest.builder() diff --git a/src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepository.kt b/src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepository.kt index 85597e60..f5b8673b 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepository.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepository.kt @@ -1,9 +1,8 @@ package com.vauthenticator.server.role.adapter.dynamodb -import com.vauthenticator.server.role.DynamoDbRoleMapper -import com.vauthenticator.server.role.ProtectedRoleFromDeletionException -import com.vauthenticator.server.role.Role -import com.vauthenticator.server.role.RoleRepository +import com.vauthenticator.server.role.domain.ProtectedRoleFromDeletionException +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository import software.amazon.awssdk.services.dynamodb.DynamoDbClient class DynamoDbRoleRepository( diff --git a/src/main/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepository.kt b/src/main/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepository.kt index d1aaf37e..bc564f05 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepository.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepository.kt @@ -1,8 +1,8 @@ package com.vauthenticator.server.role.adapter.jdbc -import com.vauthenticator.server.role.ProtectedRoleFromDeletionException -import com.vauthenticator.server.role.Role -import com.vauthenticator.server.role.RoleRepository +import com.vauthenticator.server.role.domain.ProtectedRoleFromDeletionException +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository import org.springframework.jdbc.core.JdbcTemplate import org.springframework.transaction.annotation.Transactional diff --git a/src/main/kotlin/com/vauthenticator/server/role/RoleEndPoint.kt b/src/main/kotlin/com/vauthenticator/server/role/api/RoleEndPoint.kt similarity index 80% rename from src/main/kotlin/com/vauthenticator/server/role/RoleEndPoint.kt rename to src/main/kotlin/com/vauthenticator/server/role/api/RoleEndPoint.kt index 6faf4bd5..3498b8b2 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/RoleEndPoint.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/api/RoleEndPoint.kt @@ -1,5 +1,8 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.api +import com.vauthenticator.server.role.domain.ProtectedRoleFromDeletionException +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.http.ResponseEntity.noContent diff --git a/src/main/kotlin/com/vauthenticator/server/role/PermissionValidator.kt b/src/main/kotlin/com/vauthenticator/server/role/domain/PermissionValidator.kt similarity index 98% rename from src/main/kotlin/com/vauthenticator/server/role/PermissionValidator.kt rename to src/main/kotlin/com/vauthenticator/server/role/domain/PermissionValidator.kt index 9c474a07..fc3ab5e3 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/PermissionValidator.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/domain/PermissionValidator.kt @@ -1,4 +1,4 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.domain import com.vauthenticator.server.extentions.clientAppId import com.vauthenticator.server.extentions.hasEnoughScopes diff --git a/src/main/kotlin/com/vauthenticator/server/role/Role.kt b/src/main/kotlin/com/vauthenticator/server/role/domain/Role.kt similarity index 94% rename from src/main/kotlin/com/vauthenticator/server/role/Role.kt rename to src/main/kotlin/com/vauthenticator/server/role/domain/Role.kt index a76b18c1..f2c0eed6 100644 --- a/src/main/kotlin/com/vauthenticator/server/role/Role.kt +++ b/src/main/kotlin/com/vauthenticator/server/role/domain/Role.kt @@ -1,4 +1,4 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.domain import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.ObjectMapper diff --git a/src/main/kotlin/com/vauthenticator/server/role/domain/RoleRepository.kt b/src/main/kotlin/com/vauthenticator/server/role/domain/RoleRepository.kt new file mode 100644 index 00000000..cf2feea1 --- /dev/null +++ b/src/main/kotlin/com/vauthenticator/server/role/domain/RoleRepository.kt @@ -0,0 +1,10 @@ +package com.vauthenticator.server.role.domain + +interface RoleRepository { + + fun findAll(): List + fun save(role: Role) + fun delete(role: String) + +} + diff --git a/src/test/kotlin/com/vauthenticator/server/account/api/AccountEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/account/api/AccountEndPointTest.kt index c96986e8..12ba8f73 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/api/AccountEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/api/AccountEndPointTest.kt @@ -9,7 +9,7 @@ import com.vauthenticator.server.oauth2.clientapp.domain.ClientAppId import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.AccountTestFixture.anAccount import com.vauthenticator.server.support.ClientAppFixture diff --git a/src/test/kotlin/com/vauthenticator/server/account/api/AdminApiAccountApiConverterTest.kt b/src/test/kotlin/com/vauthenticator/server/account/api/AdminApiAccountApiConverterTest.kt index 5d6310f8..0575b5a3 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/api/AdminApiAccountApiConverterTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/api/AdminApiAccountApiConverterTest.kt @@ -2,7 +2,7 @@ package com.vauthenticator.server.account.api import com.vauthenticator.server.account.api.AdminApiAccountApiConverter.fromDomainToAccountAdminApiRepresentation import com.vauthenticator.server.config.adminRole -import com.vauthenticator.server.role.Role +import com.vauthenticator.server.role.domain.Role import com.vauthenticator.server.support.AccountTestFixture.anAccount import io.mockk.mockk import org.junit.jupiter.api.Assertions.assertEquals diff --git a/src/test/kotlin/com/vauthenticator/server/account/emailverification/MailVerificationEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/account/emailverification/MailVerificationEndPointTest.kt index 39af40e8..0dac5b3d 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/emailverification/MailVerificationEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/emailverification/MailVerificationEndPointTest.kt @@ -3,7 +3,7 @@ package com.vauthenticator.server.account.emailverification import com.fasterxml.jackson.databind.ObjectMapper import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.EMAIL import com.vauthenticator.server.support.SecurityFixture diff --git a/src/test/kotlin/com/vauthenticator/server/account/repository/AbstractAccountRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/account/repository/AbstractAccountRepositoryTest.kt index 2dabaacf..81e41443 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/repository/AbstractAccountRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/repository/AbstractAccountRepositoryTest.kt @@ -2,10 +2,10 @@ package com.vauthenticator.server.account.repository import com.vauthenticator.server.account.Account import com.vauthenticator.server.account.AccountMandatoryAction.RESET_PASSWORD -import com.vauthenticator.server.role.Role -import com.vauthenticator.server.role.RoleRepository -import com.vauthenticator.server.role.defaultRole -import com.vauthenticator.server.role.protectedRoleName +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository +import com.vauthenticator.server.support.defaultRole +import com.vauthenticator.server.support.protectedRoleName import com.vauthenticator.server.support.AccountTestFixture.anAccount import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertThrows diff --git a/src/test/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAbstractAccountRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAbstractAccountRepositoryTest.kt index 2cfad15a..3d5fba59 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAbstractAccountRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/repository/dynamodb/DynamoDbAbstractAccountRepositoryTest.kt @@ -2,8 +2,8 @@ package com.vauthenticator.server.account.repository.dynamodb import com.vauthenticator.server.account.repository.AbstractAccountRepositoryTest import com.vauthenticator.server.account.repository.AccountRepository -import com.vauthenticator.server.role.RoleRepository -import com.vauthenticator.server.role.protectedRoleNames +import com.vauthenticator.server.role.domain.RoleRepository +import com.vauthenticator.server.support.protectedRoleNames import com.vauthenticator.server.role.adapter.dynamodb.DynamoDbRoleRepository import com.vauthenticator.server.support.DynamoDbUtils.dynamoAccountTableName import com.vauthenticator.server.support.DynamoDbUtils.dynamoDbClient diff --git a/src/test/kotlin/com/vauthenticator/server/account/repository/jdbc/JdbcAccountRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/account/repository/jdbc/JdbcAccountRepositoryTest.kt index 865c51e4..2a6ab6f6 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/repository/jdbc/JdbcAccountRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/repository/jdbc/JdbcAccountRepositoryTest.kt @@ -2,8 +2,8 @@ package com.vauthenticator.server.account.repository.jdbc import com.vauthenticator.server.account.repository.AbstractAccountRepositoryTest import com.vauthenticator.server.account.repository.AccountRepository -import com.vauthenticator.server.role.RoleRepository -import com.vauthenticator.server.role.protectedRoleNames +import com.vauthenticator.server.role.domain.RoleRepository +import com.vauthenticator.server.support.protectedRoleNames import com.vauthenticator.server.role.adapter.jdbc.JdbcRoleRepository import com.vauthenticator.server.support.JdbcUtils.jdbcTemplate import com.vauthenticator.server.support.JdbcUtils.resetDb diff --git a/src/test/kotlin/com/vauthenticator/server/account/signup/SignUpUseTest.kt b/src/test/kotlin/com/vauthenticator/server/account/signup/SignUpUseTest.kt index 7bbe4b6d..4d2b8f98 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/signup/SignUpUseTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/signup/SignUpUseTest.kt @@ -8,7 +8,7 @@ import com.vauthenticator.server.oauth2.clientapp.domain.ClientAppId import com.vauthenticator.server.password.Password import com.vauthenticator.server.password.PasswordPolicy import com.vauthenticator.server.password.VAuthenticatorPasswordEncoder -import com.vauthenticator.server.role.Role +import com.vauthenticator.server.role.domain.Role import com.vauthenticator.server.support.AccountTestFixture.anAccount import io.mockk.every import io.mockk.impl.annotations.MockK diff --git a/src/test/kotlin/com/vauthenticator/server/account/welcome/WelcomeEMailEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/account/welcome/WelcomeEMailEndPointTest.kt index 75ccf450..e6d89109 100644 --- a/src/test/kotlin/com/vauthenticator/server/account/welcome/WelcomeEMailEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/account/welcome/WelcomeEMailEndPointTest.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.vauthenticator.server.account.AccountNotFoundException import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.EMAIL import com.vauthenticator.server.support.SecurityFixture.principalFor diff --git a/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointApiUsageTest.kt b/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointApiUsageTest.kt index 0039cb20..511f2d7b 100644 --- a/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointApiUsageTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointApiUsageTest.kt @@ -4,7 +4,7 @@ import com.vauthenticator.server.mfa.domain.MfaChallengeSender import com.vauthenticator.server.mfa.domain.MfaDeviceId import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.AccountTestFixture.anAccount import com.vauthenticator.server.support.SecurityFixture diff --git a/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointWebUsageTest.kt b/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointWebUsageTest.kt index 8a389373..9a48fdee 100644 --- a/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointWebUsageTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaChallengeEndPointWebUsageTest.kt @@ -5,7 +5,7 @@ import com.vauthenticator.server.mfa.domain.MfaDeviceId import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope import com.vauthenticator.server.oauth2.clientapp.domain.Scopes -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.AccountTestFixture import com.vauthenticator.server.support.ClientAppFixture.aClientApp import com.vauthenticator.server.support.ClientAppFixture.aClientAppId diff --git a/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaEnrolmentAssociationEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaEnrolmentAssociationEndPointTest.kt index bb938bc5..20ce22dc 100644 --- a/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaEnrolmentAssociationEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/mfa/api/MfaEnrolmentAssociationEndPointTest.kt @@ -6,7 +6,7 @@ import com.vauthenticator.server.mfa.domain.MfaMethod.EMAIL_MFA_METHOD import com.vauthenticator.server.oauth2.clientapp.domain.ClientAppId import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.AccountTestFixture import com.vauthenticator.server.support.MfaFixture.mfaDeviceId diff --git a/src/test/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPointTest.kt index 137975e6..7ec29e76 100644 --- a/src/test/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/oauth2/clientapp/api/ClientApplicationEndPointTest.kt @@ -2,7 +2,7 @@ package com.vauthenticator.server.oauth2.clientapp.api import com.fasterxml.jackson.databind.ObjectMapper import com.vauthenticator.server.oauth2.clientapp.domain.* -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.ClientAppFixture.aClientApp import com.vauthenticator.server.support.ClientAppFixture.aClientAppId diff --git a/src/test/kotlin/com/vauthenticator/server/password/resetpassword/ResetPasswordEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/password/resetpassword/ResetPasswordEndPointTest.kt index 20a2238a..a05cc334 100644 --- a/src/test/kotlin/com/vauthenticator/server/password/resetpassword/ResetPasswordEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/password/resetpassword/ResetPasswordEndPointTest.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.vauthenticator.server.oauth2.clientapp.domain.ClientAppId import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.Scope -import com.vauthenticator.server.role.PermissionValidator +import com.vauthenticator.server.role.domain.PermissionValidator import com.vauthenticator.server.support.A_CLIENT_APP_ID import com.vauthenticator.server.support.ClientAppFixture.aClientApp import com.vauthenticator.server.support.EMAIL diff --git a/src/test/kotlin/com/vauthenticator/server/role/adapter/AbstractRoleRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/role/adapter/AbstractRoleRepositoryTest.kt index 9424f759..9241e276 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/adapter/AbstractRoleRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/adapter/AbstractRoleRepositoryTest.kt @@ -1,8 +1,8 @@ package com.vauthenticator.server.role.adapter -import com.vauthenticator.server.role.ProtectedRoleFromDeletionException -import com.vauthenticator.server.role.Role -import com.vauthenticator.server.role.RoleRepository +import com.vauthenticator.server.role.domain.ProtectedRoleFromDeletionException +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepositoryTest.kt index d9e2dece..3994bbb7 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/adapter/CachedRoleRepositoryTest.kt @@ -2,7 +2,11 @@ package com.vauthenticator.server.role.adapter import com.vauthenticator.server.cache.CacheContentConverter import com.vauthenticator.server.cache.CacheOperation -import com.vauthenticator.server.role.* +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository +import com.vauthenticator.server.support.adminRole +import com.vauthenticator.server.support.defaultRole +import com.vauthenticator.server.support.roles import io.mockk.every import io.mockk.impl.annotations.MockK import io.mockk.junit5.MockKExtension diff --git a/src/test/kotlin/com/vauthenticator/server/role/RoleCacheContentConverterTest.kt b/src/test/kotlin/com/vauthenticator/server/role/adapter/RoleCacheContentConverterTest.kt similarity index 72% rename from src/test/kotlin/com/vauthenticator/server/role/RoleCacheContentConverterTest.kt rename to src/test/kotlin/com/vauthenticator/server/role/adapter/RoleCacheContentConverterTest.kt index 1344aba8..82d3961f 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/RoleCacheContentConverterTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/adapter/RoleCacheContentConverterTest.kt @@ -1,8 +1,10 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.adapter import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleCacheContentConverter import com.vauthenticator.server.support.JsonUtils.prettifyInOneLineJsonFrom -import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test private const val testableResource = "roles/rolesSample.json" @@ -10,6 +12,7 @@ private const val testableResource = "roles/rolesSample.json" private val roleList = listOf(Role("ROLE_1", "ROLE_1"), Role("ROLE_2", "ROLE_2")) private val rawValue = prettifyInOneLineJsonFrom(testableResource) + class RoleCacheContentConverterTest { private val underTest = RoleCacheContentConverter(jacksonObjectMapper()) @@ -17,12 +20,12 @@ class RoleCacheContentConverterTest { @Test fun `when a string value from the cache is deserialized`() { val actual = underTest.getObjectFromCacheContentFor(rawValue) - assertEquals(roleList, actual) + Assertions.assertEquals(roleList, actual) } @Test fun `when a role object is serialized as cached value`() { val actual = underTest.loadableContentIntoCacheFor(roleList) - assertEquals(rawValue, actual) + Assertions.assertEquals(rawValue, actual) } } \ No newline at end of file diff --git a/src/test/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepositoryTest.kt index 7888638c..9073393f 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/adapter/dynamodb/DynamoDbRoleRepositoryTest.kt @@ -1,7 +1,7 @@ package com.vauthenticator.server.role.adapter.dynamodb -import com.vauthenticator.server.role.RoleRepository -import com.vauthenticator.server.role.protectedRoleNames +import com.vauthenticator.server.role.domain.RoleRepository +import com.vauthenticator.server.support.protectedRoleNames import com.vauthenticator.server.role.adapter.AbstractRoleRepositoryTest import com.vauthenticator.server.support.DynamoDbUtils.dynamoDbClient import com.vauthenticator.server.support.DynamoDbUtils.dynamoRoleTableName diff --git a/src/test/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepositoryTest.kt b/src/test/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepositoryTest.kt index 9f5a6c1e..4ca7a404 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepositoryTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/adapter/jdbc/JdbcRoleRepositoryTest.kt @@ -1,7 +1,7 @@ package com.vauthenticator.server.role.adapter.jdbc -import com.vauthenticator.server.role.RoleRepository -import com.vauthenticator.server.role.protectedRoleNames +import com.vauthenticator.server.role.domain.RoleRepository +import com.vauthenticator.server.support.protectedRoleNames import com.vauthenticator.server.role.adapter.AbstractRoleRepositoryTest import com.vauthenticator.server.support.JdbcUtils.initRoleTestsInDB import com.vauthenticator.server.support.JdbcUtils.jdbcTemplate diff --git a/src/test/kotlin/com/vauthenticator/server/role/RoleEndPointTest.kt b/src/test/kotlin/com/vauthenticator/server/role/api/RoleEndPointTest.kt similarity index 93% rename from src/test/kotlin/com/vauthenticator/server/role/RoleEndPointTest.kt rename to src/test/kotlin/com/vauthenticator/server/role/api/RoleEndPointTest.kt index 3103719c..0637a17b 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/RoleEndPointTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/api/RoleEndPointTest.kt @@ -1,6 +1,8 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.api import com.fasterxml.jackson.databind.ObjectMapper +import com.vauthenticator.server.role.domain.Role +import com.vauthenticator.server.role.domain.RoleRepository import io.mockk.every import io.mockk.impl.annotations.MockK import io.mockk.junit5.MockKExtension diff --git a/src/test/kotlin/com/vauthenticator/server/role/PermissionValidatorTest.kt b/src/test/kotlin/com/vauthenticator/server/role/domain/PermissionValidatorTest.kt similarity index 98% rename from src/test/kotlin/com/vauthenticator/server/role/PermissionValidatorTest.kt rename to src/test/kotlin/com/vauthenticator/server/role/domain/PermissionValidatorTest.kt index b4aeb2af..1a3aad7c 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/PermissionValidatorTest.kt +++ b/src/test/kotlin/com/vauthenticator/server/role/domain/PermissionValidatorTest.kt @@ -1,4 +1,4 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.role.domain import com.vauthenticator.server.oauth2.clientapp.domain.ClientApplicationRepository import com.vauthenticator.server.oauth2.clientapp.domain.InsufficientClientApplicationScopeException diff --git a/src/test/kotlin/com/vauthenticator/server/support/AccountTestFixture.kt b/src/test/kotlin/com/vauthenticator/server/support/AccountTestFixture.kt index f7ed52c2..636ebd60 100644 --- a/src/test/kotlin/com/vauthenticator/server/support/AccountTestFixture.kt +++ b/src/test/kotlin/com/vauthenticator/server/support/AccountTestFixture.kt @@ -1,7 +1,7 @@ package com.vauthenticator.server.support import com.vauthenticator.server.account.* -import com.vauthenticator.server.role.Role +import com.vauthenticator.server.role.domain.Role const val EMAIL = "email@domain.com" diff --git a/src/test/kotlin/com/vauthenticator/server/role/RoleFixture.kt b/src/test/kotlin/com/vauthenticator/server/support/RoleFixture.kt similarity index 72% rename from src/test/kotlin/com/vauthenticator/server/role/RoleFixture.kt rename to src/test/kotlin/com/vauthenticator/server/support/RoleFixture.kt index 87ff4276..a11f8c8c 100644 --- a/src/test/kotlin/com/vauthenticator/server/role/RoleFixture.kt +++ b/src/test/kotlin/com/vauthenticator/server/support/RoleFixture.kt @@ -1,4 +1,6 @@ -package com.vauthenticator.server.role +package com.vauthenticator.server.support + +import com.vauthenticator.server.role.domain.Role val defaultRole = Role("ROLE_USER", "Default User Role")