From 4d61c7b1c5be70acd855f68ff51123342ac94490 Mon Sep 17 00:00:00 2001 From: YuriyZ Date: Mon, 5 Dec 2022 13:49:37 +0200 Subject: [PATCH] feat(jans-auth-server): avoid compilation problem when version is flipped in test code #3148 (#3210) --- jans-auth-server/client/pom.xml | 11 +- .../jans/as/client/ws/rs/ClientTestUtil.java | 2 +- .../AccessProtectedResourceFlowHttpTest.java | 2 +- ...ntAuthenticationByAccessTokenHttpTest.java | 3 +- .../ws/rs/uma/MetaDataFlowHttpTest.java | 2 +- .../ws/rs/uma/ObtainPatTokenFlowHttpTest.java | 2 +- .../rs/uma/RegisterResourceFlowHttpTest.java | 2 +- .../as/client/ws/rs/uma/ScopeHttpTest.java | 2 +- .../UmaRegisterPermissionFlowHttpTest.java | 2 +- .../rs/uma/UmaSpontaneousScopeHttpTest.java | 6 +- .../io/jans/as/model/uma/UmaTestUtil.java | 108 ------------- jans-auth-server/pom.xml | 4 +- jans-auth-server/server/pom.xml | 5 +- .../as/server/model/uma/TConfiguration.java | 2 +- .../server/model/uma/TRegisterPermission.java | 2 +- .../server/model/uma/TRegisterResource.java | 2 +- .../as/server/model/uma/TTokenRequest.java | 2 +- .../rs/AccessProtectedResourceFlowWSTest.java | 2 +- .../as/server/uma/ws/rs/ObtainPatWSTest.java | 2 +- .../uma/ws/rs/RegisterPermissionWSTest.java | 2 +- .../uma/ws/rs/UmaConfigurationWSTest.java | 2 +- .../uma/ws/rs/UmaRegisterResourceWSTest.java | 2 +- .../as/server/uma/ws/rs/UmaScopeWSTest.java | 2 +- .../java/io/jans/as/server/util/TestUtil.java | 2 +- .../IntrospectionWebServiceEmbeddedTest.java | 2 +- ...egistrationRestWebServiceEmbeddedTest.java | 2 +- jans-auth-server/test-model/pom.xml | 153 ++++++++++++++++++ .../main/java/io/jans/as/test}/TestUtil.java | 2 +- .../java/io/jans/as/test/UmaTestUtil.java | 106 ++++++++++++ .../test-model/src/test/resources/testng.xml | 4 + 30 files changed, 294 insertions(+), 148 deletions(-) delete mode 100644 jans-auth-server/model/src/test/java/io/jans/as/model/uma/UmaTestUtil.java create mode 100644 jans-auth-server/test-model/pom.xml rename jans-auth-server/{model/src/test/java/io/jans/as/model/uma => test-model/src/main/java/io/jans/as/test}/TestUtil.java (97%) create mode 100644 jans-auth-server/test-model/src/main/java/io/jans/as/test/UmaTestUtil.java create mode 100644 jans-auth-server/test-model/src/test/resources/testng.xml diff --git a/jans-auth-server/client/pom.xml b/jans-auth-server/client/pom.xml index 3b951cd07d2..638f7ceaac7 100644 --- a/jans-auth-server/client/pom.xml +++ b/jans-auth-server/client/pom.xml @@ -181,17 +181,16 @@ testng test - - io.jans - jans-auth-model - test-jar - test - org.seleniumhq.selenium htmlunit-driver test + + io.jans + jans-auth-test-model + test + net.sourceforge.htmlunit htmlunit diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/ClientTestUtil.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/ClientTestUtil.java index c337cf79c8e..ad45f965961 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/ClientTestUtil.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/ClientTestUtil.java @@ -8,7 +8,7 @@ import io.jans.as.client.RegisterResponse; -import static io.jans.as.model.uma.TestUtil.assertNotBlank; +import static io.jans.as.test.TestUtil.assertNotBlank; import static org.testng.Assert.assertNotNull; /** diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/AccessProtectedResourceFlowHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/AccessProtectedResourceFlowHttpTest.java index 9642ce3484f..a42069d19ab 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/AccessProtectedResourceFlowHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/AccessProtectedResourceFlowHttpTest.java @@ -28,7 +28,7 @@ import jakarta.ws.rs.core.Response; import java.io.UnsupportedEncodingException; -import static io.jans.as.model.uma.UmaTestUtil.assertIt; +import static io.jans.as.test.UmaTestUtil.assertIt; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ClientAuthenticationByAccessTokenHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ClientAuthenticationByAccessTokenHttpTest.java index ff4f2e04de6..7b67a9f6e62 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ClientAuthenticationByAccessTokenHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ClientAuthenticationByAccessTokenHttpTest.java @@ -43,8 +43,7 @@ import java.util.List; import java.util.UUID; -import static io.jans.as.client.client.Asserter.*; -import static io.jans.as.model.uma.UmaTestUtil.assertIt; +import static io.jans.as.test.UmaTestUtil.assertIt; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/MetaDataFlowHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/MetaDataFlowHttpTest.java index 3652f443093..3959bf5644d 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/MetaDataFlowHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/MetaDataFlowHttpTest.java @@ -10,7 +10,7 @@ import io.jans.as.client.uma.UmaClientFactory; import io.jans.as.client.uma.UmaMetadataService; import io.jans.as.model.uma.UmaMetadata; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import org.testng.annotations.Parameters; import org.testng.annotations.Test; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ObtainPatTokenFlowHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ObtainPatTokenFlowHttpTest.java index 4399eaa65b0..ab895b6ad90 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ObtainPatTokenFlowHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ObtainPatTokenFlowHttpTest.java @@ -11,7 +11,7 @@ import io.jans.as.client.TokenResponse; import io.jans.as.client.client.AssertBuilder; import io.jans.as.client.uma.wrapper.UmaClient; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import org.testng.annotations.Parameters; import org.testng.annotations.Test; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/RegisterResourceFlowHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/RegisterResourceFlowHttpTest.java index 1a2c96b5658..613f33732d7 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/RegisterResourceFlowHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/RegisterResourceFlowHttpTest.java @@ -14,7 +14,7 @@ import io.jans.as.model.uma.UmaResource; import io.jans.as.model.uma.UmaResourceResponse; import io.jans.as.model.uma.UmaResourceWithId; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ScopeHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ScopeHttpTest.java index bca46aefd79..d8dca58f8d8 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ScopeHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/ScopeHttpTest.java @@ -10,7 +10,7 @@ import io.jans.as.client.uma.UmaScopeService; import io.jans.as.model.uma.UmaMetadata; import io.jans.as.model.uma.UmaScopeDescription; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import org.testng.annotations.Parameters; import org.testng.annotations.Test; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaRegisterPermissionFlowHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaRegisterPermissionFlowHttpTest.java index c0b51063923..a96d3823e34 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaRegisterPermissionFlowHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaRegisterPermissionFlowHttpTest.java @@ -13,7 +13,7 @@ import io.jans.as.model.uma.UmaMetadata; import io.jans.as.model.uma.UmaPermission; import io.jans.as.model.uma.UmaPermissionList; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; diff --git a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaSpontaneousScopeHttpTest.java b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaSpontaneousScopeHttpTest.java index d75017aa5b3..8ba4c4e65d7 100644 --- a/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaSpontaneousScopeHttpTest.java +++ b/jans-auth-server/client/src/test/java/io/jans/as/client/ws/rs/uma/UmaSpontaneousScopeHttpTest.java @@ -12,7 +12,6 @@ import io.jans.as.client.RegisterRequest; import io.jans.as.client.RegisterResponse; import io.jans.as.client.client.AssertBuilder; -import io.jans.as.client.client.Asserter; import io.jans.as.client.uma.UmaClientFactory; import io.jans.as.client.uma.UmaRptIntrospectionService; import io.jans.as.client.uma.UmaTokenService; @@ -35,11 +34,8 @@ import java.util.Arrays; import java.util.List; - -import static io.jans.as.model.uma.UmaTestUtil.assertIt; +import static io.jans.as.test.UmaTestUtil.assertIt; import static org.junit.Assert.assertTrue; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; /** * @author Yuriy Zabrovarnyy diff --git a/jans-auth-server/model/src/test/java/io/jans/as/model/uma/UmaTestUtil.java b/jans-auth-server/model/src/test/java/io/jans/as/model/uma/UmaTestUtil.java deleted file mode 100644 index fb0c1173375..00000000000 --- a/jans-auth-server/model/src/test/java/io/jans/as/model/uma/UmaTestUtil.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.as.model.uma; - -import io.jans.as.model.common.GrantType; -import io.jans.as.model.common.Id; -import io.jans.as.model.uma.wrapper.Token; -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.jboss.resteasy.client.jaxrs.internal.ClientResponse; - -import jakarta.ws.rs.core.Response; -import java.util.Arrays; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -/** - * @author Yuriy Zabrovarnyy - */ -public class UmaTestUtil { - - private UmaTestUtil() { - } - - public static void assertIt(UmaScopeDescription scopeDescription) { - assertNotNull(scopeDescription, "Scope description is null"); - assertTrue(StringUtils.isNotBlank(scopeDescription.getName()), "Scope name is empty"); - } - - public static void assertIt(RptIntrospectionResponse rptStatus) { - assertNotNull(rptStatus, "Token response status is null"); - assertTrue(rptStatus.getActive(), "Token is not active"); - assertTrue(rptStatus.getPermissions() != null && !rptStatus.getPermissions().isEmpty(), "Permissions are empty."); - assertNotNull(rptStatus.getExpiresAt(), "Expiration date is null"); - } - - public static void assertIt(UmaMetadata metadata) { - assertNotNull(metadata, "Metadata is null"); - assertTrue(ArrayUtils.contains(metadata.getGrantTypesSupported(), GrantType.OXAUTH_UMA_TICKET.getValue())); - assertNotNull(metadata.getIssuer(), "Issuer isn't correct"); - assertNotNull(metadata.getTokenEndpoint(), "Token endpoint isn't correct"); - assertNotNull(metadata.getIntrospectionEndpoint(), "Introspection endpoint isn't correct"); - assertNotNull(metadata.getResourceRegistrationEndpoint(), "Resource registration endpoint isn't correct"); - assertNotNull(metadata.getPermissionEndpoint(), "Permission registration endpoint isn't correct"); - assertNotNull(metadata.getAuthorizationEndpoint(), "Authorization request endpoint isn't correct"); - } - - public static void assertIt(Token token) { - assertNotNull(token, "The token object is null"); - assertNotNull(token.getAccessToken(), "The access token is null"); - //assertNotNull(p_token.getRefreshToken(), "The refresh token is null"); - } - - public static void assertIt(UmaResourceResponse resourceResponse) { - assertNotNull(resourceResponse, "Resource status is null"); - assertNotNull(resourceResponse.getId(), "Resource description id is null"); - } - - public static UmaResource createResource() { - final UmaResource resource = new UmaResource(); - resource.setName("Server Photo Album"); - resource.setIconUri("http://www.example.com/icons/flower.png"); - resource.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all")); - resource.setType("myType"); - return resource; - } - - public static void assertIt(PermissionTicket ticket) { - assertNotNull(ticket, "Ticket is null"); - assertTrue(StringUtils.isNotBlank(ticket.getTicket()), "Ticket is empty"); - } - - public static void assertIt(RPTResponse response) { - assertNotNull(response, "RPT response is null"); - assertNotNull(response.getRpt(), "RPT is null"); - } - - public static void assertIt(ClientResponse response) { - assertNotNull(response, "Response is null"); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatus(), "Response http code is not OK."); - } - - public static void assertIt(Id id) { - assertNotNull(id, "ID is null"); - assertTrue(StringUtils.isNotBlank(id.getId()), "ID is blank"); - } - - public static void assertIt(UmaTokenResponse response) { - assertNotNull(response, "UMA Token response is null"); - assertNotNull(response.getAccessToken(), "RPT is null"); - assertNotNull(response.getPct(), "PCT is null"); - } - - public static void assertIt(UmaNeedInfoResponse response) { - assertNotNull(response, "UMA Need Info response is null"); - assertTrue(StringUtils.isNotBlank(response.getError()), "need_info error is blank"); - assertTrue(StringUtils.isNotBlank(response.getTicket()), "need_info ticket is blank"); - assertTrue(response.getRequiredClaims() != null && !response.getRequiredClaims().isEmpty(), "need_info required claims are empty"); - assertTrue(StringUtils.isNotBlank(response.getRedirectUser()), "need_info redirect user uri is blank"); - } - -} diff --git a/jans-auth-server/pom.xml b/jans-auth-server/pom.xml index f6c22e03a37..4c49bdf1d44 100644 --- a/jans-auth-server/pom.xml +++ b/jans-auth-server/pom.xml @@ -105,6 +105,7 @@ static common server + test-model @@ -151,9 +152,8 @@ io.jans - jans-auth-model + jans-auth-test-model ${project.version} - test-jar io.jans diff --git a/jans-auth-server/server/pom.xml b/jans-auth-server/server/pom.xml index bb699042eb0..fa2b3ba9900 100644 --- a/jans-auth-server/server/pom.xml +++ b/jans-auth-server/server/pom.xml @@ -590,12 +590,9 @@ io.jans - jans-auth-model - ${project.version} - test-jar + jans-auth-test-model test - org.testng testng diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TConfiguration.java b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TConfiguration.java index 143aea8c81d..db16bb12b8d 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TConfiguration.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TConfiguration.java @@ -8,7 +8,7 @@ import io.jans.as.model.uma.UmaConstants; import io.jans.as.model.uma.UmaMetadata; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.server.BaseTest; import io.jans.as.server.util.ServerUtil; import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterPermission.java b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterPermission.java index 99e9e9eed79..435bfc440d2 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterPermission.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterPermission.java @@ -10,7 +10,7 @@ import io.jans.as.model.uma.PermissionTicket; import io.jans.as.model.uma.UmaConstants; import io.jans.as.model.uma.UmaPermission; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.util.ServerUtil; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterResource.java b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterResource.java index 9d4f756891b..6d863e36f01 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterResource.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TRegisterResource.java @@ -9,7 +9,7 @@ import io.jans.as.model.uma.UmaConstants; import io.jans.as.model.uma.UmaResource; import io.jans.as.model.uma.UmaResourceResponse; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.util.ServerUtil; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TTokenRequest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TTokenRequest.java index 6dc80031890..e6ea7300732 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TTokenRequest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/model/uma/TTokenRequest.java @@ -17,7 +17,7 @@ import io.jans.as.model.uma.RptIntrospectionResponse; import io.jans.as.model.uma.UmaConstants; import io.jans.as.model.uma.UmaScopeType; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.model.util.QueryStringDecoder; import io.jans.as.server.BaseTest; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/AccessProtectedResourceFlowWSTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/AccessProtectedResourceFlowWSTest.java index 760959ed9d8..2ce843f531a 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/AccessProtectedResourceFlowWSTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/AccessProtectedResourceFlowWSTest.java @@ -11,7 +11,7 @@ import io.jans.as.model.uma.RptIntrospectionResponse; import io.jans.as.model.uma.UmaPermission; import io.jans.as.model.uma.UmaResourceResponse; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/ObtainPatWSTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/ObtainPatWSTest.java index d14aa0f2312..d711e7d68f3 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/ObtainPatWSTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/ObtainPatWSTest.java @@ -6,7 +6,7 @@ package io.jans.as.server.uma.ws.rs; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/RegisterPermissionWSTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/RegisterPermissionWSTest.java index acfb12a7ce1..d8a4758ee97 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/RegisterPermissionWSTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/RegisterPermissionWSTest.java @@ -10,7 +10,7 @@ import io.jans.as.model.uma.UmaConstants; import io.jans.as.model.uma.UmaPermission; import io.jans.as.model.uma.UmaResourceResponse; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaConfigurationWSTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaConfigurationWSTest.java index 22b727ef4df..458e55e2d27 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaConfigurationWSTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaConfigurationWSTest.java @@ -7,7 +7,7 @@ package io.jans.as.server.uma.ws.rs; import io.jans.as.model.uma.UmaMetadata; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; import org.jboss.arquillian.test.api.ArquillianResource; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaRegisterResourceWSTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaRegisterResourceWSTest.java index 1c1d9913828..e74f6f6b94f 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaRegisterResourceWSTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaRegisterResourceWSTest.java @@ -8,7 +8,7 @@ import io.jans.as.model.uma.UmaResource; import io.jans.as.model.uma.UmaResourceResponse; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaScopeWSTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaScopeWSTest.java index 8dd0e27bf17..c242f16b400 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaScopeWSTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/uma/ws/rs/UmaScopeWSTest.java @@ -8,7 +8,7 @@ import io.jans.as.model.uma.UmaConstants; import io.jans.as.model.uma.UmaScopeDescription; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; import org.jboss.arquillian.test.api.ArquillianResource; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/util/TestUtil.java b/jans-auth-server/server/src/test/java/io/jans/as/server/util/TestUtil.java index 42216511bf9..17d8a6387bb 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/util/TestUtil.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/util/TestUtil.java @@ -5,7 +5,7 @@ import jakarta.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; -import static io.jans.as.model.uma.TestUtil.assertNotBlank; +import static io.jans.as.test.TestUtil.assertNotBlank; import static org.testng.Assert.*; /** diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/IntrospectionWebServiceEmbeddedTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/IntrospectionWebServiceEmbeddedTest.java index f8aa5f0ff23..5b1611d6430 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/IntrospectionWebServiceEmbeddedTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/IntrospectionWebServiceEmbeddedTest.java @@ -7,7 +7,7 @@ package io.jans.as.server.ws.rs; import io.jans.as.model.common.IntrospectionResponse; -import io.jans.as.model.uma.UmaTestUtil; +import io.jans.as.test.UmaTestUtil; import io.jans.as.model.uma.wrapper.Token; import io.jans.as.server.BaseTest; import io.jans.as.server.model.uma.TUma; diff --git a/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/RegistrationRestWebServiceEmbeddedTest.java b/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/RegistrationRestWebServiceEmbeddedTest.java index 63d97478285..ddad09dc0db 100644 --- a/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/RegistrationRestWebServiceEmbeddedTest.java +++ b/jans-auth-server/server/src/test/java/io/jans/as/server/ws/rs/RegistrationRestWebServiceEmbeddedTest.java @@ -15,7 +15,7 @@ import io.jans.as.model.crypto.signature.SignatureAlgorithm; import io.jans.as.model.register.ApplicationType; import io.jans.as.model.register.RegisterResponseParam; -import io.jans.as.model.uma.TestUtil; +import io.jans.as.test.TestUtil; import io.jans.as.model.util.StringUtils; import io.jans.as.server.BaseTest; import io.jans.as.server.util.ServerUtil; diff --git a/jans-auth-server/test-model/pom.xml b/jans-auth-server/test-model/pom.xml new file mode 100644 index 00000000000..52663dc505f --- /dev/null +++ b/jans-auth-server/test-model/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + jans-auth-test-model + jans-auth-test-model + jar + + + io.jans + jans-auth-server-parent + 1.0.6-test-release-SNAPSHOT + + + + ${maven.min-version} + + + + jans-auth-test-model + + + + src/main/resources + + **/*.xml + **/*.properties + **/*.js + + + + + + + src/test/resources + + **/*.json + **/*.xml + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + + + + + + + + io.jans + jans-auth-model + ${project.version} + + + com.google.guava + guava + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-client + + + org.json + json + + + com.fasterxml.jackson.datatype + jackson-datatype-json-org + + + com.fasterxml.jackson.module + jackson-module-jakarta-xmlbind-annotations + + + commons-codec + commons-codec + + + commons-lang + commons-lang + + + commons-io + commons-io + + + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-1.2-api + + + + org.testng + testng + compile + + + org.mockito + mockito-core + + + org.mockito + mockito-testng + + + org.mockito + mockito-inline + + + + org.bouncycastle + bcprov-jdk15on + provided + + + org.bouncycastle + bcpkix-jdk15on + provided + + + + com.nimbusds + nimbus-jose-jwt + + + org.bitbucket.b_c + jose4j + + + + jakarta.validation + jakarta.validation-api + + + org.jetbrains + annotations + + + \ No newline at end of file diff --git a/jans-auth-server/model/src/test/java/io/jans/as/model/uma/TestUtil.java b/jans-auth-server/test-model/src/main/java/io/jans/as/test/TestUtil.java similarity index 97% rename from jans-auth-server/model/src/test/java/io/jans/as/model/uma/TestUtil.java rename to jans-auth-server/test-model/src/main/java/io/jans/as/test/TestUtil.java index aa27eee724b..c4eafed6b68 100644 --- a/jans-auth-server/model/src/test/java/io/jans/as/model/uma/TestUtil.java +++ b/jans-auth-server/test-model/src/main/java/io/jans/as/test/TestUtil.java @@ -4,7 +4,7 @@ * Copyright (c) 2020, Janssen Project */ -package io.jans.as.model.uma; +package io.jans.as.test; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; diff --git a/jans-auth-server/test-model/src/main/java/io/jans/as/test/UmaTestUtil.java b/jans-auth-server/test-model/src/main/java/io/jans/as/test/UmaTestUtil.java new file mode 100644 index 00000000000..ab643519293 --- /dev/null +++ b/jans-auth-server/test-model/src/main/java/io/jans/as/test/UmaTestUtil.java @@ -0,0 +1,106 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.as.test; + +import io.jans.as.model.common.GrantType; +import io.jans.as.model.common.Id; +import io.jans.as.model.uma.*; +import io.jans.as.model.uma.wrapper.Token; +import jakarta.ws.rs.core.Response; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; +import org.jboss.resteasy.client.jaxrs.internal.ClientResponse; +import org.testng.Assert; + +import java.util.Arrays; + +/** + * @author Yuriy Zabrovarnyy + */ +public class UmaTestUtil { + + private UmaTestUtil() { + } + + public static void assertIt(UmaScopeDescription scopeDescription) { + Assert.assertNotNull(scopeDescription, "Scope description is null"); + Assert.assertTrue(StringUtils.isNotBlank(scopeDescription.getName()), "Scope name is empty"); + } + + public static void assertIt(RptIntrospectionResponse rptStatus) { + Assert.assertNotNull(rptStatus, "Token response status is null"); + Assert.assertTrue(rptStatus.getActive(), "Token is not active"); + Assert.assertTrue(rptStatus.getPermissions() != null && !rptStatus.getPermissions().isEmpty(), "Permissions are empty."); + Assert.assertNotNull(rptStatus.getExpiresAt(), "Expiration date is null"); + } + + public static void assertIt(UmaMetadata metadata) { + Assert.assertNotNull(metadata, "Metadata is null"); + Assert.assertTrue(ArrayUtils.contains(metadata.getGrantTypesSupported(), GrantType.OXAUTH_UMA_TICKET.getValue())); + Assert.assertNotNull(metadata.getIssuer(), "Issuer isn't correct"); + Assert.assertNotNull(metadata.getTokenEndpoint(), "Token endpoint isn't correct"); + Assert.assertNotNull(metadata.getIntrospectionEndpoint(), "Introspection endpoint isn't correct"); + Assert.assertNotNull(metadata.getResourceRegistrationEndpoint(), "Resource registration endpoint isn't correct"); + Assert.assertNotNull(metadata.getPermissionEndpoint(), "Permission registration endpoint isn't correct"); + Assert.assertNotNull(metadata.getAuthorizationEndpoint(), "Authorization request endpoint isn't correct"); + } + + public static void assertIt(Token token) { + Assert.assertNotNull(token, "The token object is null"); + Assert.assertNotNull(token.getAccessToken(), "The access token is null"); + //assertNotNull(p_token.getRefreshToken(), "The refresh token is null"); + } + + public static void assertIt(UmaResourceResponse resourceResponse) { + Assert.assertNotNull(resourceResponse, "Resource status is null"); + Assert.assertNotNull(resourceResponse.getId(), "Resource description id is null"); + } + + public static UmaResource createResource() { + final UmaResource resource = new UmaResource(); + resource.setName("Server Photo Album"); + resource.setIconUri("http://www.example.com/icons/flower.png"); + resource.setScopes(Arrays.asList("http://photoz.example.com/dev/scopes/view", "http://photoz.example.com/dev/scopes/all")); + resource.setType("myType"); + return resource; + } + + public static void assertIt(PermissionTicket ticket) { + Assert.assertNotNull(ticket, "Ticket is null"); + Assert.assertTrue(StringUtils.isNotBlank(ticket.getTicket()), "Ticket is empty"); + } + + public static void assertIt(RPTResponse response) { + Assert.assertNotNull(response, "RPT response is null"); + Assert.assertNotNull(response.getRpt(), "RPT is null"); + } + + public static void assertIt(ClientResponse response) { + Assert.assertNotNull(response, "Response is null"); + Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus(), "Response http code is not OK."); + } + + public static void assertIt(Id id) { + Assert.assertNotNull(id, "ID is null"); + Assert.assertTrue(StringUtils.isNotBlank(id.getId()), "ID is blank"); + } + + public static void assertIt(UmaTokenResponse response) { + Assert.assertNotNull(response, "UMA Token response is null"); + Assert.assertNotNull(response.getAccessToken(), "RPT is null"); + Assert.assertNotNull(response.getPct(), "PCT is null"); + } + + public static void assertIt(UmaNeedInfoResponse response) { + Assert.assertNotNull(response, "UMA Need Info response is null"); + Assert.assertTrue(StringUtils.isNotBlank(response.getError()), "need_info error is blank"); + Assert.assertTrue(StringUtils.isNotBlank(response.getTicket()), "need_info ticket is blank"); + Assert.assertTrue(response.getRequiredClaims() != null && !response.getRequiredClaims().isEmpty(), "need_info required claims are empty"); + Assert.assertTrue(StringUtils.isNotBlank(response.getRedirectUser()), "need_info redirect user uri is blank"); + } + +} diff --git a/jans-auth-server/test-model/src/test/resources/testng.xml b/jans-auth-server/test-model/src/test/resources/testng.xml new file mode 100644 index 00000000000..ae5d2cd5147 --- /dev/null +++ b/jans-auth-server/test-model/src/test/resources/testng.xml @@ -0,0 +1,4 @@ + + + +