diff --git a/jans-config-api/.gitignore b/jans-config-api/.gitignore index c53194b720c..51ac95769dc 100644 --- a/jans-config-api/.gitignore +++ b/jans-config-api/.gitignore @@ -34,3 +34,4 @@ pom.xml.tag pom.xml.releaseBackup pom.xml.versionsBackup release.properties +test-output/ diff --git a/jans-config-api/common/pom.xml b/jans-config-api/common/pom.xml index a33c08a4ec7..f8a30e49d70 100644 --- a/jans-config-api/common/pom.xml +++ b/jans-config-api/common/pom.xml @@ -39,12 +39,6 @@ maven-surefire-plugin - - true - - --tags ~@ignore - - diff --git a/jans-config-api/plugins/admin-ui-plugin/pom.xml b/jans-config-api/plugins/admin-ui-plugin/pom.xml index c47467970a1..dd12c01d1df 100644 --- a/jans-config-api/plugins/admin-ui-plugin/pom.xml +++ b/jans-config-api/plugins/admin-ui-plugin/pom.xml @@ -31,42 +31,18 @@ commons-collections 3.2.2 + io.rest-assured rest-assured test - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test - - - junit - junit - - + + org.testng + testng + test + jakarta.xml.bind jakarta.xml.bind-api @@ -90,15 +66,19 @@ admin-ui-plugin + + + ../../profiles/${cfg}/config-build.properties + ../../profiles/${cfg}/config-api-test.properties + + src/test/resources true - - *.* - + org.apache.maven.plugins @@ -119,14 +99,11 @@ maven-surefire-plugin - - - - integration - - --tags ~@ignore - - + + + target/test-classes/testng.xml + + integration-tests diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/AdminUIBaseTest.java b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/AdminUIBaseTest.java new file mode 100644 index 00000000000..1186f9f05e1 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/AdminUIBaseTest.java @@ -0,0 +1,35 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.ca.plugin.adminui; + +import io.jans.as.model.common.GrantType; +import io.jans.configapi.core.test.BaseTest; + +import org.testng.annotations.BeforeMethod; + +public class AdminUIBaseTest extends BaseTest{ + + //AdminUI specific code + + @BeforeMethod + @Override + public void getAccessToken() throws Exception { + log.info("AdminUI - getAccessToken - propertiesMap:{}", propertiesMap); + + String tokenUrl = propertiesMap.get("test.authzurl"); + String strGrantType = propertiesMap.get("test.grant.type"); + String clientId = propertiesMap.get("test.client.id"); + String clientSecret = propertiesMap.get("test.client.secret"); + String scopes = propertiesMap.get("test.scopes"); + + GrantType grantType = GrantType.fromString(strGrantType); + this.accessToken = getToken(tokenUrl, clientId, clientSecret, grantType, scopes); + log.info("\n\n\n\n AdminUI- accessToken:{}", accessToken); + } + + +} diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/KarateTestRunner.java b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/KarateTestRunner.java deleted file mode 100644 index a9d07255f2f..00000000000 --- a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/KarateTestRunner.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.ca.plugin.adminui; - -import com.intuit.karate.junit5.Karate; -import org.junit.jupiter.api.Test; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/TestAdminUIPluginJenkinsRunner.java b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/TestAdminUIPluginJenkinsRunner.java deleted file mode 100644 index 466e942a336..00000000000 --- a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/TestAdminUIPluginJenkinsRunner.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.ca.plugin.adminui; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Yuriy Zabrovarnyy - */ -public class TestAdminUIPluginJenkinsRunner { - - @Test - void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/AuditLoggingResourceTest.java b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/AuditLoggingResourceTest.java new file mode 100644 index 00000000000..e0fe81dff0a --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/AuditLoggingResourceTest.java @@ -0,0 +1,44 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.ca.plugin.adminui.test; + + +import io.jans.ca.plugin.adminui.AdminUIBaseTest; + +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; + +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class AuditLoggingResourceTest extends AdminUIBaseTest{ + + + /** + * Testing Audit Logging endpoint + */ + @Parameters({"test.issuer", "auditLoggingURL", "audit_post_1"}) + @Test + public void postAuditLoggingData(final String issuer, final String auditLoggingURL, final String json) { + log.info("postAuditLoggingData() - accessToken:{}, issuer:{}, auditLoggingURL:{}, json:{}", accessToken, issuer, auditLoggingURL, json); + Builder request = getResteasyService().getClientBuilder(issuer+auditLoggingURL); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.post(Entity.entity(json, MediaType.APPLICATION_JSON)); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("\n\n Response for postAuditLoggingData - response:{}", response); + } + + + +} diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/LicenseResourceTest.java b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/LicenseResourceTest.java new file mode 100644 index 00000000000..8176121bc52 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/LicenseResourceTest.java @@ -0,0 +1,41 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.ca.plugin.adminui.test; + + +import io.jans.ca.plugin.adminui.AdminUIBaseTest; + +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; + +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class LicenseResourceTest extends AdminUIBaseTest { + + /** + * Test License Details + */ + @Parameters({ "test.issuer", "checkActiveLicenseURL" }) + @Test + public void getLicenseDetails(final String issuer, final String checkActiveLicenseURL) { + log.info("getLicenseDetails() - accessToken:{}, issuer:{}, checkActiveLicenseURL:{}", accessToken, issuer, + checkActiveLicenseURL); + Builder request = getResteasyService().getClientBuilder(issuer + checkActiveLicenseURL); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("\n\n Response for getLicenseDetails - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/OAuth2ResourceTest.java b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/OAuth2ResourceTest.java new file mode 100644 index 00000000000..eb6ae3f7fb3 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/java/io/jans/ca/plugin/adminui/test/OAuth2ResourceTest.java @@ -0,0 +1,55 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.ca.plugin.adminui.test; + + + +import io.jans.ca.plugin.adminui.AdminUIBaseTest; + +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.MediaType; + +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class OAuth2ResourceTest extends AdminUIBaseTest{ + + + /** + * Testing oauth2 GET configuration endpoint + */ + @Parameters({"test.issuer", "adminUIConfigURL"}) + @Test + public void getOAuth2Data(final String issuer, final String adminUIConfigURL) { + log.info("getOAuth2Data() - accessToken:{}, issuer:{}, adminUIConfigURL:{}", accessToken, issuer, adminUIConfigURL); + Builder request = getResteasyService().getClientBuilder(issuer+adminUIConfigURL); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + log.info("Response for getOAuth2Data() - response:{}", response); + } + + + /** + * Testing api-protection-token GET endpoint + */ + @Parameters({"test.issuer", "apiProtectionTokenURL", "ujwt"}) + @Test + public void getApiProtectionTokenData(final String issuer, final String apiProtectionTokenURL, final String ujwt) { + log.info("\n\n getApiProtectionTokenData() - accessToken:{}, issuer:{}, apiProtectionTokenURL:{}, ujwt:{}", accessToken, issuer, apiProtectionTokenURL, ujwt); + Builder request = getResteasyService().getClientBuilder(issuer+apiProtectionTokenURL); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); + request.property("ujwt", ujwt); + Response response = request.get(); + log.info("\n\n Response for getApiProtectionTokenData() - response:{}", response); + } + + +} diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/auditLogging.feature b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/auditLogging.feature new file mode 100644 index 00000000000..788f8d35ac3 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/auditLogging.feature @@ -0,0 +1,15 @@ +# new feature +# Tags: optional + +Feature: Test License endpoints of admin-ui + + Scenario Outline: Testing 'auditLogging' POST endpoint + Given url + And header = + And request + When method + Then status + And print + Examples: + | expression | name | values | body | method | status | exps | + | getAuditLoggingURL | Accept | 'application/json' | {\"message\": {\"childMsg\": \"Testing audit logging.\"}} | POST | 200 | response | \ No newline at end of file diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/license.feature b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/license.feature new file mode 100644 index 00000000000..8dc9e510f17 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/license.feature @@ -0,0 +1,10 @@ +# new feature +# Tags: optional + +Feature: Test Audit logging endpoints of admin-ui + + Scenario: Testing 'checkLicense' GET endpoint + Given url checkLicenseURL + When method GET + Then status 200 + And print response diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/oauth2.feature b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/oauth2.feature new file mode 100644 index 00000000000..ee60ee8de24 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/auth/oauth2.feature @@ -0,0 +1,26 @@ +Feature: Oauth2 + + Background: + * def ujwt = 'eyJraWQiOiI2NmQ1ODk4Ny03NjQ0LTRkYjEtOWU2YS04ZmFiNWFjYWVhNjVfc2lnX3JzMjU2IiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJndFZ2cDJCMGlwdFN5bXFSTEpzc2ZZOWZNbjliWVZRNF8xVTBHSFlFWFRJIiwiYXVkIjoiMjA3M2M4ZTctMTA2MC00YzA5LWIwZjYtN2Q0NmZiNmZmOGY1IiwibmFtZSI6IkRlZmF1bHQgQWRtaW4gVXNlciIsIm5pY2tuYW1lIjoiQWRtaW4iLCJpc3MiOiJodHRwczovL2FkbWluLXVpLXRlc3QuZ2x1dS5vcmciLCJnaXZlbl9uYW1lIjoiQWRtaW4iLCJtaWRkbGVfbmFtZSI6IkFkbWluIiwiZmFtaWx5X25hbWUiOiJVc2VyIiwiamFuc0FkbWluVUlSb2xlIjpbImFwaS1hZG1pbiJdfQ.losuUsBib2YvB2t995iT0HJvE-q7uZT8zHrTJsWN8_rxB_-kawFNI6weWiH4hpAaIAIaw6Bnq5AczSW3OS6sn5fZDrBxuftrurCa7PK7uAeYim8Zozg0NHNQQ9FDe6MYg8FLtKI3eiusvgC3P4CClIFf1AMGVxREyBra87r_J8j2IyV86Ktjv_rVZLNm2mChOrbM5sIjaski4saKtZTMiVZoK7WMC4FJmS8ttysfG2w7-t8MoI9kiM890RhxSoUba9nQIVxKmpdJOzam8_FqNfQmC9fzI2XKjgRu16SoAoJxCNeTy8HHBCN4H_BwxgU2seSbDTMgU11GiApd4D2xaw' + + Scenario: Testing oauth2 GET configuration endpoint + Given url adminUIConfigURL + And header Accept = 'application/json' + When method GET + Then status 200 + And print response + + Scenario: Testing api-protection-token GET endpoint + Given url apiProtectionTokenURL + And header Accept = 'application/json' + Given param ujwt = ujwt + When method GET + Then status 200 + And print response + + +#Scenario: Testing access-token GET endpoint + #Given url https://admin-ui-test.gluu.org/jans-config-api/admin-ui/oauth2/access-token + #When method GET + #Then status 200 + #And print response \ No newline at end of file diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/logging/logging-post.json b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/logging/logging-post.json new file mode 100644 index 00000000000..9558aee3a09 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/json/logging/logging-post.json @@ -0,0 +1,5 @@ +{ + "message":{ + "childMsg":"Testing audit logging." + } +} \ No newline at end of file diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/test.properties b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/test.properties index a327ce4a05b..da3b670db39 100644 --- a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/test.properties @@ -1,6 +1,31 @@ +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete + +# Test env Setting +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + + test.scopes=openid profile email user_name test.grant.type=authorization_code -test.client.id=2073c8e7-1060-4c09-b0f6-7d46fb6ff8f5 -test.client.secret=92bc4d8e-2f4c-4a4d-80ae-1e4eb1f5f463 -test.issuer=https://admin-ui-test.gluu.org -test.authzurl=https://admin-ui-test.gluu.org/jans-auth/authorize.htm +test.client.id=2001.3f672ceb-ff41-4cc6-8b68-57182314a2fd +test.client.secret=SK31nbIxwSAl +test.issuer=https://pujavs-witty-weasel.gluu.info +test.authzurl=https://pujavs-witty-weasel.gluu.info/jans-auth/authorize.htm + +ujwt=eyJraWQiOiI2NmQ1ODk4Ny03NjQ0LTRkYjEtOWU2YS04ZmFiNWFjYWVhNjVfc2lnX3JzMjU2IiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJndFZ2cDJCMGlwdFN5bXFSTEpzc2ZZOWZNbjliWVZRNF8xVTBHSFlFWFRJIiwiYXVkIjoiMjA3M2M4ZTctMTA2MC00YzA5LWIwZjYtN2Q0NmZiNmZmOGY1IiwibmFtZSI6IkRlZmF1bHQgQWRtaW4gVXNlciIsIm5pY2tuYW1lIjoiQWRtaW4iLCJpc3MiOiJodHRwczovL2FkbWluLXVpLXRlc3QuZ2x1dS5vcmciLCJnaXZlbl9uYW1lIjoiQWRtaW4iLCJtaWRkbGVfbmFtZSI6IkFkbWluIiwiZmFtaWx5X25hbWUiOiJVc2VyIiwiamFuc0FkbWluVUlSb2xlIjpbImFwaS1hZG1pbiJdfQ.losuUsBib2YvB2t995iT0HJvE-q7uZT8zHrTJsWN8_rxB_-kawFNI6weWiH4hpAaIAIaw6Bnq5AczSW3OS6sn5fZDrBxuftrurCa7PK7uAeYim8Zozg0NHNQQ9FDe6MYg8FLtKI3eiusvgC3P4CClIFf1AMGVxREyBra87r_J8j2IyV86Ktjv_rVZLNm2mChOrbM5sIjaski4saKtZTMiVZoK7WMC4FJmS8ttysfG2w7-t8MoI9kiM890RhxSoUba9nQIVxKmpdJOzam8_FqNfQmC9fzI2XKjgRu16SoAoJxCNeTy8HHBCN4H_BwxgU2seSbDTMgU11GiApd4D2xaw +authzurl=/jans-auth/authorize.htm +adminUIConfigURL=/jans-config-api/admin-ui/oauth2/config +apiProtectionTokenURL=/jans-config-api/admin-ui/oauth2/api-protection-token +checkActiveLicenseURL=/jans-config-api/admin-ui/license/isActive +licenseDetailsURL=/jans-config-api/admin-ui/license/getLicenseDetails +auditLoggingURL=/jans-config-api/admin-ui/logging/audit + + + +#logging +audit_post_1=file:target/test-classes/json/logging/logging-post.json + diff --git a/jans-config-api/plugins/admin-ui-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..a3a46e5b796 --- /dev/null +++ b/jans-config-api/plugins/admin-ui-plugin/src/test/resources/testng.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/fido2-plugin/pom.xml b/jans-config-api/plugins/fido2-plugin/pom.xml index 08eeea05b3d..e8135018fb2 100644 --- a/jans-config-api/plugins/fido2-plugin/pom.xml +++ b/jans-config-api/plugins/fido2-plugin/pom.xml @@ -90,29 +90,9 @@ test - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -130,18 +110,12 @@ ../../profiles/${cfg}/config-api-test.properties - - - src/test/resources - true - - karate.properties - karate_jenkins.properties - test.properties - *.* - - - + + + src/test/resources + true + + @@ -179,12 +153,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java b/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java deleted file mode 100644 index a7f7d2d80c2..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class TestJenkinsRunner { - - @Test - void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/test/Fido2ResourceTest.java b/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/test/Fido2ResourceTest.java new file mode 100644 index 00000000000..8fc67c8698d --- /dev/null +++ b/jans-config-api/plugins/fido2-plugin/src/test/java/io/jans/configapi/test/Fido2ResourceTest.java @@ -0,0 +1,38 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Parameters; + +public class Fido2ResourceTest extends BaseTest { + + @Parameters({"issuer", "fido2Url"}) + @Test + public void getFido2Configuration(final String issuer, final String fido2Url) { + log.error("getFido2Configuration() - accessToken:{}, issuer:{}, fido2Url:{}", accessToken, issuer, fido2Url); + Builder request = getResteasyService().getClientBuilder(issuer + fido2Url); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.error("getFido2Configuration() - Response for getDefaultAuthenticationMethod - response:{}", response); + } + + + +} diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/dynamiconf.json b/jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/dynamiconf.json similarity index 100% rename from jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/dynamiconf.json rename to jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/dynamiconf.json diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/fido2.feature b/jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/fido2.feature similarity index 100% rename from jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/fido2.feature rename to jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/fido2.feature diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/fido2.json b/jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/fido2.json similarity index 100% rename from jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/fido2.json rename to jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/fido2.json diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/ref_dynami_conf.json b/jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/ref_dynami_conf.json similarity index 100% rename from jans-config-api/plugins/fido2-plugin/src/test/resources/feature/fido2/ref_dynami_conf.json rename to jans-config-api/plugins/fido2-plugin/src/test/resources/json/fido2/ref_dynami_conf.json diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/fido2-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index 35a4a9bb3c1..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - fido2Url: baseUrl + '/jans-config-api/fido2/fido2-config', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/fido2-plugin/src/test/resources/karate-config.js deleted file mode 100644 index 0a39c646bec..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,57 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - fido2Url: baseUrl + '/jans-config-api/fido2/fido2-config', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/fido2-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/fido2-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/test.properties b/jans-config-api/plugins/fido2-plugin/src/test/resources/test.properties index 4257f297907..31d2620b4b6 100644 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/fido2-plugin/src/test/resources/test.properties @@ -1,8 +1,11 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +fido2Url=/jans-config-api/fido2/fido2-config \ No newline at end of file diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/fido2-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/fido2-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..6c1f8fdeef9 --- /dev/null +++ b/jans-config-api/plugins/fido2-plugin/src/test/resources/testng.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/fido2-plugin/src/test/resources/token.feature b/jans-config-api/plugins/fido2-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/fido2-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/plugins/jans-link-plugin/pom.xml b/jans-config-api/plugins/jans-link-plugin/pom.xml index 1b65f2ded34..a8dc6b68f36 100644 --- a/jans-config-api/plugins/jans-link-plugin/pom.xml +++ b/jans-config-api/plugins/jans-link-plugin/pom.xml @@ -84,35 +84,15 @@ + + io.rest-assured + rest-assured + test + - io.rest-assured - rest-assured - test - - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -134,12 +114,6 @@ src/test/resources true - - karate.properties - karate_jenkins.properties - test.properties - *.* - @@ -179,12 +153,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java b/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java deleted file mode 100644 index a7f7d2d80c2..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class TestJenkinsRunner { - - @Test - void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/test/JansLinkConfigResourceTest.java b/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/test/JansLinkConfigResourceTest.java new file mode 100644 index 00000000000..d8bcfaf5678 --- /dev/null +++ b/jans-config-api/plugins/jans-link-plugin/src/test/java/io/jans/configapi/test/JansLinkConfigResourceTest.java @@ -0,0 +1,38 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Parameters; + +public class JansLinkConfigResourceTest extends BaseTest { + + @Parameters({"issuer", "linkConfigUrl"}) + @Test + public void getLinkConfiguration(final String issuer, final String linkConfigUrl) { + log.error("getLinkConfiguration() - accessToken:{}, issuer:{}, linkConfigUrl:{}", accessToken, issuer, linkConfigUrl); + Builder request = getResteasyService().getClientBuilder(issuer + linkConfigUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.error("Response for getLinkConfiguration - response:{}", response); + } + + + +} diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/feature/link/dynamiconf.json b/jans-config-api/plugins/jans-link-plugin/src/test/resources/json/link/dynamiconf.json similarity index 100% rename from jans-config-api/plugins/jans-link-plugin/src/test/resources/feature/link/dynamiconf.json rename to jans-config-api/plugins/jans-link-plugin/src/test/resources/json/link/dynamiconf.json diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/feature/link/link-config.feature b/jans-config-api/plugins/jans-link-plugin/src/test/resources/json/link/link-config.feature similarity index 100% rename from jans-config-api/plugins/jans-link-plugin/src/test/resources/feature/link/link-config.feature rename to jans-config-api/plugins/jans-link-plugin/src/test/resources/json/link/link-config.feature diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index e8db40cc61c..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - jansLinkUrl: baseUrl + '/jans-config-api/jans-link/link-config', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate-config.js deleted file mode 100644 index 079922e6552..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,57 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - jansLinkUrl: baseUrl + '/jans-config-api/jans-link/link-config', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/test.properties b/jans-config-api/plugins/jans-link-plugin/src/test/resources/test.properties index 4257f297907..f018a240e3e 100644 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/jans-link-plugin/src/test/resources/test.properties @@ -1,8 +1,11 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +linkConfigUrl=/jans-config-api/jans-link/link-config \ No newline at end of file diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/jans-link-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/jans-link-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..e37cc5e1b5f --- /dev/null +++ b/jans-config-api/plugins/jans-link-plugin/src/test/resources/testng.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/jans-link-plugin/src/test/resources/token.feature b/jans-config-api/plugins/jans-link-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/jans-link-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/plugins/kc-link-plugin/pom.xml b/jans-config-api/plugins/kc-link-plugin/pom.xml index d92ec7aeba1..71f2e34df77 100644 --- a/jans-config-api/plugins/kc-link-plugin/pom.xml +++ b/jans-config-api/plugins/kc-link-plugin/pom.xml @@ -122,35 +122,15 @@ + + io.rest-assured + rest-assured + test + - io.rest-assured - rest-assured - test - - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -173,12 +153,6 @@ src/test/resources true - - karate.properties - karate_jenkins.properties - test.properties - *.* - @@ -218,12 +192,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java b/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java deleted file mode 100644 index a7f7d2d80c2..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class TestJenkinsRunner { - - @Test - void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/test/JansKcLinkConfigResourceTest.java b/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/test/JansKcLinkConfigResourceTest.java new file mode 100644 index 00000000000..a3599ee2fd4 --- /dev/null +++ b/jans-config-api/plugins/kc-link-plugin/src/test/java/io/jans/configapi/test/JansKcLinkConfigResourceTest.java @@ -0,0 +1,48 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import java.lang.reflect.Method; + +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; +import org.testng.SkipException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Parameters; + +public class JansKcLinkConfigResourceTest extends BaseTest { + + // Execute before each test is run + @BeforeMethod + public void before(Method methodName){ + boolean isServiceDeployed = isServiceDeployed("io.jans.configapi.plugin.kc.link.rest.ApiApplication"); + log.info("\n\n\n *** JansKcLinkConfigResourceTest - isServiceDeployed:{}",isServiceDeployed); + // check condition, note once you condition is met the rest of the tests will be skipped as well + if(!isServiceDeployed) { + throw new SkipException("KC-LINK Plugin not deployed"); + } + } + + @Parameters({"issuer", "kcLinkConfigUrl"}) + @Test + public void getKcLinkConfiguration(final String issuer, final String kcLinkConfigUrl) { + log.info("getKcLinkConfiguration() - accessToken:{}, issuer:{}, kcLinkConfigUrl:{}", accessToken, issuer, kcLinkConfigUrl); + Builder request = getResteasyService().getClientBuilder(issuer + kcLinkConfigUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getKcLinkConfiguration - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/feature/kc-link/kc-link-config.feature b/jans-config-api/plugins/kc-link-plugin/src/test/resources/json/kc-link/kc-link-config.feature similarity index 100% rename from jans-config-api/plugins/kc-link-plugin/src/test/resources/feature/kc-link/kc-link-config.feature rename to jans-config-api/plugins/kc-link-plugin/src/test/resources/json/kc-link/kc-link-config.feature diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index f17ade676db..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - kcLinkUrl: baseUrl + '/jans-config-api/kc-link/kc-link-config', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate-config.js deleted file mode 100644 index 41958588071..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,57 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - kcLinkUrl: baseUrl + '/jans-config-api/kc-link/kc-link-config', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/test.properties b/jans-config-api/plugins/kc-link-plugin/src/test/resources/test.properties index 4257f297907..30ac6460f26 100644 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/kc-link-plugin/src/test/resources/test.properties @@ -1,8 +1,11 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +kcLinkConfigUrl=/jans-config-api/kc-link/kcLinkConfig \ No newline at end of file diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/kc-link-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/kc-link-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..f1b7dbb7db0 --- /dev/null +++ b/jans-config-api/plugins/kc-link-plugin/src/test/resources/testng.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/kc-link-plugin/src/test/resources/token.feature b/jans-config-api/plugins/kc-link-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/kc-link-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/plugins/kc-saml-plugin/pom.xml b/jans-config-api/plugins/kc-saml-plugin/pom.xml index 29feff15e1e..cb7c36c3821 100644 --- a/jans-config-api/plugins/kc-saml-plugin/pom.xml +++ b/jans-config-api/plugins/kc-saml-plugin/pom.xml @@ -142,35 +142,15 @@ + + io.rest-assured + rest-assured + test + - io.rest-assured - rest-assured - test - - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -193,12 +173,6 @@ src/test/resources true - - karate.properties - karate_jenkins.properties - test.properties - *.* - @@ -238,12 +212,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java deleted file mode 100644 index a7f7d2d80c2..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class TestJenkinsRunner { - - @Test - void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansIdpResourceTest.java b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansIdpResourceTest.java new file mode 100644 index 00000000000..6bf4b9ad08e --- /dev/null +++ b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansIdpResourceTest.java @@ -0,0 +1,49 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import java.lang.reflect.Method; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import org.testng.SkipException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Parameters; + +public class JansIdpResourceTest extends BaseTest { + + // Execute before each test is run + @BeforeMethod + public void before(Method methodName) { + boolean isServiceDeployed = isServiceDeployed("io.jans.configapi.plugin.saml.rest.ApiApplication"); + log.info("\n\n\n *** JansIdpResourceTest - isServiceDeployed:{}", isServiceDeployed); + // check condition, note once you condition is met the rest of the tests will be + // skipped as well + if (!isServiceDeployed) { + throw new SkipException("KC-SAML Plugin not deployed"); + } + } + + @Parameters({ "issuer", "samlIdpUrl" }) + @Test + public void getKcSAMLIdp(final String issuer, final String samlIdpUrl) { + log.info("getKcSAMLIdp() - accessToken:{}, issuer:{}, samlIdpUrl:{}", accessToken, issuer, samlIdpUrl); + Builder request = getResteasyService().getClientBuilder(issuer + samlIdpUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getKcSAMLIdp - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansKcSAMLConfigResourceTest.java b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansKcSAMLConfigResourceTest.java new file mode 100644 index 00000000000..72480c7b952 --- /dev/null +++ b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansKcSAMLConfigResourceTest.java @@ -0,0 +1,47 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import java.lang.reflect.Method; +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +import org.testng.SkipException; +import org.testng.annotations.Parameters; + +public class JansKcSAMLConfigResourceTest extends BaseTest { + + // Execute before each test is run + @BeforeMethod + public void before(Method methodName) { + // check condition, note once you condition is met the rest of the tests will be + // skipped as well + if (!isServiceDeployed("io.jans.configapi.plugin.saml.rest.ApiApplication")) + throw new SkipException("KC-SAML Plugin not deployed"); + } + + @Parameters({ "issuer", "samlConfigUrl" }) + @Test + public void getKcSAMLConfiguration(final String issuer, final String samlConfigUrl) { + log.info("getKcSAMLConfiguration() - accessToken:{}, issuer:{}, samlConfigUrl:{}", accessToken, issuer, + samlConfigUrl); + Builder request = getResteasyService().getClientBuilder(issuer + samlConfigUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getKcSAMLConfiguration - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansKcSAMLTrustRelationshipTest.java b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansKcSAMLTrustRelationshipTest.java new file mode 100644 index 00000000000..607b37e8bab --- /dev/null +++ b/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/test/JansKcSAMLTrustRelationshipTest.java @@ -0,0 +1,47 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; +import java.lang.reflect.Method; + +import org.testng.SkipException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Parameters; + +public class JansKcSAMLTrustRelationshipTest extends BaseTest { + + // Execute before each test is run + @BeforeMethod + public void before(Method methodName) { + // check condition, note once you condition is met the rest of the tests will be + // skipped as well + if (!isServiceDeployed("io.jans.configapi.plugin.saml.rest.ApiApplication")) + throw new SkipException("KC-SAML Plugin not deployed"); + } + + @Parameters({ "issuer", "samlTrustRelationshipUrl" }) + @Test + public void getKcSAMLTrustRelationship(final String issuer, final String samlTrustRelationshipUrl) { + log.info("getKcSAMLTrustRelationship() - accessToken:{}, issuer:{}, samlTrustRelationshipUrl:{}", accessToken, + issuer, samlTrustRelationshipUrl); + Builder request = getResteasyService().getClientBuilder(issuer + samlTrustRelationshipUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getKcSAMLTrustRelationship - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/feature/saml/config/saml.feature b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/json/saml/config/saml.feature similarity index 100% rename from jans-config-api/plugins/kc-saml-plugin/src/test/resources/feature/saml/config/saml.feature rename to jans-config-api/plugins/kc-saml-plugin/src/test/resources/json/saml/config/saml.feature diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/feature/saml/trust-relationship/saml-trust-relationship.feature b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/json/saml/trust-relationship/saml-trust-relationship.feature similarity index 100% rename from jans-config-api/plugins/kc-saml-plugin/src/test/resources/feature/saml/trust-relationship/saml-trust-relationship.feature rename to jans-config-api/plugins/kc-saml-plugin/src/test/resources/json/saml/trust-relationship/saml-trust-relationship.feature diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index d32b307b93f..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,59 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - samlTrustRelationshipUrl: baseUrl + '/jans-config-api/saml/trust-relationship', - samlConfigUrl: baseUrl + '/jans-config-api/saml/samlConfig', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate-config.js deleted file mode 100644 index a8086c01326..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - samlTrustRelationshipUrl: baseUrl + '/jans-config-api/saml/trust-relationship', - samlConfigUrl: baseUrl + '/jans-config-api/saml/samlConfig', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/test.properties b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/test.properties index 4257f297907..95a3cdef1a3 100644 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/test.properties @@ -1,8 +1,12 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + +samlConfigUrl=/jans-config-api/kc/samlConfig +samlTrustRelationshipUrl=/jans-config-api/kc/saml/trust-relationship +samlIdpUrl=/jans-config-api/kc/saml/idp \ No newline at end of file diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..3027ee6fd06 --- /dev/null +++ b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/testng.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/token.feature b/jans-config-api/plugins/kc-saml-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/plugins/lock-plugin/pom.xml b/jans-config-api/plugins/lock-plugin/pom.xml index cace2d322a5..053428ac213 100644 --- a/jans-config-api/plugins/lock-plugin/pom.xml +++ b/jans-config-api/plugins/lock-plugin/pom.xml @@ -111,35 +111,15 @@ + + io.rest-assured + rest-assured + test + - io.rest-assured - rest-assured - test - - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -162,12 +142,6 @@ src/test/resources true - - karate.properties - karate_jenkins.properties - test.properties - *.* - @@ -207,12 +181,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java b/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java deleted file mode 100644 index a7f7d2d80c2..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/TestJenkinsRunner.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class TestJenkinsRunner { - - @Test - void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/test/LockAuditResourceTest.java b/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/test/LockAuditResourceTest.java new file mode 100644 index 00000000000..cb5960dad89 --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/test/LockAuditResourceTest.java @@ -0,0 +1,69 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import java.lang.reflect.Method; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; + +import org.testng.SkipException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Parameters; + +public class LockAuditResourceTest extends BaseTest { + + // Execute before each test is run + @BeforeMethod + public void before(Method methodName) { + boolean isServiceDeployed = isServiceDeployed("io.jans.configapi.plugin.lock.rest.ApiApplication"); + log.info("\n\n\n *** LockAuditResourceTest - isServiceDeployed:{}", isServiceDeployed); + // check condition, note once you condition is met the rest of the tests will be + // skipped as well + if (!isServiceDeployed) { + throw new SkipException("Lock Plugin not deployed"); + } + + } + + @Parameters({ "issuer", "lockAuditHealthPostUrl", "audit_health_post_1" }) + @Test + public void getLockAuditData(final String issuer, final String lockAuditHealthPostUrl, final String json) { + log.info("getLockAuditData() - accessToken:{}, issuer:{}, lockAuditHealthPostUrl:{}, json:{}", accessToken, + issuer, lockAuditHealthPostUrl, json); + Builder request = getResteasyService().getClientBuilder(issuer + lockAuditHealthPostUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.post(Entity.entity(json, MediaType.APPLICATION_JSON)); + log.info("post lock audit - response:{}", response); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getLockAuditData - response:{}", response); + } + + @Parameters({ "issuer", "lockAuditHealthSearchUrl" }) + // @Test + public void getLockAuditData(final String issuer, final String lockAuditHealthSearchUrl) { + log.info("getLockAuditData() - accessToken:{}, issuer:{}, lockAuditHealthSearchUrl:{}", accessToken, issuer, + lockAuditHealthSearchUrl); + Builder request = getResteasyService().getClientBuilder(issuer + lockAuditHealthSearchUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getLockAuditData - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/test/LockConfigResourceTest.java b/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/test/LockConfigResourceTest.java new file mode 100644 index 00000000000..f3273d7c69d --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/java/io/jans/configapi/test/LockConfigResourceTest.java @@ -0,0 +1,51 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; +import java.lang.reflect.Method; +import org.testng.SkipException; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Parameters; + +public class LockConfigResourceTest extends BaseTest { + + // Execute before each test is run + @BeforeMethod + public void before(Method methodName) { + boolean isServiceDeployed = isServiceDeployed("io.jans.configapi.plugin.lock.rest.ApiApplication"); + log.info("\n\n\n *** LockConfigResourceTest - isServiceDeployed:{}", isServiceDeployed); + // check condition, note once you condition is met the rest of the tests will be + // skipped as well + if (!isServiceDeployed) { + throw new SkipException("Lock Plugin not deployed"); + } + + } + + @Parameters({ "issuer", "lockConfigUrl" }) + @Test + public void getLockConfigUrlData(final String issuer, final String lockConfigUrl) { + log.info("getLockConfigUrlData() - accessToken:{}, issuer:{}, lockConfigUrl:{}", accessToken, issuer, + lockConfigUrl); + Builder request = getResteasyService().getClientBuilder(issuer + lockConfigUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getLockConfigUrlData - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-health-post.json b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-health-post.json new file mode 100644 index 00000000000..763018756bf --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-health-post.json @@ -0,0 +1,6 @@ +{ + "jansStatus": "Success", + "cedarEngineStatus": "fail", + "cedarPolicyStatus": "pass", + "tokenDataStatus": "error" +} \ No newline at end of file diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-log-post.json b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-log-post.json new file mode 100644 index 00000000000..65c11f6e7c7 --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-log-post.json @@ -0,0 +1,9 @@ +{ + "eventTime": "2012-04-21T18:25:43-05:00", + "eventType": "registration", + "severetyLevel": "warning", + "policyId": "PID001", + "policyResult": "deny", + "userAccountId": "ACC0001", + "clientId": "CLI001" +} \ No newline at end of file diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-telemetry-post.json b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-telemetry-post.json new file mode 100644 index 00000000000..65c11f6e7c7 --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-audit-telemetry-post.json @@ -0,0 +1,9 @@ +{ + "eventTime": "2012-04-21T18:25:43-05:00", + "eventType": "registration", + "severetyLevel": "warning", + "policyId": "PID001", + "policyResult": "deny", + "userAccountId": "ACC0001", + "clientId": "CLI001" +} \ No newline at end of file diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/feature/lock/lock-config.feature b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-config.feature similarity index 100% rename from jans-config-api/plugins/lock-plugin/src/test/resources/feature/lock/lock-config.feature rename to jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-config.feature diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-config.json b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-config.json new file mode 100644 index 00000000000..8a39e6b159a --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/resources/json/lock/lock-config.json @@ -0,0 +1,56 @@ +{ + "baseEndpoint": "https://pujavs-witty-weasel.gluu.info/jans-auth/v1", + "openIdIssuer": "https://pujavs-witty-weasel.gluu.info", + "tokenChannels": [ + "jans_token" + ], + "clientId": "2200.ea10b5a0-a6b7-45fd-ad0b-5e34f7f75fab", + "clientPassword": "zZn4wZAA+TU1OJ8s7z/l8g==", + "tokenUrl": "https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token", + "groupScopeEnabled": true, + "endpointGroups": { + "audit": [ + "telemetry", + "telemetry/bulk", + "health", + "health/bulk", + "log", + "log/bulk" + ] + }, + "endpointDetails": { + "jans-config-api/lock/audit/telemetry": [ + "https://jans.io/oauth/lock/telemetry.readonly", + "https://jans.io/oauth/lock/telemetry.write" + ], + "jans-config-api/lock/audit/telemetry/bulk": [ + "https://jans.io/oauth/lock/telemetry.readonly", + "https://jans.io/oauth/lock/telemetry.write" + ], + "jans-config-api/lock/audit/log": [ + "https://jans.io/oauth/lock/log.write" + ], + "jans-config-api/lock/audit/log/bulk": [ + "https://jans.io/oauth/lock/log.write" + ], + "jans-config-api/lock/audit/health": [ + "https://jans.io/oauth/lock/health.readonly", + "https://jans.io/oauth/lock/health.write" + ], + "jans-config-api/lock/audit/health/bulk": [ + "https://jans.io/oauth/lock/health.readonly", + "https://jans.io/oauth/lock/health.write" + ] + }, + "disableJdkLogger": true, + "loggingLevel": "INFO", + "loggingLayout": "text", + "metricReporterInterval": 300, + "metricReporterKeepDataDays": 15, + "metricReporterEnabled": true, + "cleanServiceInterval": 60, + "opaConfiguration": { + "baseUrl": "http://localhost:8181/v1/" + }, + "pdpType": "OPA" +} \ No newline at end of file diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/lock-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index 6689c423102..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - lockUrl: baseUrl + '/jans-config-api/lock/lock-config', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/lock-plugin/src/test/resources/karate-config.js deleted file mode 100644 index eed01e27f05..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,57 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - LockUrl: baseUrl + '/jans-config-api/lock/lock-config', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/lock-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/lock-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/test.properties b/jans-config-api/plugins/lock-plugin/src/test/resources/test.properties index 4257f297907..f191ad9ed07 100644 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/lock-plugin/src/test/resources/test.properties @@ -1,8 +1,22 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +lockAuditHealthPostUrl=/jans-config-api/lock/audit/health +lockAuditHealthSearchUrl=/jans-config-api/lock/audit/health/search +lockAuditLogPostUrl=/jans-config-api/lock/audit/log +lockAuditLogSearchUrl=/jans-config-api/lock/audit/log/search +lockAuditTelemetryPostUrl=/jans-config-api/lock/audit/telemetry +lockAuditTelemetrySearchUrl=/jans-config-api/lock/audit/telemetry/search +lockConfigUrl=/jans-config-api/lock/lockConfig + + +audit_health_post_1=file:target/test-classes/json/lock/lock-audit-health-post.json +audit_log_post_1=file:target/test-classes/json/lock/lock-audit-log-post.json +audit_telemetry_post_1=file:target/test-classes/json/lock/lock-audit-telemetry-post.json diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/lock-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/lock-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..ffa29f7c848 --- /dev/null +++ b/jans-config-api/plugins/lock-plugin/src/test/resources/testng.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/lock-plugin/src/test/resources/token.feature b/jans-config-api/plugins/lock-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/lock-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/plugins/scim-plugin/pom.xml b/jans-config-api/plugins/scim-plugin/pom.xml index 7d460c68a29..dc16e44d7f7 100644 --- a/jans-config-api/plugins/scim-plugin/pom.xml +++ b/jans-config-api/plugins/scim-plugin/pom.xml @@ -86,35 +86,15 @@ + + io.rest-assured + rest-assured + test + - io.rest-assured - rest-assured - test - - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -136,12 +116,6 @@ src/test/resources true - - karate.properties - karate_jenkins.properties - test.properties - *.* - @@ -181,12 +155,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/JenkinsTestRunner.java b/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/JenkinsTestRunner.java deleted file mode 100644 index d039e1f2040..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/JenkinsTestRunner.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Yuriy Zabrovarnyy - */ -public class JenkinsTestRunner { - - @Test - public void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/test/ScimConfigResourceTest.java b/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/test/ScimConfigResourceTest.java new file mode 100644 index 00000000000..0159f477b1f --- /dev/null +++ b/jans-config-api/plugins/scim-plugin/src/test/java/io/jans/configapi/test/ScimConfigResourceTest.java @@ -0,0 +1,34 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Test; +import org.testng.annotations.Parameters; + +public class ScimConfigResourceTest extends BaseTest { + + @Parameters({"issuer", "scimConfigUrl"}) + @Test + public void getScimConfigData(final String issuer, final String scimConfigUrl) { + log.info("getScimConfigData() - accessToken:{}, issuer:{}, scimConfigUrl:{}", accessToken, issuer, scimConfigUrl); + Builder request = getResteasyService().getClientBuilder(issuer + scimConfigUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getScimConfigData - response:{}", response); + } + +} diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/feature/scim/config/scim-config.feature b/jans-config-api/plugins/scim-plugin/src/test/resources/json/scim/config/scim-config.feature similarity index 100% rename from jans-config-api/plugins/scim-plugin/src/test/resources/feature/scim/config/scim-config.feature rename to jans-config-api/plugins/scim-plugin/src/test/resources/json/scim/config/scim-config.feature diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/scim-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index fd5214c5cfe..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - //scim - scim_config_url: baseUrl + '/jans-config-api/scim/scim-config', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/scim-plugin/src/test/resources/karate-config.js deleted file mode 100644 index 0c8ff9e7111..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,59 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - - //scim - scim_config_url: baseUrl + '/jans-config-api/scim/scim-config', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/scim-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/scim-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/test.properties b/jans-config-api/plugins/scim-plugin/src/test/resources/test.properties index 4257f297907..fcb60d1ba19 100644 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/scim-plugin/src/test/resources/test.properties @@ -1,8 +1,11 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +scimConfigUrl=/jans-config-api/scim/scim-config \ No newline at end of file diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/scim-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/scim-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..4c9045e4208 --- /dev/null +++ b/jans-config-api/plugins/scim-plugin/src/test/resources/testng.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/scim-plugin/src/test/resources/token.feature b/jans-config-api/plugins/scim-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/scim-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/plugins/user-mgt-plugin/pom.xml b/jans-config-api/plugins/user-mgt-plugin/pom.xml index 27c77ea328b..0142c8706bb 100644 --- a/jans-config-api/plugins/user-mgt-plugin/pom.xml +++ b/jans-config-api/plugins/user-mgt-plugin/pom.xml @@ -82,35 +82,15 @@ + + io.rest-assured + rest-assured + test + - io.rest-assured - rest-assured - test - - - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -132,12 +112,6 @@ src/test/resources true - - karate.properties - karate_jenkins.properties - test.properties - *.* - @@ -177,12 +151,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/JenkinsTestRunner.java b/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/JenkinsTestRunner.java deleted file mode 100644 index d039e1f2040..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/JenkinsTestRunner.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Yuriy Zabrovarnyy - */ -public class JenkinsTestRunner { - - @Test - public void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/test/UserResourceTest.java b/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/test/UserResourceTest.java new file mode 100644 index 00000000000..59ba05c526b --- /dev/null +++ b/jans-config-api/plugins/user-mgt-plugin/src/test/java/io/jans/configapi/test/UserResourceTest.java @@ -0,0 +1,37 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test; + +import io.jans.configapi.core.test.BaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import org.testng.annotations.Test; +import org.testng.annotations.Parameters; +import static org.testng.Assert.assertEquals; + + +public class UserResourceTest extends BaseTest { + + @Parameters({"issuer", "userUrl"}) + @Test + public void getUserResourceData(final String issuer, final String userUrl) { + log.info("\n\n getUserResourceData() - accessToken:{}, issuer:{}, userUrl:{}", accessToken, issuer, userUrl); + Builder request = getResteasyService().getClientBuilder(issuer + userUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("\n\n Response for getUserResourceData() - response:{}", response); + } + + + +} diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user-patch.json b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user-patch.json similarity index 100% rename from jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user-patch.json rename to jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user-patch.json diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user-ref.json b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user-ref.json similarity index 100% rename from jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user-ref.json rename to jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user-ref.json diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user.feature b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user.feature similarity index 100% rename from jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user.feature rename to jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user.feature diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user.json b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user.json similarity index 100% rename from jans-config-api/plugins/user-mgt-plugin/src/test/resources/feature/mgt/user/user.json rename to jans-config-api/plugins/user-mgt-plugin/src/test/resources/json/mgt/user/user.json diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate-config-jenkins.js b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index bffd51af405..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,58 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - //mgt - user_url: baseUrl + '/jans-config-api/mgt/configuser', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate-config.js b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate-config.js deleted file mode 100644 index ac0472c4dd1..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate-config.js +++ /dev/null @@ -1,59 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - - //mgt - user_url: baseUrl + '/jans-config-api/mgt/configuser', - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate.properties b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate_jenkins.properties b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/test.properties b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/test.properties index 4257f297907..05a8ea9fd8a 100644 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/test.properties +++ b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/test.properties @@ -1,8 +1,11 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +userUrl=/jans-config-api/mgt/configuser \ No newline at end of file diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/testClient.feature b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/testng.xml b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/testng.xml new file mode 100644 index 00000000000..e346fbf279d --- /dev/null +++ b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/testng.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/token.feature b/jans-config-api/plugins/user-mgt-plugin/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/plugins/user-mgt-plugin/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/pom.xml b/jans-config-api/pom.xml index efb8f25fd64..2fb7fcd58bd 100644 --- a/jans-config-api/pom.xml +++ b/jans-config-api/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 @@ -23,7 +23,7 @@ 11 UTF-8 UTF-8 - 3.0.0-M5 + 3.5.2 ${project.version} @@ -41,7 +41,7 @@ 4.7.5.Final 5.0.1 - 0.9.5 + 7.8.0 2.0 5.7.0 3.8.0 @@ -93,11 +93,7 @@ Bouncy Castle https://repo1.maven.org/maven2/org/bouncycastle - - repository.jboss.org - JBoss Repository - https://repository.jboss.org/nexus/content/groups/public-jboss/ - + @@ -109,13 +105,13 @@ - - io.jans - jans-bom - ${jans.version} - import - pom - + + io.jans + jans-bom + ${jans.version} + import + pom + com.fasterxml.jackson jackson-bom @@ -333,40 +329,12 @@ test - com.intuit.karate - karate-junit5 - ${karate.version} - test - - - snakeyaml - * - - - - - com.intuit.karate - karate-apache - ${karate.version} - test - - - org.yaml - snakeyaml - ${snake.version} - - - org.junit.jupiter - junit-jupiter-api - ${jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${jupiter.version} - test - + org.testng + testng + ${testng.version} + + + net.masterthought cucumber-reporting diff --git a/jans-config-api/server/pom.xml b/jans-config-api/server/pom.xml index b0d052e9f61..aae964a284c 100644 --- a/jans-config-api/server/pom.xml +++ b/jans-config-api/server/pom.xml @@ -195,29 +195,9 @@ test - com.intuit.karate - karate-junit5 - test - - - com.intuit.karate - karate-apache - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - net.masterthought - cucumber-reporting - test + org.testng + testng + test @@ -266,22 +246,15 @@ jans-config-api - ../profiles/${cfg}/config-build.properties ../profiles/${cfg}/config-api-test.properties - - - src/test/resources - true - - karate.properties - karate_jenkins.properties - test.properties - *.* - - - + + + src/test/resources + true + + @@ -388,12 +361,9 @@ maven-surefire-plugin - - - integration - - --tags ~@ignore - + + target/test-classes/testng.xml + diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java index 5f24bdead8b..dd5b41dcf87 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java @@ -55,7 +55,6 @@ public Response doSyntaxCheck(@Parameter(description = "Agama Flow name") @PathP } e.setStackTrace(new StackTraceElement[0]); return Response.ok().entity(e).build(); - } } diff --git a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/server/src/test/java/io/jans/configapi/ConfigServerBaseTest.java similarity index 51% rename from jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java rename to jans-config-api/server/src/test/java/io/jans/configapi/ConfigServerBaseTest.java index 34da4586ef9..e487705f1dc 100644 --- a/jans-config-api/plugins/kc-saml-plugin/src/test/java/io/jans/configapi/KarateTestRunner.java +++ b/jans-config-api/server/src/test/java/io/jans/configapi/ConfigServerBaseTest.java @@ -6,13 +6,10 @@ package io.jans.configapi; -import com.intuit.karate.junit5.Karate; -public class KarateTestRunner { +import io.jans.configapi.core.test.BaseTest; - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } +public class ConfigServerBaseTest extends BaseTest{ + //server specific code } diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/JenkinsTestRunner.java b/jans-config-api/server/src/test/java/io/jans/configapi/JenkinsTestRunner.java deleted file mode 100644 index d039e1f2040..00000000000 --- a/jans-config-api/server/src/test/java/io/jans/configapi/JenkinsTestRunner.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.Results; -import com.intuit.karate.Runner; - -import io.jans.as.common.model.registration.Client; -import net.masterthought.cucumber.Configuration; -import net.masterthought.cucumber.ReportBuilder; -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Yuriy Zabrovarnyy - */ -public class JenkinsTestRunner { - - @Test - public void testParallel() { - System.setProperty("karate.env", "jenkins"); - Results results = Runner.path("src/test/resources/feature").tags("~@ignore").parallel(1); - generateReport(results.getReportDir()); - Assertions.assertEquals(0, results.getFailCount(), results.getErrorMessages()); - } - - public static void generateReport(String karateOutputPath) { - Collection jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] { "json" }, true); - List jsonPaths = new ArrayList(jsonFiles.size()); - jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath())); - Configuration config = new Configuration(new File("target"), "karateTesting"); - ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config); - reportBuilder.generateReports(); - } -} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/KarateTestRunner.java b/jans-config-api/server/src/test/java/io/jans/configapi/KarateTestRunner.java deleted file mode 100644 index 34da4586ef9..00000000000 --- a/jans-config-api/server/src/test/java/io/jans/configapi/KarateTestRunner.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi; - -import com.intuit.karate.junit5.Karate; - -public class KarateTestRunner { - - @Karate.Test - Karate testFullPath() throws Exception { - return Karate.run("src/test/resources/feature"); - } - -} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/rest/resource/ConfigResourceTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/rest/resource/ConfigResourceTest.java deleted file mode 100644 index 34e4b478b39..00000000000 --- a/jans-config-api/server/src/test/java/io/jans/configapi/rest/resource/ConfigResourceTest.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. - * - * Copyright (c) 2020, Janssen Project - */ - -package io.jans.configapi.rest.resource; - -import org.junit.jupiter.api.Test; -import jakarta.ws.rs.core.MediaType; -import static io.restassured.RestAssured.given; - -/** - * @author Yuriy Zabrovarnyy - */ -public class ConfigResourceTest { - - @Test - public void patchAppConfigurationProperty() { - given().when().contentType(MediaType.APPLICATION_JSON) - .header("Authorization", "Bearer 0ea2ce99-b741-4f5a-8fd7-26f52d057c19", null) - .body("[ {\"op\":\"replace\", \"path\": \"/loggingLevel\", \"value\": \"DEBUG\" } ]") - .patch("/jans-config-api/api/v1/jans-auth-server/config").then().statusCode(200); - } -} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AcrsResourceTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AcrsResourceTest.java new file mode 100644 index 00000000000..ab1313ec44b --- /dev/null +++ b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AcrsResourceTest.java @@ -0,0 +1,48 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test.auth; + +import io.jans.configapi.ConfigServerBaseTest; + +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class AcrsResourceTest extends ConfigServerBaseTest{ + + @Parameters({"issuer", "acrsUrl"}) + @Test + public void getDefaultAuthenticationMethod(final String issuer, final String acrsUrl) { + log.info("accessToken:{}, issuer:{}, acrsUrl:{}", accessToken, issuer, acrsUrl); + Builder request = getResteasyService().getClientBuilder(issuer + acrsUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getDefaultAuthenticationMethod - response:{}", response); + } + + + @Parameters({"issuer", "acrsUrl", "default_acr_1"}) + @Test + public void postClient(final String issuer, final String acrsUrl, final String json) { + log.info("accessToken:{}, issuer:{}, acrsUrl:{}, json:{}", accessToken, issuer, acrsUrl, json); + Builder request = getResteasyService().getClientBuilder(issuer + acrsUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.put(Entity.entity(json, MediaType.APPLICATION_JSON)); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getApiConfigtion - response:{}", response); + + } +} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AgamaDeploymentsResourceTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AgamaDeploymentsResourceTest.java new file mode 100644 index 00000000000..bc86fa52776 --- /dev/null +++ b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AgamaDeploymentsResourceTest.java @@ -0,0 +1,36 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test.auth; + +import io.jans.configapi.ConfigServerBaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class AgamaDeploymentsResourceTest extends ConfigServerBaseTest { + + @Parameters({ "issuer", "agamaDeploymentUrl" }) + @Test + public void getDeployments(final String issuer, final String agamaDeploymentUrl) { + log.info("accessToken:{}, issuer:{}, agamaDeploymentUrl:{}", accessToken, issuer, agamaDeploymentUrl); + + Builder request = getResteasyService().getClientBuilder(issuer + agamaDeploymentUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getDefaultAuthenticationMethod - response:{}", response); + + } + +} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AuthConfigResourceTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AuthConfigResourceTest.java new file mode 100644 index 00000000000..422637338ce --- /dev/null +++ b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/AuthConfigResourceTest.java @@ -0,0 +1,66 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test.auth; + +import io.jans.configapi.ConfigServerBaseTest; + +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import static org.testng.Assert.*; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class AuthConfigResourceTest extends ConfigServerBaseTest{ + + @Parameters({"issuer", "authConfigurationUrl"}) + @Test + public void getAuthConfigurationProperty(final String issuer, final String authConfigurationUrl) { + log.info("getAuthConfigurationProperty() - accessToken:{}, issuer:{}, authConfigurationUrl:{}", accessToken, issuer, authConfigurationUrl); + + Builder request = getResteasyService().getClientBuilder(issuer + authConfigurationUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getAuthConfigurationProperty() - response:{}", response); + } + + @Parameters({"issuer", "authConfigurationUrl"}) + @Test + public void getPersistenceDetails(final String issuer, final String authConfigurationUrl) { + log.info("getPersistenceDetails() - accessToken:{}, issuer:{}, authConfigurationUrl:{}", accessToken, issuer, authConfigurationUrl); + + Builder request = getResteasyService().getClientBuilder(issuer + authConfigurationUrl + "/persistence"); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getPersistenceDetails() - response:{}", response); + } + + @Parameters({"issuer", "authConfigurationUrl", "auth_config_patch_1"}) + @Test + public void patchAuthConfigurationProperty(final String issuer, final String authConfigurationUrl, final String json) { + log.info("patchAuthConfigurationProperty() - getApiConfigtion() - accessToken:{}, issuer:{}, authConfigurationUrl:{}, json:{}", accessToken, issuer, + authConfigurationUrl, json); + Builder request = getResteasyService().getClientBuilder(issuer + authConfigurationUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON_PATCH_JSON); + + Response response = request.method(HttpMethod.PATCH, Entity.entity(json, MediaType.APPLICATION_JSON_PATCH_JSON)); + + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response patchAuthConfigurationProperty() - response:{}", response); + } +} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/ClientResourceTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/ClientResourceTest.java new file mode 100644 index 00000000000..2fb7cd82292 --- /dev/null +++ b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/ClientResourceTest.java @@ -0,0 +1,55 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test.auth; + +import io.jans.configapi.ConfigServerBaseTest; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +import static org.testng.Assert.*; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +public class ClientResourceTest extends ConfigServerBaseTest { + + + @Parameters({ "issuer", "openidClientsUrl" }) + @Test + public void getAllClient(final String issuer, final String openidClientsUrl) { + log.info("getAllClient() - accessToken:{}, issuer:{}, openidClientsUrl:{}", accessToken, issuer, + openidClientsUrl); + Builder request = getResteasyService().getClientBuilder(issuer + openidClientsUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getAllClient - response:{}", response); + } + + @Parameters({ "issuer", "openidClientsUrl", "openid_client_1" }) + @Test + public void postClient(final String issuer, final String openidClientsUrl, final String json) { + log.info("\n\n\n postClient2 - accessToken:{}, issuer:{}, openidClientsUrl:{}, json:{}", accessToken, issuer, + openidClientsUrl, json); + + Builder request = getResteasyService().getClientBuilder(issuer + openidClientsUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); + Response response = request.post(Entity.entity(json, MediaType.APPLICATION_JSON)); + log.info("post client - response:{}", response); + + if (response.getStatus() == 201) { + log.trace("Response for postClient - response.getEntity():{}, response.getClass():{}", + response.getEntity(), response.getClass()); + } + + assertEquals(response.getStatus(), Status.CREATED.getStatusCode()); + } +} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/ConfigResourceTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/ConfigResourceTest.java new file mode 100644 index 00000000000..03a66ddd1af --- /dev/null +++ b/jans-config-api/server/src/test/java/io/jans/configapi/test/auth/ConfigResourceTest.java @@ -0,0 +1,52 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test.auth; + +import static org.testng.Assert.assertEquals; + +import io.jans.configapi.ConfigServerBaseTest; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; + +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +public class ConfigResourceTest extends ConfigServerBaseTest { + + @Parameters({ "issuer", "apiConfigtionUrl" }) + @Test + public void getApiConfigtion(final String issuer, final String apiConfigtionUrl) { + log.info("getApiConfigtion() - accessToken:{}, issuer:{}, apiConfigtionUrl:{}", accessToken, issuer, + apiConfigtionUrl); + Builder request = getResteasyService().getClientBuilder(issuer + apiConfigtionUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getApiConfigtion - response:{}", response); + + } + + @Parameters({ "issuer", "apiConfigtionUrl", "api_config_patch_1" }) + @Test + public void patchgetApiConfigtion(final String issuer, final String apiConfigtionUrl, final String json) { + log.info("getApiConfigtion() - accessToken:{}, issuer:{}, apiConfigtionUrl:{}, json:{}", accessToken, issuer, + apiConfigtionUrl, json); + Builder request = getResteasyService().getClientBuilder(issuer + apiConfigtionUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON_PATCH_JSON); + + Response response = request.method(HttpMethod.PATCH, Entity.entity(json, MediaType.APPLICATION_JSON_PATCH_JSON)); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getApiConfigtion - response:{}", response); + } +} diff --git a/jans-config-api/server/src/test/java/io/jans/configapi/test/health/ApiHealthTest.java b/jans-config-api/server/src/test/java/io/jans/configapi/test/health/ApiHealthTest.java new file mode 100644 index 00000000000..a90d09f1022 --- /dev/null +++ b/jans-config-api/server/src/test/java/io/jans/configapi/test/health/ApiHealthTest.java @@ -0,0 +1,77 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.test.health; + +import io.jans.configapi.ConfigServerBaseTest; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Parameters; + +public class ApiHealthTest extends ConfigServerBaseTest { + + @Parameters({ "issuer", "healthUrl" }) + @Test + public void getHealthResponse(final String issuer, final String healthUrl) { + log.info("accessToken:{}, issuer:{}, healthUrl:{}", accessToken, issuer, healthUrl); + Builder request = getResteasyService().getClientBuilder(issuer + healthUrl); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getHealthResponse - response:{}", response); + } + + @Parameters({ "issuer", "healthUrl" }) + @Test + public void getServerStat(final String issuer, final String healthUrl) { + log.info("accessToken:{}, issuer:{}, healthUrl:{}", accessToken, issuer, healthUrl); + + Builder request = getResteasyService().getClientBuilder(issuer + healthUrl + "/server-stat"); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getServerStat - response:{}", response); + } + + @Parameters({ "issuer", "healthUrl" }) + @Test + public void getApplicationVersion(final String issuer, final String healthUrl) { + log.info("accessToken:{}, issuer:{}, healthUrl:{}", accessToken, issuer, healthUrl); + + Builder request = getResteasyService().getClientBuilder(issuer + healthUrl + "/app-version"); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getApplicationVersion - response:{}", response); + } + + @Parameters({ "issuer", "healthUrl" }) + @Test + public void getServiceStatus(final String issuer, final String healthUrl) { + log.info("accessToken:{}, issuer:{}, healthUrl:{}", accessToken, issuer, healthUrl); + + Builder request = getResteasyService().getClientBuilder(issuer + healthUrl + "/service-status"); + request.header(AUTHORIZATION, AUTHORIZATION_TYPE + " " + accessToken); + request.header(CONTENT_TYPE, MediaType.APPLICATION_JSON); + + Response response = request.get(); + assertEquals(response.getStatus(), Status.OK.getStatusCode()); + log.info("Response for getServiceStatus - response:{}", response); + } +} diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/clients.feature b/jans-config-api/server/src/test/resources/feature/openid/clients/clients.feature deleted file mode 100644 index 9b8c32bdc5c..00000000000 --- a/jans-config-api/server/src/test/resources/feature/openid/clients/clients.feature +++ /dev/null @@ -1,141 +0,0 @@ - -Feature: Openid connect clients - - Background: - * def mainUrl = openidclients_url - -Scenario: Fetch all openid connect clients without bearer token -Given url mainUrl -When method GET -Then status 401 - - -Scenario: Fetch all openid connect clients -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response -#And assert response.length != null - - -Scenario: Fetch the first three openidconnect clients -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param limit = 3 -When method GET -Then status 200 -And print response -#And assert response.length == 3 - - -Scenario: Search openid connect clients given a serach pattern -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param limit = 1 -When method GET -Then status 200 -And print response -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param pattern = response.entries[0].displayName -And print 'pattern = '+pattern -When method GET -Then status 200 -And print response -#And assert response.length !=0 - -Scenario: Search openid connect clients given a serach pattern and pagination -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param pattern = 'test' -And param limit = 10 -And param startIndex = 1 -When method GET -Then status 200 -And print response - -Scenario: Get an openid connect client by inum(unexisting client) -Given url mainUrl + '/53553532727272772' -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 404 - - -Scenario: Get an openid connect client by inum -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -Given url mainUrl + '/' +response.entries[0].inum -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response - -@ignore -@CreateUpdateDelete -Scenario: Create new OpenId Connect Client -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And request read('client.json') -When method POST -Then status 201 -And print response -Then def result = response -Then set result.entries[0].displayName = 'UpdatedQAAddedClient' -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And request result -When method PUT -Then status 200 -And print response -And assert response.entries[0]displayName == 'UpdatedQAAddedClient' -Given url mainUrl + '/' +response.entries[0].inum -And header Authorization = 'Bearer ' + accessToken -When method DELETE -Then status 204 -And print response - - -Scenario: Delete a non-existion openid connect client by inum -Given url mainUrl + '/1402.66633-8675-473e-a749' -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 404 -And print response - -@ignore -Scenario: Patch openid connect client -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param limit = 1 -When method GET -Then status 200 -And print response -Given url mainUrl + '/' +response.entries[0].inum -And header Authorization = 'Bearer ' + accessToken -And header Content-Type = 'application/json-patch+json' -And header Accept = 'application/json' -And def newName = response.entries[0].displayName -And print " newName = "+newName -#And request "[ {\"op\":\"replace\", \"path\": \"/displayName\", \"value\":\""+newName+"\"} ]" -And def request_body = (response.entries[0].displayName == null ? "[ {\"op\":\"add\", \"path\": \"/displayName\", \"value\":null } ]" : "[ {\"op\":\"replace\", \"path\": \"/displayName\", \"value\":"+response.displayName+" } ]") -And print 'request_body ='+request_body -And request request_body -When method PATCH -Then status 200 -And print response -#And assert response.length !=0 - -@ignore -@CreateUpdateDelete -Scenario: Create new OpenId Connect Client -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And request read('openid_clients_create.json') -When method POST -Then status 201 -And print response - - diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/custom-attribute.feature b/jans-config-api/server/src/test/resources/feature/openid/clients/custom-attribute.feature deleted file mode 100644 index 5a42b98b8c7..00000000000 --- a/jans-config-api/server/src/test/resources/feature/openid/clients/custom-attribute.feature +++ /dev/null @@ -1,43 +0,0 @@ -@ignore -Feature: Openid connect clients to test Custom Attribute for Client Claim Management - -Background: -* def mainUrl = openidclients_url -* def customAttributes_url = attributes_url - - -Scenario: Connect Client with CustomAttribute Testing for Client Claim Management -#Check if custom attribute is present -Given url customAttributes_url -And header Authorization = 'Bearer ' + accessToken -And param pattern = 'customTest' -And param limit = 1 -When method GET -Then status 200 -And print response -Then print response[0].name -Then assert responseStatus == 200 -And eval if( response.length == 0 ||response[0].name != 'customTest' ) karate.abort() -# Create Client with CustomAttribute -Given url openidclients_url -And header Authorization = 'Bearer ' + accessToken -And request read('openid-client.json') -When method POST -Then status 201 -And print response -And print response.inum -# Patch OpenId Connect Client with CustomAttribute -Given url openidclients_url + '/' +response.inum -And header Authorization = 'Bearer ' + accessToken -And header Content-Type = 'application/json-patch+json' -And header Accept = 'application/json' -And request read('client_custom_attribute_patch.json') -When method PATCH -Then status 200 -And print response -# Delete OpenId Connect Client with CustomAttribute -Given url openidclients_url + '/' +response.inum -And header Authorization = 'Bearer ' + accessToken -When method DELETE -Then status 204 - diff --git a/jans-config-api/server/src/test/resources/feature/openid/scopes/generic_scopes.feature b/jans-config-api/server/src/test/resources/feature/openid/scopes/generic_scopes.feature deleted file mode 100644 index 21606bc4204..00000000000 --- a/jans-config-api/server/src/test/resources/feature/openid/scopes/generic_scopes.feature +++ /dev/null @@ -1,87 +0,0 @@ -@ignore -Feature: Scopes - -Scenario: Fetch all scopes without bearer token -Given url scopes_url -When method GET -Then status 401 - -Scenario: Fetch all scopes -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response -And assert response.length != null - -Scenario: Fetch all scopes -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response -And assert response.length != null - -Scenario: Fetch the first three scopes -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -And param limit = 3 -When method GET -Then status 200 -And print response -And assert response.length == 3 - -Scenario: Search scopes given a serach pattern -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -And param pattern = 'View' -When method GET -Then status 200 -And print response - -@CreateUpdateDelete -Scenario: Create new Scope -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -And request read('classpath:scope.json') -When method POST -Then status 201 -Then def result = response -Then set result.displayName = 'UpdatedQAAddedScope' -Then def inum_before = result.inum -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -And request result -When method PUT -Then status 200 -And assert response.displayName == 'UpdatedQAAddedScope' -And assert response.inum == inum_before -Given url scopes_url + '/' +response.inum -And header Authorization = 'Bearer ' + accessToken -When method DELETE -Then status 204 - -Scenario: Delete a non-existing scope by inum -Given url scopes_url + '/1402.66633-8675-473e-a749' -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 404 - - -Scenario: Get an scope by inum(unexisting scope) -Given url scopes_url + '/53553532727272772' -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 404 -And print response - -Scenario: Get an scopes by inum -Given url scopes_url -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -Given url scopes_url + '/' +response[0].inum -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 - diff --git a/jans-config-api/server/src/test/resources/feature/openid/scopes/scopes-all.json b/jans-config-api/server/src/test/resources/feature/openid/scopes/scopes-all.json deleted file mode 100644 index 777a31d7d45..00000000000 --- a/jans-config-api/server/src/test/resources/feature/openid/scopes/scopes-all.json +++ /dev/null @@ -1,809 +0,0 @@ -{ - "start": 0, - "totalEntriesCount": 79, - "entriesCount": 50, - "entries": [ - { - "dn": "inum=F0C4,ou=scopes,o=jans", - "inum": "F0C4", - "displayName": "authenticate_openid_connect", - "id": "openid", - "description": "Authenticate using OpenID Connect.", - "scopeType": "openid", - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=F0C4,ou=scopes,o=jans" - }, - { - "dn": "inum=43F1,ou=scopes,o=jans", - "inum": "43F1", - "displayName": "view_profile", - "id": "profile", - "description": "View your basic profile info.", - "scopeType": "openid", - "claims": [ - "inum=2B29,ou=attributes,o=jans", - "inum=0C85,ou=attributes,o=jans", - "inum=B4B0,ou=attributes,o=jans", - "inum=A0E8,ou=attributes,o=jans", - "inum=5EC6,ou=attributes,o=jans", - "inum=B52A,ou=attributes,o=jans", - "inum=64A0,ou=attributes,o=jans", - "inum=EC3A,ou=attributes,o=jans", - "inum=3B47,ou=attributes,o=jans", - "inum=3692,ou=attributes,o=jans", - "inum=98FC,ou=attributes,o=jans", - "inum=A901,ou=attributes,o=jans", - "inum=36D9,ou=attributes,o=jans", - "inum=BE64,ou=attributes,o=jans", - "inum=6493,ou=attributes,o=jans", - "inum=4CF1,ou=attributes,o=jans", - "inum=29DA,ou=attributes,o=jans" - ], - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=43F1,ou=scopes,o=jans" - }, - { - "dn": "inum=764C,ou=scopes,o=jans", - "inum": "764C", - "displayName": "view_email_address", - "id": "email", - "description": "View your email address.", - "scopeType": "openid", - "claims": [ - "inum=8F88,ou=attributes,o=jans", - "inum=CAE3,ou=attributes,o=jans" - ], - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=764C,ou=scopes,o=jans" - }, - { - "dn": "inum=C17A,ou=scopes,o=jans", - "inum": "C17A", - "displayName": "view_address", - "id": "address", - "description": "View your address.", - "scopeType": "openid", - "claims": [ - "inum=27DB,ou=attributes,o=jans", - "inum=2A3D,ou=attributes,o=jans", - "inum=6609,ou=attributes,o=jans", - "inum=6EEB,ou=attributes,o=jans", - "inum=BCE8,ou=attributes,o=jans", - "inum=D90B,ou=attributes,o=jans", - "inum=E6B8,ou=attributes,o=jans", - "inum=E999,ou=attributes,o=jans" - ], - "defaultScope": true, - "groupClaims": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=C17A,ou=scopes,o=jans" - }, - { - "dn": "inum=D491,ou=scopes,o=jans", - "inum": "D491", - "displayName": "view_phone_number", - "id": "phone", - "description": "View your phone number.", - "scopeType": "openid", - "claims": [ - "inum=B17A,ou=attributes,o=jans", - "inum=0C18,ou=attributes,o=jans" - ], - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=D491,ou=scopes,o=jans" - }, - { - "dn": "inum=341A,ou=scopes,o=jans", - "inum": "341A", - "displayName": "view_client", - "id": "clientinfo", - "description": "View the client info.", - "scopeType": "openid", - "claims": [ - "inum=2B29,ou=attributes,o=jans", - "inum=29DA,ou=attributes,o=jans", - "inum=18CF,ou=attributes,o=jans", - "inum=18CC,ou=attributes,o=jans", - "inum=18CD,ou=attributes,o=jans", - "inum=18CE,ou=attributes,o=jans" - ], - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=341A,ou=scopes,o=jans" - }, - { - "dn": "inum=10B2,ou=scopes,o=jans", - "inum": "10B2", - "displayName": "view_username", - "id": "user_name", - "description": "View your local username in the Janssen Server.", - "scopeType": "openid", - "claims": [ - "inum=42E0,ou=attributes,o=jans" - ], - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=10B2,ou=scopes,o=jans" - }, - { - "dn": "inum=6D99,ou=scopes,o=jans", - "inum": "6D99", - "displayName": "UMA Protection", - "id": "uma_protection", - "description": "Obtain UMA PAT.", - "scopeType": "openid", - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=6D99,ou=scopes,o=jans" - }, - { - "dn": "inum=7D90,ou=scopes,o=jans", - "inum": "7D90", - "displayName": "revoke_session", - "id": "revoke_session", - "description": "revoke_session scope which is required to be able call /revoke_session endpoint", - "scopeType": "openid", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=7D90,ou=scopes,o=jans" - }, - { - "dn": "inum=8A01,ou=scopes,o=jans", - "inum": "8A01", - "displayName": "view_mobile_phone_number", - "id": "mobile_phone", - "description": "View your mobile phone number.", - "scopeType": "openid", - "claims": [ - "inum=6DA6,ou=attributes,o=jans" - ], - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=8A01,ou=scopes,o=jans" - }, - { - "dn": "inum=C4F5,ou=scopes,o=jans", - "inum": "C4F5", - "displayName": "view_user_permissions_roles", - "id": "permission", - "description": "View your user permission and roles.", - "scopeType": "dynamic", - "defaultScope": true, - "dynamicScopeScripts": [ - "inum=CB5B-3211,ou=scripts,o=jans" - ], - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=C4F5,ou=scopes,o=jans" - }, - { - "dn": "inum=C4F6,ou=scopes,o=jans", - "inum": "C4F6", - "displayName": "refresh_token", - "id": "offline_access", - "description": "This scope value requests that an OAuth 2.0 Refresh Token be issued.", - "scopeType": "openid", - "defaultScope": true, - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=C4F6,ou=scopes,o=jans" - }, - { - "dn": "inum=C4F7,ou=scopes,o=jans", - "inum": "C4F7", - "id": "jans_stat", - "description": "This scope is required for calling Statistic Endpoint", - "scopeType": "openid", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=C4F7,ou=scopes,o=jans" - }, - { - "dn": "inum=1200.487800,ou=scopes,o=jans", - "inum": "1200.487800", - "displayName": "Scim users.read", - "id": "https://jans.io/scim/users.read", - "description": "Query user resources", - "scopeType": "oauth", - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=1200.487800,ou=scopes,o=jans" - }, - { - "dn": "inum=1200.9CEE5C,ou=scopes,o=jans", - "inum": "1200.9CEE5C", - "displayName": "Scim users.write", - "id": "https://jans.io/scim/users.write", - "description": "Modify user resources", - "scopeType": "oauth", - "attributes": { - "showInConfigurationEndpoint": true - }, - "creationDate": "2022-10-27T20:51:17", - "umaType": false, - "baseDn": "inum=1200.9CEE5C,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.FFE5C0,ou=scopes,o=jans", - "inum": "1800.FFE5C0", - "displayName": "Config API scope https://jans.io/oauth/jans-auth-server/config/properties.readonly", - "id": "https://jans.io/oauth/jans-auth-server/config/properties.readonly", - "description": "View Auth Server properties related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.FFE5C0,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.472951,ou=scopes,o=jans", - "inum": "1800.472951", - "displayName": "Config API scope https://jans.io/oauth/jans-auth-server/config/properties.write", - "id": "https://jans.io/oauth/jans-auth-server/config/properties.write", - "description": "Manage Auth Server properties related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.472951,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.556F45,ou=scopes,o=jans", - "inum": "1800.556F45", - "displayName": "Config API scope https://jans.io/oauth/config/fido2.readonly", - "id": "https://jans.io/oauth/config/fido2.readonly", - "description": "View FIDO2 related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.556F45,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.77FB4F,ou=scopes,o=jans", - "inum": "1800.77FB4F", - "displayName": "Config API scope https://jans.io/oauth/config/fido2.write", - "id": "https://jans.io/oauth/config/fido2.write", - "description": "Manage FIDO2 related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.77FB4F,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.AA8DFE,ou=scopes,o=jans", - "inum": "1800.AA8DFE", - "displayName": "Config API scope https://jans.io/oauth/config/attributes.readonly", - "id": "https://jans.io/oauth/config/attributes.readonly", - "description": "View attribute related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.AA8DFE,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.CD5B72,ou=scopes,o=jans", - "inum": "1800.CD5B72", - "displayName": "Config API scope https://jans.io/oauth/config/attributes.write", - "id": "https://jans.io/oauth/config/attributes.write", - "description": "Manage attribute related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.CD5B72,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.CBCF52,ou=scopes,o=jans", - "inum": "1800.CBCF52", - "displayName": "Config API scope https://jans.io/oauth/config/attributes.delete", - "id": "https://jans.io/oauth/config/attributes.delete", - "description": "Delete attribute related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.CBCF52,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.12284F,ou=scopes,o=jans", - "inum": "1800.12284F", - "displayName": "Config API scope https://jans.io/oauth/config/acrs.readonly", - "id": "https://jans.io/oauth/config/acrs.readonly", - "description": "View ACRS related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.12284F,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.141B26,ou=scopes,o=jans", - "inum": "1800.141B26", - "displayName": "Config API scope https://jans.io/oauth/config/acrs.write", - "id": "https://jans.io/oauth/config/acrs.write", - "description": "Manage ACRS related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.141B26,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.A018AC,ou=scopes,o=jans", - "inum": "1800.A018AC", - "displayName": "Config API scope https://jans.io/oauth/config/database/ldap.readonly", - "id": "https://jans.io/oauth/config/database/ldap.readonly", - "description": "View LDAP database related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.A018AC,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.6E4456,ou=scopes,o=jans", - "inum": "1800.6E4456", - "displayName": "Config API scope https://jans.io/oauth/config/database/ldap.write", - "id": "https://jans.io/oauth/config/database/ldap.write", - "description": "Manage LDAP database related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.6E4456,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.55499D,ou=scopes,o=jans", - "inum": "1800.55499D", - "displayName": "Config API scope https://jans.io/oauth/config/database/ldap.delete", - "id": "https://jans.io/oauth/config/database/ldap.delete", - "description": "Delete LDAP database related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.55499D,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.E730AA,ou=scopes,o=jans", - "inum": "1800.E730AA", - "displayName": "Config API scope https://jans.io/oauth/config/scripts.readonly", - "id": "https://jans.io/oauth/config/scripts.readonly", - "description": "View cache scripts information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.E730AA,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.097318,ou=scopes,o=jans", - "inum": "1800.097318", - "displayName": "Config API scope https://jans.io/oauth/config/scripts.write", - "id": "https://jans.io/oauth/config/scripts.write", - "description": "Manage scripts related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.097318,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.04CF24,ou=scopes,o=jans", - "inum": "1800.04CF24", - "displayName": "Config API scope https://jans.io/oauth/config/scripts.delete", - "id": "https://jans.io/oauth/config/scripts.delete", - "description": "Delete scripts related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.04CF24,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.F963F9,ou=scopes,o=jans", - "inum": "1800.F963F9", - "displayName": "Config API scope https://jans.io/oauth/config/cache.readonly", - "id": "https://jans.io/oauth/config/cache.readonly", - "description": "View cache related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.F963F9,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.31F580,ou=scopes,o=jans", - "inum": "1800.31F580", - "displayName": "Config API scope https://jans.io/oauth/config/cache.write", - "id": "https://jans.io/oauth/config/cache.write", - "description": "Manage cache related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.31F580,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.E512E3,ou=scopes,o=jans", - "inum": "1800.E512E3", - "displayName": "Config API scope https://jans.io/oauth/config/smtp.readonly", - "id": "https://jans.io/oauth/config/smtp.readonly", - "description": "View SMTP related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.E512E3,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.E65DC6,ou=scopes,o=jans", - "inum": "1800.E65DC6", - "displayName": "Config API scope https://jans.io/oauth/config/smtp.write", - "id": "https://jans.io/oauth/config/smtp.write", - "description": "Manage SMTP related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.E65DC6,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.3C1F46,ou=scopes,o=jans", - "inum": "1800.3C1F46", - "displayName": "Config API scope https://jans.io/oauth/config/smtp.delete", - "id": "https://jans.io/oauth/config/smtp.delete", - "description": "Delete SMTP related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.3C1F46,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.20D48C,ou=scopes,o=jans", - "inum": "1800.20D48C", - "displayName": "Config API scope https://jans.io/oauth/config/logging.readonly", - "id": "https://jans.io/oauth/config/logging.readonly", - "description": "View logging related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.20D48C,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.4601AA,ou=scopes,o=jans", - "inum": "1800.4601AA", - "displayName": "Config API scope https://jans.io/oauth/config/logging.write", - "id": "https://jans.io/oauth/config/logging.write", - "description": "Manage logging related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.4601AA,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.A9B842,ou=scopes,o=jans", - "inum": "1800.A9B842", - "displayName": "Config API scope https://jans.io/oauth/config/jwks.readonly", - "id": "https://jans.io/oauth/config/jwks.readonly", - "description": "View JWKS related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.A9B842,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.864485,ou=scopes,o=jans", - "inum": "1800.864485", - "displayName": "Config API scope https://jans.io/oauth/config/jwks.write", - "id": "https://jans.io/oauth/config/jwks.write", - "description": "Manage JWKS related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.864485,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.F0B654,ou=scopes,o=jans", - "inum": "1800.F0B654", - "displayName": "Config API scope https://jans.io/oauth/config/jwks.delete", - "id": "https://jans.io/oauth/config/jwks.delete", - "description": "Delete JWKS related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.F0B654,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.45F1D7,ou=scopes,o=jans", - "inum": "1800.45F1D7", - "displayName": "Config API scope https://jans.io/oauth/config/openid/clients.readonly", - "id": "https://jans.io/oauth/config/openid/clients.readonly", - "description": "View clients related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.45F1D7,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.B78FA5,ou=scopes,o=jans", - "inum": "1800.B78FA5", - "displayName": "Config API scope https://jans.io/oauth/config/openid/clients.write", - "id": "https://jans.io/oauth/config/openid/clients.write", - "description": "Manage clients related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.B78FA5,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.E3D7E0,ou=scopes,o=jans", - "inum": "1800.E3D7E0", - "displayName": "Config API scope https://jans.io/oauth/config/openid/clients.delete", - "id": "https://jans.io/oauth/config/openid/clients.delete", - "description": "Delete clients related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.E3D7E0,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.E212DC,ou=scopes,o=jans", - "inum": "1800.E212DC", - "displayName": "Config API scope https://jans.io/oauth/config/scopes.readonly", - "id": "https://jans.io/oauth/config/scopes.readonly", - "description": "View scope related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.E212DC,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.94F80F,ou=scopes,o=jans", - "inum": "1800.94F80F", - "displayName": "Config API scope https://jans.io/oauth/config/scopes.write", - "id": "https://jans.io/oauth/config/scopes.write", - "description": "Manage scope related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.94F80F,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.9F96F3,ou=scopes,o=jans", - "inum": "1800.9F96F3", - "displayName": "Config API scope https://jans.io/oauth/config/scopes.delete", - "id": "https://jans.io/oauth/config/scopes.delete", - "description": "Delete scope related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.9F96F3,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.CB50EC,ou=scopes,o=jans", - "inum": "1800.CB50EC", - "displayName": "Config API scope https://jans.io/oauth/config/uma/resources.readonly", - "id": "https://jans.io/oauth/config/uma/resources.readonly", - "description": "View UMA Resource related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.CB50EC,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.1CA946,ou=scopes,o=jans", - "inum": "1800.1CA946", - "displayName": "Config API scope https://jans.io/oauth/config/uma/resources.write", - "id": "https://jans.io/oauth/config/uma/resources.write", - "description": "Manage UMA Resource related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:27", - "umaType": false, - "baseDn": "inum=1800.1CA946,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.18231E,ou=scopes,o=jans", - "inum": "1800.18231E", - "displayName": "Config API scope https://jans.io/oauth/config/uma/resources.delete", - "id": "https://jans.io/oauth/config/uma/resources.delete", - "description": "Delete UMA Resource related information", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:28", - "umaType": false, - "baseDn": "inum=1800.18231E,ou=scopes,o=jans" - }, - { - "dn": "inum=1800.C25D78,ou=scopes,o=jans", - "inum": "1800.C25D78", - "displayName": "Config API scope https://jans.io/oauth/config/stats.readonly", - "id": "https://jans.io/oauth/config/stats.readonly", - "description": "Vew server with basic statistic", - "scopeType": "oauth", - "defaultScope": false, - "attributes": { - "showInConfigurationEndpoint": false - }, - "creationDate": "2022-10-24T14:55:28", - "umaType": false, - "baseDn": "inum=1800.C25D78,ou=scopes,o=jans" - } - ] -} \ No newline at end of file diff --git a/jans-config-api/server/src/test/resources/feature/openid/scopes/scopes.feature b/jans-config-api/server/src/test/resources/feature/openid/scopes/scopes.feature deleted file mode 100644 index cc93861fea4..00000000000 --- a/jans-config-api/server/src/test/resources/feature/openid/scopes/scopes.feature +++ /dev/null @@ -1,132 +0,0 @@ - -Feature: Openid connect Scopes - -Background: -* def mainUrl = scopes_url - -Scenario: Fetch all openid connect scopes without bearer token -Given url mainUrl -When method GET -Then status 401 - - -Scenario: Fetch all scopes -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response -And assert response.length != null - - -Scenario: Fetch all openid connect scopes -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param type = 'openid' -When method GET -Then status 200 -And print response -And assert response.length != null - - -Scenario: Fetch the first three openidconnect scopes -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param type = 'openid' -And param limit = 3 -When method GET -Then status 200 -And print response -#And assert response.length == 3 - - -Scenario: Search openid connect scopes given a serach pattern -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And param type = 'openid' -And param pattern = 'openid' -When method GET -Then status 200 -And print response -#And assert response.length == 1 - -Scenario: Fetch scopes based on creator -Given url mainUrl + '/creator/abc' -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response - -Scenario: Fetch scopes based on type -Given url mainUrl + '/type/uma' -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response - - -@CreateUpdateDelete -Scenario: Create new OpenId Connect Scope -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And request read('scope.json') -When method POST -Then status 201 -And print response -Then def result = response -Then set result.displayName = 'UpdatedQAAddedScope' -Then def inum_before = result.inum -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -And request result -When method PUT -Then status 200 -And print response -And assert response.displayName == 'UpdatedQAAddedScope' -And assert response.inum == inum_before -Given url mainUrl + '/' +response.inum -And header Authorization = 'Bearer ' + accessToken -And header Content-Type = 'application/json-patch+json' -And header Accept = 'application/json' -And def newDisplayName = response.displayName -And print " newDisplayName = "+newDisplayName -And request "[ {\"op\":\"replace\", \"path\": \"/displayName\", \"value\":\""+newDisplayName+"\"} ]" -When method PATCH -Then status 200 -And print response -And assert response.length !=0 -Given url mainUrl + '/' +response.inum -And header Authorization = 'Bearer ' + accessToken -When method DELETE -Then status 204 - - -Scenario: Delete a non-existing openid connect scope by inum -Given url mainUrl + '/1402.66633-8675-473e-a749' -And header Authorization = 'Bearer ' + accessToken -And param type = 'openid' -When method GET -Then status 404 -And print response - - -Scenario: Get an openid connect scope by inum(unexisting scope) -Given url mainUrl + '/53553532727272772' -And header Authorization = 'Bearer ' + accessToken -And param type = 'openid' -When method GET -Then status 404 -And print response - - -Scenario: Get an openid connect scopes by inum -Given url mainUrl -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response -Given url mainUrl + '/' +response.entries[0].inum -And header Authorization = 'Bearer ' + accessToken -When method GET -Then status 200 -And print response diff --git a/jans-config-api/server/src/test/resources/feature/defaultAcr/defaultAcr.feature b/jans-config-api/server/src/test/resources/json/acr/defaultAcr.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/defaultAcr/defaultAcr.feature rename to jans-config-api/server/src/test/resources/json/acr/defaultAcr.feature diff --git a/jans-config-api/server/src/test/resources/feature/defaultAcr/defaultAcr.json b/jans-config-api/server/src/test/resources/json/acr/defaultAcr.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/defaultAcr/defaultAcr.json rename to jans-config-api/server/src/test/resources/json/acr/defaultAcr.json diff --git a/jans-config-api/server/src/test/resources/feature/agama/agama-deployment.feature b/jans-config-api/server/src/test/resources/json/agama/agama-deployment.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/agama/agama-deployment.feature rename to jans-config-api/server/src/test/resources/json/agama/agama-deployment.feature diff --git a/jans-config-api/server/src/test/resources/feature/agama/agama-source.txt b/jans-config-api/server/src/test/resources/json/agama/agama-source.txt similarity index 100% rename from jans-config-api/server/src/test/resources/feature/agama/agama-source.txt rename to jans-config-api/server/src/test/resources/json/agama/agama-source.txt diff --git a/jans-config-api/server/src/test/resources/feature/agama/agama.feature b/jans-config-api/server/src/test/resources/json/agama/agama.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/agama/agama.feature rename to jans-config-api/server/src/test/resources/json/agama/agama.feature diff --git a/jans-config-api/server/src/test/resources/feature/agama/agama.json b/jans-config-api/server/src/test/resources/json/agama/agama.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/agama/agama.json rename to jans-config-api/server/src/test/resources/json/agama/agama.json diff --git a/jans-config-api/server/src/test/resources/feature/agama/agama1.json b/jans-config-api/server/src/test/resources/json/agama/agama1.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/agama/agama1.json rename to jans-config-api/server/src/test/resources/json/agama/agama1.json diff --git a/jans-config-api/server/src/test/resources/feature/attribute/attribute-for-patch.json b/jans-config-api/server/src/test/resources/json/attribute/attribute-for-patch.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/attribute/attribute-for-patch.json rename to jans-config-api/server/src/test/resources/json/attribute/attribute-for-patch.json diff --git a/jans-config-api/server/src/test/resources/feature/attribute/attribute.json b/jans-config-api/server/src/test/resources/json/attribute/attribute.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/attribute/attribute.json rename to jans-config-api/server/src/test/resources/json/attribute/attribute.json diff --git a/jans-config-api/server/src/test/resources/feature/attribute/attributes.feature b/jans-config-api/server/src/test/resources/json/attribute/attributes.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/attribute/attributes.feature rename to jans-config-api/server/src/test/resources/json/attribute/attributes.feature diff --git a/jans-config-api/server/src/test/resources/feature/client-auth/client-auth.feature b/jans-config-api/server/src/test/resources/json/client-auth/client-auth.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/client-auth/client-auth.feature rename to jans-config-api/server/src/test/resources/json/client-auth/client-auth.feature diff --git a/jans-config-api/server/src/test/resources/json/config/api/api-config-patch.json b/jans-config-api/server/src/test/resources/json/config/api/api-config-patch.json new file mode 100644 index 00000000000..d44e2e1292a --- /dev/null +++ b/jans-config-api/server/src/test/resources/json/config/api/api-config-patch.json @@ -0,0 +1,5 @@ +[{ + "op": "replace", + "path": "/loggingLevel", + "value": "DEBUG" +}] diff --git a/jans-config-api/server/src/test/resources/feature/config/api/properties.feature b/jans-config-api/server/src/test/resources/json/config/api/properties.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/api/properties.feature rename to jans-config-api/server/src/test/resources/json/config/api/properties.feature diff --git a/jans-config-api/server/src/test/resources/json/config/auth/auth-config-patch.json b/jans-config-api/server/src/test/resources/json/config/auth/auth-config-patch.json new file mode 100644 index 00000000000..d44e2e1292a --- /dev/null +++ b/jans-config-api/server/src/test/resources/json/config/auth/auth-config-patch.json @@ -0,0 +1,5 @@ +[{ + "op": "replace", + "path": "/loggingLevel", + "value": "DEBUG" +}] diff --git a/jans-config-api/server/src/test/resources/feature/config/cache/cache.feature b/jans-config-api/server/src/test/resources/json/config/cache/cache.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/cache/cache.feature rename to jans-config-api/server/src/test/resources/json/config/cache/cache.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/database/ldap/get-ldap-config.feature b/jans-config-api/server/src/test/resources/json/config/database/ldap/get-ldap-config.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/database/ldap/get-ldap-config.feature rename to jans-config-api/server/src/test/resources/json/config/database/ldap/get-ldap-config.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/database/ldap/ldap.feature b/jans-config-api/server/src/test/resources/json/config/database/ldap/ldap.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/database/ldap/ldap.feature rename to jans-config-api/server/src/test/resources/json/config/database/ldap/ldap.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/database/ldap/ldap.json b/jans-config-api/server/src/test/resources/json/config/database/ldap/ldap.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/database/ldap/ldap.json rename to jans-config-api/server/src/test/resources/json/config/database/ldap/ldap.json diff --git a/jans-config-api/server/src/test/resources/feature/config/database/ldap/ldap_list.json b/jans-config-api/server/src/test/resources/json/config/database/ldap/ldap_list.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/database/ldap/ldap_list.json rename to jans-config-api/server/src/test/resources/json/config/database/ldap/ldap_list.json diff --git a/jans-config-api/server/src/test/resources/feature/config/jwks/jwk_key.json b/jans-config-api/server/src/test/resources/json/config/jwks/jwk_key.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/jwks/jwk_key.json rename to jans-config-api/server/src/test/resources/json/config/jwks/jwk_key.json diff --git a/jans-config-api/server/src/test/resources/feature/config/jwks/jwks-all.json b/jans-config-api/server/src/test/resources/json/config/jwks/jwks-all.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/jwks/jwks-all.json rename to jans-config-api/server/src/test/resources/json/config/jwks/jwks-all.json diff --git a/jans-config-api/server/src/test/resources/feature/config/jwks/jwks.feature b/jans-config-api/server/src/test/resources/json/config/jwks/jwks.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/jwks/jwks.feature rename to jans-config-api/server/src/test/resources/json/config/jwks/jwks.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/jwks/jwks.json b/jans-config-api/server/src/test/resources/json/config/jwks/jwks.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/jwks/jwks.json rename to jans-config-api/server/src/test/resources/json/config/jwks/jwks.json diff --git a/jans-config-api/server/src/test/resources/feature/config/jwks/jwks_patch.json b/jans-config-api/server/src/test/resources/json/config/jwks/jwks_patch.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/jwks/jwks_patch.json rename to jans-config-api/server/src/test/resources/json/config/jwks/jwks_patch.json diff --git a/jans-config-api/server/src/test/resources/feature/config/message/message.feature b/jans-config-api/server/src/test/resources/json/config/message/message.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/message/message.feature rename to jans-config-api/server/src/test/resources/json/config/message/message.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/org/org-config.feature b/jans-config-api/server/src/test/resources/json/config/org/org-config.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/org/org-config.feature rename to jans-config-api/server/src/test/resources/json/config/org/org-config.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/authenticationFilters.json b/jans-config-api/server/src/test/resources/json/config/properties/authenticationFilters.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/authenticationFilters.json rename to jans-config-api/server/src/test/resources/json/config/properties/authenticationFilters.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/backchannel/backchannel.feature b/jans-config-api/server/src/test/resources/json/config/properties/backchannel/backchannel.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/backchannel/backchannel.feature rename to jans-config-api/server/src/test/resources/json/config/properties/backchannel/backchannel.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/ciba/ciba.feature b/jans-config-api/server/src/test/resources/json/config/properties/ciba/ciba.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/ciba/ciba.feature rename to jans-config-api/server/src/test/resources/json/config/properties/ciba/ciba.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/ciba/ciba.json b/jans-config-api/server/src/test/resources/json/config/properties/ciba/ciba.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/ciba/ciba.json rename to jans-config-api/server/src/test/resources/json/config/properties/ciba/ciba.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/clientAuthenticationFilters.json b/jans-config-api/server/src/test/resources/json/config/properties/clientAuthenticationFilters.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/clientAuthenticationFilters.json rename to jans-config-api/server/src/test/resources/json/config/properties/clientAuthenticationFilters.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/cors/cors.feature b/jans-config-api/server/src/test/resources/json/config/properties/cors/cors.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/cors/cors.feature rename to jans-config-api/server/src/test/resources/json/config/properties/cors/cors.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/cors/cors.json b/jans-config-api/server/src/test/resources/json/config/properties/cors/cors.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/cors/cors.json rename to jans-config-api/server/src/test/resources/json/config/properties/cors/cors.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/custom.json b/jans-config-api/server/src/test/resources/json/config/properties/custom.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/custom.json rename to jans-config-api/server/src/test/resources/json/config/properties/custom.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/dynamic/registration/registration.feature b/jans-config-api/server/src/test/resources/json/config/properties/dynamic/registration/registration.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/dynamic/registration/registration.feature rename to jans-config-api/server/src/test/resources/json/config/properties/dynamic/registration/registration.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/dynamic/registration/registration.json b/jans-config-api/server/src/test/resources/json/config/properties/dynamic/registration/registration.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/dynamic/registration/registration.json rename to jans-config-api/server/src/test/resources/json/config/properties/dynamic/registration/registration.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/endpoints/endpoints.feature b/jans-config-api/server/src/test/resources/json/config/properties/endpoints/endpoints.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/endpoints/endpoints.feature rename to jans-config-api/server/src/test/resources/json/config/properties/endpoints/endpoints.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/endpoints/endpoints.json b/jans-config-api/server/src/test/resources/json/config/properties/endpoints/endpoints.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/endpoints/endpoints.json rename to jans-config-api/server/src/test/resources/json/config/properties/endpoints/endpoints.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/expiration/expiration.feature b/jans-config-api/server/src/test/resources/json/config/properties/expiration/expiration.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/expiration/expiration.feature rename to jans-config-api/server/src/test/resources/json/config/properties/expiration/expiration.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/expiration/expiration.json b/jans-config-api/server/src/test/resources/json/config/properties/expiration/expiration.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/expiration/expiration.json rename to jans-config-api/server/src/test/resources/json/config/properties/expiration/expiration.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/grant/grant.feature b/jans-config-api/server/src/test/resources/json/config/properties/grant/grant.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/grant/grant.feature rename to jans-config-api/server/src/test/resources/json/config/properties/grant/grant.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/grant/grant.json b/jans-config-api/server/src/test/resources/json/config/properties/grant/grant.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/grant/grant.json rename to jans-config-api/server/src/test/resources/json/config/properties/grant/grant.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/idToken/idToken.feature b/jans-config-api/server/src/test/resources/json/config/properties/idToken/idToken.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/idToken/idToken.feature rename to jans-config-api/server/src/test/resources/json/config/properties/idToken/idToken.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/idToken/idToken.json b/jans-config-api/server/src/test/resources/json/config/properties/idToken/idToken.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/idToken/idToken.json rename to jans-config-api/server/src/test/resources/json/config/properties/idToken/idToken.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/janssenpkcs/janssenpkcs.feature b/jans-config-api/server/src/test/resources/json/config/properties/janssenpkcs/janssenpkcs.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/janssenpkcs/janssenpkcs.feature rename to jans-config-api/server/src/test/resources/json/config/properties/janssenpkcs/janssenpkcs.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/keys/regen/regen.feature b/jans-config-api/server/src/test/resources/json/config/properties/keys/regen/regen.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/keys/regen/regen.feature rename to jans-config-api/server/src/test/resources/json/config/properties/keys/regen/regen.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/keys/regen/regen.json b/jans-config-api/server/src/test/resources/json/config/properties/keys/regen/regen.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/keys/regen/regen.json rename to jans-config-api/server/src/test/resources/json/config/properties/keys/regen/regen.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/metrics/metrics.feature b/jans-config-api/server/src/test/resources/json/config/properties/metrics/metrics.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/metrics/metrics.feature rename to jans-config-api/server/src/test/resources/json/config/properties/metrics/metrics.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/openid/config/config.feature b/jans-config-api/server/src/test/resources/json/config/properties/openid/config/config.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/openid/config/config.feature rename to jans-config-api/server/src/test/resources/json/config/properties/openid/config/config.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/openid/config/config.json b/jans-config-api/server/src/test/resources/json/config/properties/openid/config/config.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/openid/config/config.json rename to jans-config-api/server/src/test/resources/json/config/properties/openid/config/config.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/pairwise/pairwise.feature b/jans-config-api/server/src/test/resources/json/config/properties/pairwise/pairwise.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/pairwise/pairwise.feature rename to jans-config-api/server/src/test/resources/json/config/properties/pairwise/pairwise.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/properties.feature b/jans-config-api/server/src/test/resources/json/config/properties/properties.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/properties.feature rename to jans-config-api/server/src/test/resources/json/config/properties/properties.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/request/object.feature b/jans-config-api/server/src/test/resources/json/config/properties/request/object.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/request/object.feature rename to jans-config-api/server/src/test/resources/json/config/properties/request/object.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/response/modes/modes.feature b/jans-config-api/server/src/test/resources/json/config/properties/response/modes/modes.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/response/modes/modes.feature rename to jans-config-api/server/src/test/resources/json/config/properties/response/modes/modes.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/response/types/type.feature b/jans-config-api/server/src/test/resources/json/config/properties/response/types/type.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/response/types/type.feature rename to jans-config-api/server/src/test/resources/json/config/properties/response/types/type.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/server/cleanup.feature b/jans-config-api/server/src/test/resources/json/config/properties/server/cleanup.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/server/cleanup.feature rename to jans-config-api/server/src/test/resources/json/config/properties/server/cleanup.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/server/cleanup.json b/jans-config-api/server/src/test/resources/json/config/properties/server/cleanup.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/server/cleanup.json rename to jans-config-api/server/src/test/resources/json/config/properties/server/cleanup.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/server/config.feature b/jans-config-api/server/src/test/resources/json/config/properties/server/config.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/server/config.feature rename to jans-config-api/server/src/test/resources/json/config/properties/server/config.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/server/config.json b/jans-config-api/server/src/test/resources/json/config/properties/server/config.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/server/config.json rename to jans-config-api/server/src/test/resources/json/config/properties/server/config.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/server/session/sessionId.feature b/jans-config-api/server/src/test/resources/json/config/properties/server/session/sessionId.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/server/session/sessionId.feature rename to jans-config-api/server/src/test/resources/json/config/properties/server/session/sessionId.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/subject/subject.feature b/jans-config-api/server/src/test/resources/json/config/properties/subject/subject.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/subject/subject.feature rename to jans-config-api/server/src/test/resources/json/config/properties/subject/subject.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/subject/subject.json b/jans-config-api/server/src/test/resources/json/config/properties/subject/subject.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/subject/subject.json rename to jans-config-api/server/src/test/resources/json/config/properties/subject/subject.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/token/token.feature b/jans-config-api/server/src/test/resources/json/config/properties/token/token.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/token/token.feature rename to jans-config-api/server/src/test/resources/json/config/properties/token/token.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/token/token.json b/jans-config-api/server/src/test/resources/json/config/properties/token/token.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/token/token.json rename to jans-config-api/server/src/test/resources/json/config/properties/token/token.json diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/uma/configuration/configuration.feature b/jans-config-api/server/src/test/resources/json/config/properties/uma/configuration/configuration.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/uma/configuration/configuration.feature rename to jans-config-api/server/src/test/resources/json/config/properties/uma/configuration/configuration.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/properties/user/info/userInfo.feature b/jans-config-api/server/src/test/resources/json/config/properties/user/info/userInfo.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/properties/user/info/userInfo.feature rename to jans-config-api/server/src/test/resources/json/config/properties/user/info/userInfo.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/scripts/custom/generic/all-script.json b/jans-config-api/server/src/test/resources/json/config/scripts/custom/generic/all-script.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/scripts/custom/generic/all-script.json rename to jans-config-api/server/src/test/resources/json/config/scripts/custom/generic/all-script.json diff --git a/jans-config-api/server/src/test/resources/feature/config/scripts/custom/generic/custom.feature b/jans-config-api/server/src/test/resources/json/config/scripts/custom/generic/custom.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/scripts/custom/generic/custom.feature rename to jans-config-api/server/src/test/resources/json/config/scripts/custom/generic/custom.feature diff --git a/jans-config-api/server/src/test/resources/feature/config/scripts/custom/generic/post-script.json b/jans-config-api/server/src/test/resources/json/config/scripts/custom/generic/post-script.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/scripts/custom/generic/post-script.json rename to jans-config-api/server/src/test/resources/json/config/scripts/custom/generic/post-script.json diff --git a/jans-config-api/server/src/test/resources/feature/config/scripts/custom/persons/person-script.json b/jans-config-api/server/src/test/resources/json/config/scripts/custom/persons/person-script.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/scripts/custom/persons/person-script.json rename to jans-config-api/server/src/test/resources/json/config/scripts/custom/persons/person-script.json diff --git a/jans-config-api/server/src/test/resources/feature/config/scripts/custom/persons/person-scripts.feature b/jans-config-api/server/src/test/resources/json/config/scripts/custom/persons/person-scripts.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/config/scripts/custom/persons/person-scripts.feature rename to jans-config-api/server/src/test/resources/json/config/scripts/custom/persons/person-scripts.feature diff --git a/jans-config-api/server/src/test/resources/feature/health/auth-server-health.feature b/jans-config-api/server/src/test/resources/json/health/auth-server-health.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/health/auth-server-health.feature rename to jans-config-api/server/src/test/resources/json/health/auth-server-health.feature diff --git a/jans-config-api/server/src/test/resources/feature/health/config-api-health.feature b/jans-config-api/server/src/test/resources/json/health/config-api-health.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/health/config-api-health.feature rename to jans-config-api/server/src/test/resources/json/health/config-api-health.feature diff --git a/jans-config-api/server/src/test/resources/feature/health/server-health.feature b/jans-config-api/server/src/test/resources/json/health/server-health.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/health/server-health.feature rename to jans-config-api/server/src/test/resources/json/health/server-health.feature diff --git a/jans-config-api/server/src/test/resources/feature/logging/logging.feature b/jans-config-api/server/src/test/resources/json/logging/logging.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/logging/logging.feature rename to jans-config-api/server/src/test/resources/json/logging/logging.feature diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/admin-ui-client.json b/jans-config-api/server/src/test/resources/json/openid/clients/admin-ui-client.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/openid/clients/admin-ui-client.json rename to jans-config-api/server/src/test/resources/json/openid/clients/admin-ui-client.json diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/client.json b/jans-config-api/server/src/test/resources/json/openid/clients/client.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/openid/clients/client.json rename to jans-config-api/server/src/test/resources/json/openid/clients/client.json diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/client_custom_attribute_patch.json b/jans-config-api/server/src/test/resources/json/openid/clients/client_custom_attribute_patch.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/openid/clients/client_custom_attribute_patch.json rename to jans-config-api/server/src/test/resources/json/openid/clients/client_custom_attribute_patch.json diff --git a/jans-config-api/server/src/test/resources/json/openid/clients/openid-client-post.json b/jans-config-api/server/src/test/resources/json/openid/clients/openid-client-post.json new file mode 100644 index 00000000000..300d87d7dd2 --- /dev/null +++ b/jans-config-api/server/src/test/resources/json/openid/clients/openid-client-post.json @@ -0,0 +1,55 @@ +{ + "applicationType": "web", + "description":"Description for test client 2", + "customObjectClasses":["top"], + "accessTokenAsJwt": false, + "claimRedirectUris": [ + ], + "deletable": false, + "disabled": false, + "requireAuthTime": false, + "clientName": "test-client-2", + "clientSecret": "test1234", + "exp": "2130-09-28T23:00:00Z[UTC]", + "grantTypes": [ + "authorization_code", + "implicit", + "refresh_token", + "client_credentials", + "password" + ], + "responseTypes": ["code"], + "idTokenSignedResponseAlg": "RS256", + "accessTokenSigningAlg": "RS256", + "attributes": { + "tlsClientAuthSubjectDn":"", + "runIntrospectionScriptBeforeJwtCreation":false, + "keepClientAuthorizationAfterExpiration":false, + "allowSpontaneousScopes":false, + "spontaneousScopes":[],"spontaneousScopeScriptDns":[], + "backchannelLogoutUri":[],"backchannelLogoutSessionRequired":false, + "additionalAudience":[],"postAuthnScripts":[],"consentGatheringScripts":[], + "introspectionScripts":[],"rptClaimsScripts":[] + }, + "frontChannelLogoutSessionRequired": false, + "logoutUri": [ + ], + "persistClientAuthorizations": true, + "postLogoutRedirectUris": [ + ], + "redirectUris": [ + "http://localhost:8080" + ], + "scopes": [ + ], + "trustedClient": false, + "includeClaimsInIdToken": false, + "rptAsJwt": false, + "subjectType": "pairwise", + "tokenEndpointAuthMethod": "client_secret_basic", + "dynamicRegistrationCustomObjectClass": "MyDynamicRegistrationCustomObject", + "dynamicRegistrationCustomAttributes": [ + "jansTrustedClnt", + "myAttr1" + ] +} \ No newline at end of file diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/openid-client.json b/jans-config-api/server/src/test/resources/json/openid/clients/openid-client.json similarity index 87% rename from jans-config-api/server/src/test/resources/feature/openid/clients/openid-client.json rename to jans-config-api/server/src/test/resources/json/openid/clients/openid-client.json index 24da86ddd1f..5a05c79e704 100644 --- a/jans-config-api/server/src/test/resources/feature/openid/clients/openid-client.json +++ b/jans-config-api/server/src/test/resources/json/openid/clients/openid-client.json @@ -15,7 +15,7 @@ "spontaneousScopes": [] }, "claimRedirectURI": [ - "https://gluu.gasmyr.com/jans-auth/restv1/uma/gather_claims" + "https://gluu.server.com/jans-auth/restv1/uma/gather_claims" ], "deletable": false, "disabled": false, @@ -29,15 +29,15 @@ "idTokenSignedResponseAlg": "HS256", "logoutSessionRequired": true, "logoutUri": [ - "https://gluu.gasmyr.com/identity/ssologout.htm" + "https://gluu.server.com/identity/ssologout.htm" ], "jansAppTyp": "WEB", "jansPersistClntAuthzs": false, "jansPostLogoutRedirectURI": [ - "https://gluu.gasmyr.com/identity/finishlogout.htm" + "https://gluu.server.com/identity/finishlogout.htm" ], "jansRedirectURI": [ - "https://gluu.gasmyr.com/identity/uri1" + "https://gluu.server.com/identity/uri1" ], "jansScope": [ "inum=F0C4,ou=scopes,o=gluu" diff --git a/jans-config-api/server/src/test/resources/feature/openid/clients/openid_clients_create.json b/jans-config-api/server/src/test/resources/json/openid/clients/openid_clients_create.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/openid/clients/openid_clients_create.json rename to jans-config-api/server/src/test/resources/json/openid/clients/openid_clients_create.json diff --git a/jans-config-api/server/src/test/resources/feature/openid/scopes/scope.json b/jans-config-api/server/src/test/resources/json/openid/scopes/scope.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/openid/scopes/scope.json rename to jans-config-api/server/src/test/resources/json/openid/scopes/scope.json diff --git a/jans-config-api/server/src/test/resources/feature/plugins/plugin-all.json b/jans-config-api/server/src/test/resources/json/plugins/plugin-all.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/plugins/plugin-all.json rename to jans-config-api/server/src/test/resources/json/plugins/plugin-all.json diff --git a/jans-config-api/server/src/test/resources/feature/plugins/plugin.feature b/jans-config-api/server/src/test/resources/json/plugins/plugin.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/plugins/plugin.feature rename to jans-config-api/server/src/test/resources/json/plugins/plugin.feature diff --git a/jans-config-api/server/src/test/resources/feature/session/session.feature b/jans-config-api/server/src/test/resources/json/session/session.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/session/session.feature rename to jans-config-api/server/src/test/resources/json/session/session.feature diff --git a/jans-config-api/server/src/test/resources/feature/smtp/smtp.feature b/jans-config-api/server/src/test/resources/json/smtp/smtp.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/smtp/smtp.feature rename to jans-config-api/server/src/test/resources/json/smtp/smtp.feature diff --git a/jans-config-api/server/src/test/resources/feature/smtp/smtp.json b/jans-config-api/server/src/test/resources/json/smtp/smtp.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/smtp/smtp.json rename to jans-config-api/server/src/test/resources/json/smtp/smtp.json diff --git a/jans-config-api/server/src/test/resources/feature/stat/stat.feature b/jans-config-api/server/src/test/resources/json/stat/stat.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/stat/stat.feature rename to jans-config-api/server/src/test/resources/json/stat/stat.feature diff --git a/jans-config-api/server/src/test/resources/feature/token/client-token.feature b/jans-config-api/server/src/test/resources/json/token/client-token.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/token/client-token.feature rename to jans-config-api/server/src/test/resources/json/token/client-token.feature diff --git a/jans-config-api/server/src/test/resources/feature/uma/resource/resources.feature b/jans-config-api/server/src/test/resources/json/uma/resource/resources.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/uma/resource/resources.feature rename to jans-config-api/server/src/test/resources/json/uma/resource/resources.feature diff --git a/jans-config-api/server/src/test/resources/feature/uma/resource/uma-resource.json b/jans-config-api/server/src/test/resources/json/uma/resource/uma-resource.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/uma/resource/uma-resource.json rename to jans-config-api/server/src/test/resources/json/uma/resource/uma-resource.json diff --git a/jans-config-api/server/src/test/resources/feature/uma/scopes/uma-scope.json b/jans-config-api/server/src/test/resources/json/uma/scopes/uma-scope.json similarity index 100% rename from jans-config-api/server/src/test/resources/feature/uma/scopes/uma-scope.json rename to jans-config-api/server/src/test/resources/json/uma/scopes/uma-scope.json diff --git a/jans-config-api/server/src/test/resources/feature/uma/scopes/umascopes.feature b/jans-config-api/server/src/test/resources/json/uma/scopes/umascopes.feature similarity index 100% rename from jans-config-api/server/src/test/resources/feature/uma/scopes/umascopes.feature rename to jans-config-api/server/src/test/resources/json/uma/scopes/umascopes.feature diff --git a/jans-config-api/server/src/test/resources/karate-config-jenkins.js b/jans-config-api/server/src/test/resources/karate-config-jenkins.js deleted file mode 100644 index 33999c8bcf8..00000000000 --- a/jans-config-api/server/src/test/resources/karate-config-jenkins.js +++ /dev/null @@ -1,82 +0,0 @@ -function() { - - var stream = read('classpath:karate_jenkins.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate_jenkins env :', env); - karate.log('karate_jenkins url :', url); - karate.log('karate_jenkins port :', port); - karate.log('karate_jenkins baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - statUrl: baseUrl + '/jans-config-api/api/v1/stat', - healthUrl: baseUrl + '/jans-config-api/api/v1/health', - acrsUrl: baseUrl + '/jans-config-api/api/v1/acrs', - authConfigurationUrl: baseUrl + '/jans-config-api/api/v1/jans-auth-server/config', - scriptsUrl: baseUrl + '/jans-config-api/api/v1/config/scripts', - cacheUrl: baseUrl + '/jans-config-api/api/v1/config/cache', - messageUrl: baseUrl + '/jans-config-api/api/v1/config/message', - jwksUrl: baseUrl + '/jans-config-api/api/v1/config/jwks', - ldapUrl: baseUrl + '/jans-config-api/api/v1/config/database/ldap', - openidclients_url: baseUrl + '/jans-config-api/api/v1/openid/clients', - scopes_url: baseUrl + '/jans-config-api/api/v1/scopes', - umaresources_url: baseUrl + '/jans-config-api/api/v1/uma/resources', - attributes_url: baseUrl + '/jans-config-api/api/v1/attributes', - smtp_url: baseUrl + '/jans-config-api/api/v1/config/smtp', - logging_url: baseUrl + '/jans-config-api/api/v1/logging', - auth_health_url: baseUrl + '/jans-config-api/api/v1/jans-auth-server/health', - org_configuration_url: baseUrl + '/jans-config-api/api/v1/org', - user_url: baseUrl + '/jans-config-api/api/v1/user', - agama_url: baseUrl + '/jans-config-api/api/v1/agama', - session_url: baseUrl + '/jans-config-api/api/v1/jans-auth-server/session', - plugin_url: baseUrl + '/jans-config-api/api/v1/plugin', - api_config_url: baseUrl + '/jans-config-api/api/v1/api-config', - agama_deployment_url: baseUrl + '/jans-config-api/api/v1/agama-deployment', - clients_authorizations_url: baseUrl + '/jans-config-api/api/v1/clients/authorizations', - token_url: baseUrl + '/jans-config-api/api/v1/token', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/server/src/test/resources/karate-config.js b/jans-config-api/server/src/test/resources/karate-config.js deleted file mode 100644 index b11ca003aa2..00000000000 --- a/jans-config-api/server/src/test/resources/karate-config.js +++ /dev/null @@ -1,82 +0,0 @@ -function() { - - var stream = read('classpath:karate.properties'); - var props = new java.util.Properties(); - props.load(stream); - - var env = props.get('karate.env'); // get java system property 'karate.env' - karate.configure("ssl", true); - - if (!env) { - env = 'dev'; //env can be anything: dev, qa, staging, etc. - } - - var url = props.get('karate.test.url'); - var port = props.get('karate.test.port'); - var baseUrl = url + (port ? ':' + port : ''); - - karate.log('karate env :', env); - karate.log('karate url :', url); - karate.log('karate port :', port); - karate.log('karate baseUrl :', baseUrl); - - var testStream = read('classpath:test.properties'); - var testProps = new java.util.Properties(); - testProps.load(testStream); - karate.log(' testProps = '+testProps); - var testClientId = testProps.get('test.client.id'); - var testClientSecret = testProps.get('test.client.secret'); - var tokenEndpoint = testProps.get('token.endpoint'); - var testScopes = testProps.get('test.scopes'); - var issuer = testProps.get('test.issuer'); - karate.log(' testClientId = '+testClientId); - karate.log(' testClientSecret = '+testClientSecret); - karate.log(' tokenEndpoint = '+tokenEndpoint); - karate.log(' testScopes = '+testScopes); - karate.log(' issuer = '+issuer); - - - var config = { - env: env, - baseUrl: baseUrl, - testProps: testProps, - issuer: issuer, - accessToken: '123', - - statUrl: baseUrl + '/jans-config-api/api/v1/stat', - healthUrl: baseUrl + '/jans-config-api/api/v1/health', - acrsUrl: baseUrl + '/jans-config-api/api/v1/acrs', - authConfigurationUrl: baseUrl + '/jans-config-api/api/v1/jans-auth-server/config', - scriptsUrl: baseUrl + '/jans-config-api/api/v1/config/scripts', - cacheUrl: baseUrl + '/jans-config-api/api/v1/config/cache', - messageUrl: baseUrl + '/jans-config-api/api/v1/config/message', - jwksUrl: baseUrl + '/jans-config-api/api/v1/config/jwks', - ldapUrl: baseUrl + '/jans-config-api/api/v1/config/database/ldap', - openidclients_url: baseUrl + '/jans-config-api/api/v1/openid/clients', - scopes_url: baseUrl + '/jans-config-api/api/v1/scopes', - umaresources_url: baseUrl + '/jans-config-api/api/v1/uma/resources', - attributes_url: baseUrl + '/jans-config-api/api/v1/attributes', - smtp_url: baseUrl + '/jans-config-api/api/v1/config/smtp', - logging_url: baseUrl + '/jans-config-api/api/v1/logging', - auth_health_url: baseUrl + '/jans-config-api/api/v1/jans-auth-server/health', - org_configuration_url: baseUrl + '/jans-config-api/api/v1/org', - user_url: baseUrl + '/jans-config-api/api/v1/user', - agama_url: baseUrl + '/jans-config-api/api/v1/agama', - session_url: baseUrl + '/jans-config-api/api/v1/jans-auth-server/session', - plugin_url: baseUrl + '/jans-config-api/api/v1/plugin', - api_config_url: baseUrl + '/jans-config-api/api/v1/api-config', - agama_deployment_url: baseUrl + '/jans-config-api/api/v1/agama-deployment', - clients_authorizations_url: baseUrl + '/jans-config-api/api/v1/clients/authorizations', - token_url: baseUrl + '/jans-config-api/api/v1/token', - - }; - - karate.configure('connectTimeout', 30000); - karate.configure('readTimeout', 60000); - - var result = karate.callSingle('classpath:token.feature', config); - print(' result.response = '+result.response); - config.accessToken = result.response.access_token; - - return config; -} \ No newline at end of file diff --git a/jans-config-api/server/src/test/resources/karate.properties b/jans-config-api/server/src/test/resources/karate.properties deleted file mode 100644 index 41c0d369aff..00000000000 --- a/jans-config-api/server/src/test/resources/karate.properties +++ /dev/null @@ -1,5 +0,0 @@ -#karate.test.url=http://localhost -#karate.test.port=8080 -#karate.test.url=https://jenkins-config-api.gluu.org/jans-config-api -#karate.test.port=443 -karate.test.url=${test.server} diff --git a/jans-config-api/server/src/test/resources/karate_jenkins.properties b/jans-config-api/server/src/test/resources/karate_jenkins.properties deleted file mode 100644 index 0b44a8d7b13..00000000000 --- a/jans-config-api/server/src/test/resources/karate_jenkins.properties +++ /dev/null @@ -1,2 +0,0 @@ -karate.test.url=${test.server} -#karate.test.port=443 diff --git a/jans-config-api/server/src/test/resources/log4j2-test.xml b/jans-config-api/server/src/test/resources/log4j2-test.xml new file mode 100644 index 00000000000..28f0d2bef4d --- /dev/null +++ b/jans-config-api/server/src/test/resources/log4j2-test.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/server/src/test/resources/test.properties b/jans-config-api/server/src/test/resources/test.properties index 4257f297907..beceb80ab7d 100644 --- a/jans-config-api/server/src/test/resources/test.properties +++ b/jans-config-api/server/src/test/resources/test.properties @@ -1,8 +1,55 @@ -test.scopes=${test.scopes} +scopes=https://jans.io/oauth/config/acrs.readonly https://jans.io/oauth/config/acrs.write https://jans.io/oauth/config/attributes.readonly https://jans.io/oauth/config/attributes.write https://jans.io/oauth/config/attributes.delete https://jans.io/oauth/config/cache.readonly https://jans.io/oauth/config/cache.write https://jans.io/oauth/config/openid/clients.readonly https://jans.io/oauth/config/openid/clients.write https://jans.io/oauth/config/openid/clients.delete https://jans.io/oauth/jans-auth-server/config/properties.readonly https://jans.io/oauth/jans-auth-server/config/properties.write https://jans.io/oauth/config/smtp.readonly https://jans.io/oauth/config/smtp.write https://jans.io/oauth/config/smtp.delete https://jans.io/oauth/config/scripts.readonly https://jans.io/oauth/config/scripts.write https://jans.io/oauth/config/scripts.delete https://jans.io/oauth/config/fido2.readonly https://jans.io/oauth/config/fido2.write https://jans.io/oauth/config/fido2.delete https://jans.io/oauth/config/jwks.readonly https://jans.io/oauth/config/jwks.write https://jans.io/oauth/config/jwks.delete https://jans.io/oauth/config/database/ldap.readonly https://jans.io/oauth/config/database/ldap.write https://jans.io/oauth/config/database/ldap.delete https://jans.io/oauth/config/logging.readonly https://jans.io/oauth/config/logging.write https://jans.io/oauth/config/scopes.readonly https://jans.io/oauth/config/scopes.write https://jans.io/oauth/config/scopes.delete https://jans.io/oauth/config/uma/resources.readonly https://jans.io/oauth/config/uma/resources.write https://jans.io/oauth/config/uma/resources.delete https://jans.io/oauth/config/database/sql.readonly https://jans.io/oauth/config/database/sql.write https://jans.io/oauth/config/database/sql.delete https://jans.io/oauth/config/stats.readonly jans_stat https://jans.io/scim/users.read https://jans.io/scim/users.write https://jans.io/oauth/config/scim/users.read https://jans.io/oauth/config/scim/users.write https://jans.io/scim/config.readonly https://jans.io/scim/config.write https://jans.io/oauth/config/organization.readonly https://jans.io/oauth/config/organization.write https://jans.io/oauth/config/user.readonly https://jans.io/oauth/config/user.write https://jans.io/oauth/config/user.delete https://jans.io/oauth/config/agama.readonly https://jans.io/oauth/config/agama.write https://jans.io/oauth/config/agama.delete https://jans.io/oauth/jans-auth-server/session.readonly https://jans.io/oauth/jans-auth-server/session.delete revoke_session https://jans.io/oauth/config/read-all https://jans.io/oauth/config/write-all https://jans.io/oauth/config/delete-all https://jans.io/oauth/config/openid-read https://jans.io/oauth/config/openid-write https://jans.io/oauth/config/openid-delete https://jans.io/oauth/config/uma-read https://jans.io/oauth/config/uma-write https://jans.io/oauth/config/uma-delete https://jans.io/oauth/jans-auth-server/config/adminui/user/role.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write https://jans.io/oauth/jans-auth-server/config/adminui/read-all https://jans.io/oauth/jans-auth-server/config/adminui/write-all https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete https://jans.io/oauth/jans-auth-server/config/adminui/delete-all https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.readonly https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete https://jans.io/oauth/jans-auth-server/config/adminui/license.readonly https://jans.io/oauth/jans-auth-server/config/adminui/license.write https://jans.io/oauth/config/plugin.readonly https://jans.io/oauth/client/authorizations.readonly https://jans.io/oauth/client/authorizations.delete https://jans.io/oauth/config/cacherefresh.readonly https://jans.io/oauth/config/cacherefresh.write https://jans.io/oauth/config/saml.readonly https://jans.io/oauth/config/saml.write https://jans.io/oauth/config/saml-config.readonly https://jans.io/oauth/config/saml-config.write https://jans.io/oauth/config/saml-client-scope.readonly https://jans.io/oauth/config/saml-client-scope.write https://jans.io/idp/config.readonly https://jans.io/idp/config.write https://jans.io/idp/realm.readonly https://jans.io/idp/realm.write https://jans.io/idp/realm.write https://jans.io/idp/saml.readonly https://jans.io/idp/saml.write https://jans.io/oauth/config/app-version.readonly https://jans.io/oauth/kc-link-config.readonly https://jans.io/oauth/kc-link-config.write https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://pujavs-definite-dory.gluu.info/jans-config-api/api/v1/jans-assets/upload-asset https://jans.io/oauth/config/jans_asset-write https://jans.io/oauth/config/jans_asset-delete https://jans.io/oauth/lock/read-all https://jans.io/oauth/lock/write-all https://jans.io/oauth/lock-config.readonly https://jans.io/oauth/lock-config.write https://jans.io/oauth/lock/audit.readonly https://jans.io/oauth/lock/audit.write https://jans.io/oauth/lock/health.readonly https://jans.io/oauth/lock/health.write https://jans.io/oauth/lock/log.readonly https://jans.io/oauth/lock/log.write https://jans.io/oauth/lock/telemetry.readonly https://jans.io/oauth/lock/telemetry.write https://jans.io/oauth/config/token.readonly https://jans.io/oauth/config/token.write https://jans.io/oauth/config/token.delete # Test env Setting -token.endpoint=${token.endpoint} -token.grant.type=${token.grant.type} -test.client.id=${test.client.id} -test.client.secret=${test.client.secret} -test.issuer=${test.issuer} \ No newline at end of file +tokenEndpoint=https://pujavs-witty-weasel.gluu.info/jans-auth/restv1/token +tokenGrantType=client_credentials +clientId=1800.2602d79c-2c24-42ec-b229-1f951ea7c6f2 +clientSecret=eoT3tAwFVps0 +issuer=https://pujavs-witty-weasel.gluu.info + + +statUrl=/jans-config-api/api/v1/stat +healthUrl=/jans-config-api/api/v1/health +acrsUrl=/jans-config-api/api/v1/acrs +apiConfigtionUrl=/jans-config-api/api/v1/api-config +authConfigurationUrl=/jans-config-api/api/v1/jans-auth-server/config +scriptsUrl=/jans-config-api/api/v1/config/scripts +cacheUrl=/jans-config-api/api/v1/config/cache +messageUrl=/jans-config-api/api/v1/config/message +jwksUrl=/jans-config-api/api/v1/config/jwks +ldapUrl=/jans-config-api/api/v1/config/database/ldap +openidClientsUrl=/jans-config-api/api/v1/openid/clients +scopesUrl=/jans-config-api/api/v1/scopes +umaresourcesUrl=/jans-config-api/api/v1/uma/resources +attributesUrl=/jans-config-api/api/v1/attributes +smtpUrl=/jans-config-api/api/v1/config/smtp +loggingUrl=/jans-config-api/api/v1/logging +authHealthUrl=/jans-config-api/api/v1/jans-auth-server/health +orgConfigurationUrl=/jans-config-api/api/v1/org +userUrl=/jans-config-api/api/v1/user +agamaUrl=/jans-config-api/api/v1/agama +sessionUrl=/jans-config-api/api/v1/jans-auth-server/session +pluginUrl=/jans-config-api/api/v1/plugin +apiConfigUrl=/jans-config-api/api/v1/api-config +agamaDeploymentUrl=/jans-config-api/api/v1/agama-deployment +clientsAuthorizationsUrl=/jans-config-api/api/v1/clients/authorizations +tokenUrl=/jans-config-api/api/v1/token + + +#apiConfigtion +api_config_patch_1=file:target/test-classes/json/config/api/api-config-patch.json + +#apiConfigtion +auth_config_patch_1=file:target/test-classes/json/config/auth/auth-config-patch.json + +#defaultAcr +default_acr_1=file:target/test-classes/json/acr/defaultAcr.json + +#openid-client +openid_client_1=file:target/test-classes/json/openid/clients/openid-client-post.json +openid_client_2=file:target/test-classes/json/openid/clients/client.json + + +#openid-scopes +openid_scopes_1=file:target/test-classes/json/openid/scopes/scope.json + diff --git a/jans-config-api/server/src/test/resources/testClient.feature b/jans-config-api/server/src/test/resources/testClient.feature deleted file mode 100644 index 34cfdffc438..00000000000 --- a/jans-config-api/server/src/test/resources/testClient.feature +++ /dev/null @@ -1,13 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - -Background: -* def mainUrl = test_url - -Scenario: Get Token -Given url mainUrl -And print url -And request '' -When method POST -Then status 204 -And print response diff --git a/jans-config-api/server/src/test/resources/testng.xml b/jans-config-api/server/src/test/resources/testng.xml new file mode 100644 index 00000000000..3c98a2f3c30 --- /dev/null +++ b/jans-config-api/server/src/test/resources/testng.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jans-config-api/server/src/test/resources/token.feature b/jans-config-api/server/src/test/resources/token.feature deleted file mode 100644 index ef0ad0d262d..00000000000 --- a/jans-config-api/server/src/test/resources/token.feature +++ /dev/null @@ -1,45 +0,0 @@ -@ignore -Feature: This Feature is to get token to test the test cases - Do not remove ignore tag - -Background: -* def mainUrl = testProps.get('token.endpoint'); -* def grantType = testProps.get('token.grant.type'); -* def clientId = testProps.get('test.client.id'); -* def clientSecret = testProps.get('test.client.secret'); -* def scopes = testProps.get('test.scopes'); -* def authStr = clientId+':'+clientSecret -* def Base64 = Java.type('java.util.Base64') -* def encodedAuth = Base64.encoder.encodeToString(authStr.bytes) -* def encodedScopes = java.net.URLDecoder.decode(scopes, 'UTF-8') - - -Scenario: Get Token -Given url mainUrl -And print 'mainUrl = '+mainUrl -And print 'grantType = '+grantType -And print 'clientId = '+clientId -And print 'clientSecret = '+clientSecret -And print 'scopes = '+scopes -And print 'authStr = '+authStr -And print 'encodedAuth = '+encodedAuth -And print 'encodedScopes = '+encodedScopes -And header Accept = 'application/json' -And header Authorization = 'Basic '+encodedAuth -And form field grant_type = grantType -And form field scope = scopes -When method POST -Then status 200 -And print 'token response = '+response - - - - -#Scenario: Get Token -#Given url 'https://pujavs.jans.server/jans-auth/restv1/token' -#And header Accept = 'application/json' -#And header Authorization = 'Basic MTgwMi45ZGNkOThhZC1mZTJjLTRmZDktYjcxNy1kOTQzNmQ5ZjIwMDk6dGVzdDEyMzQ=' -#And form field grant_type = 'client_credentials' -#And form field scope = 'https://jans.io/oauth/config/openid/clients.readonly' -#When method POST -#Then status 200 -#And print 'token response = '+response diff --git a/jans-config-api/server/test-output/bullet_point.png b/jans-config-api/server/test-output/bullet_point.png new file mode 100644 index 00000000000..176e6d5b3d6 Binary files /dev/null and b/jans-config-api/server/test-output/bullet_point.png differ diff --git a/jans-config-api/server/test-output/failed.png b/jans-config-api/server/test-output/failed.png new file mode 100644 index 00000000000..c117be59a9e Binary files /dev/null and b/jans-config-api/server/test-output/failed.png differ diff --git a/jans-config-api/server/test-output/jquery-3.6.0.min.js b/jans-config-api/server/test-output/jquery-3.6.0.min.js new file mode 100644 index 00000000000..c4c6022f298 --- /dev/null +++ b/jans-config-api/server/test-output/jquery-3.6.0.min.js @@ -0,0 +1,2 @@ +/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ +!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0Groups used for this test run \ No newline at end of file diff --git a/jans-config-api/server/test-output/old/Default suite/index.html b/jans-config-api/server/test-output/old/Default suite/index.html new file mode 100644 index 00000000000..8ed202c3be3 --- /dev/null +++ b/jans-config-api/server/test-output/old/Default suite/index.html @@ -0,0 +1,6 @@ +Results for Default suite + + + + + diff --git a/jans-config-api/server/test-output/old/Default suite/main.html b/jans-config-api/server/test-output/old/Default suite/main.html new file mode 100644 index 00000000000..5888ae0744d --- /dev/null +++ b/jans-config-api/server/test-output/old/Default suite/main.html @@ -0,0 +1,2 @@ +Results for Default suite +Select a result on the left-hand pane. diff --git a/jans-config-api/server/test-output/old/Default suite/reporter-output.html b/jans-config-api/server/test-output/old/Default suite/reporter-output.html new file mode 100644 index 00000000000..063bc2e96fd --- /dev/null +++ b/jans-config-api/server/test-output/old/Default suite/reporter-output.html @@ -0,0 +1 @@ +

Reporter output

\ No newline at end of file diff --git a/jans-config-api/server/test-output/passed.png b/jans-config-api/server/test-output/passed.png new file mode 100644 index 00000000000..45e85bbfd0f Binary files /dev/null and b/jans-config-api/server/test-output/passed.png differ diff --git a/jans-config-api/server/test-output/skipped.png b/jans-config-api/server/test-output/skipped.png new file mode 100644 index 00000000000..c36a324398f Binary files /dev/null and b/jans-config-api/server/test-output/skipped.png differ diff --git a/jans-config-api/server/test-output/testng-reports.css b/jans-config-api/server/test-output/testng-reports.css new file mode 100644 index 00000000000..d7b75c40478 --- /dev/null +++ b/jans-config-api/server/test-output/testng-reports.css @@ -0,0 +1,326 @@ +body { + margin: 0 0 5px 5px; +} + +ul { + margin: 0; +} + +li { + list-style-type: none; +} + +a { + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +.navigator-selected { + background: #ffa500; +} + +.wrapper { + position: absolute; + top: 60px; + bottom: 0; + left: 400px; + right: 0; + overflow: auto; +} + +.navigator-root { + position: absolute; + top: 60px; + bottom: 0; + left: 0; + width: 400px; + overflow-y: auto; +} + +.suite { + margin: 0 10px 10px 0; + background-color: #fff8dc; +} + +.suite-name { + padding-left: 10px; + font-size: 25px; + font-family: Times, sans-serif; +} + +.main-panel-header { + padding: 5px; + background-color: #9FB4D9; /*afeeee*/; + font-family: monospace; + font-size: 18px; +} + +.main-panel-content { + padding: 5px; + margin-bottom: 10px; + background-color: #DEE8FC; /*d0ffff*/; +} + +.rounded-window { + border-radius: 10px; + border-style: solid; + border-width: 1px; +} + +.rounded-window-top { + border-top-right-radius: 10px 10px; + border-top-left-radius: 10px 10px; + border-style: solid; + border-width: 1px; + overflow: auto; +} + +.light-rounded-window-top { + border-top-right-radius: 10px 10px; + border-top-left-radius: 10px 10px; +} + +.rounded-window-bottom { + border-style: solid; + border-width: 0 1px 1px 1px; + border-bottom-right-radius: 10px 10px; + border-bottom-left-radius: 10px 10px; + overflow: auto; +} + +.method-name { + font-size: 12px; + font-family: monospace; +} + +.method-content { + border-style: solid; + border-width: 0 0 1px 0; + margin-bottom: 10px; + padding-bottom: 5px; + width: 80%; +} + +.parameters { + font-size: 14px; + font-family: monospace; +} + +.stack-trace { + white-space: pre; + font-family: monospace; + font-size: 12px; + font-weight: bold; + margin-top: 0; + margin-left: 20px; +} + +.testng-xml { + font-family: monospace; +} + +.method-list-content { + margin-left: 10px; +} + +.navigator-suite-content { + margin-left: 10px; + font: 12px 'Lucida Grande'; +} + +.suite-section-title { + margin-top: 10px; + width: 80%; + border-style: solid; + border-width: 1px 0 0 0; + font-family: Times, sans-serif; + font-size: 18px; + font-weight: bold; +} + +.suite-section-content { + list-style-image: url(bullet_point.png); +} + +.top-banner-root { + position: absolute; + top: 0; + height: 45px; + left: 0; + right: 0; + padding: 5px; + margin: 0 0 5px 0; + background-color: #0066ff; + font-family: Times, sans-serif; + color: #fff; + text-align: center; +} +.button{ + position: absolute; + margin-left:500px; + margin-top:8px; + background-color: white; + color:#0066ff; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight:bold; + border-color:#0066ff ; + border-radius:25px; + cursor: pointer; + height:30px; + width:150px; + outline:none; + +} + +.top-banner-title-font { + font-size: 25px; +} + +.test-name { + font-family: 'Lucida Grande', sans-serif; + font-size: 16px; +} + +.suite-icon { + padding: 5px; + float: right; + height: 20px; +} + +.test-group { + font: 20px 'Lucida Grande'; + margin: 5px 5px 10px 5px; + border-width: 0 0 1px 0; + border-style: solid; + padding: 5px; +} + +.test-group-name { + font-weight: bold; +} + +.method-in-group { + font-size: 16px; + margin-left: 80px; +} + +table.google-visualization-table-table { + width: 100%; +} + +.reporter-method-name { + font-size: 14px; + font-family: monospace; +} + +.reporter-method-output-div { + padding: 5px; + margin: 0 0 5px 20px; + font-size: 12px; + font-family: monospace; + border-width: 0 0 0 1px; + border-style: solid; +} + +.ignored-class-div { + font-size: 14px; + font-family: monospace; +} + +.ignored-methods-div { + padding: 5px; + margin: 0 0 5px 20px; + font-size: 12px; + font-family: monospace; + border-width: 0 0 0 1px; + border-style: solid; +} + +.border-failed { + border-top-left-radius: 10px 10px; + border-bottom-left-radius: 10px 10px; + border-style: solid; + border-width: 0 0 0 10px; + border-color: #f00; +} + +.border-skipped { + border-top-left-radius: 10px 10px; + border-bottom-left-radius: 10px 10px; + border-style: solid; + border-width: 0 0 0 10px; + border-color: #edc600; +} + +.border-passed { + border-top-left-radius: 10px 10px; + border-bottom-left-radius: 10px 10px; + border-style: solid; + border-width: 0 0 0 10px; + border-color: #19f52d; +} + +.times-div { + text-align: center; + padding: 5px; +} + +.suite-total-time { + font: 16px 'Lucida Grande'; +} + +.configuration-suite { + margin-left: 20px; +} + +.configuration-test { + margin-left: 40px; +} + +.configuration-class { + margin-left: 60px; +} + +.configuration-method { + margin-left: 80px; +} + +.test-method { + margin-left: 100px; +} + +.chronological-class { + background-color: skyblue; + border-style: solid; + border-width: 0 0 1px 1px; +} + +.method-start { + float: right; +} + +.chronological-class-name { + padding: 0 0 0 5px; + color: #008; +} + +.after, .before, .test-method { + font-family: monospace; + font-size: 14px; +} + +.navigator-suite-header { + font-size: 22px; + margin: 0 10px 5px 0; + background-color: #deb887; + text-align: center; +} + +.collapse-all-icon { + padding: 5px; + float: right; +} +/*retro Theme*/ diff --git a/jans-config-api/server/test-output/testng-reports.js b/jans-config-api/server/test-output/testng-reports.js new file mode 100644 index 00000000000..c1a84a35d45 --- /dev/null +++ b/jans-config-api/server/test-output/testng-reports.js @@ -0,0 +1,122 @@ +$(document).ready(function() { + $('a.navigator-link').on("click", function() { + // Extract the panel for this link + var panel = getPanelName($(this)); + + // Mark this link as currently selected + $('.navigator-link').parent().removeClass('navigator-selected'); + $(this).parent().addClass('navigator-selected'); + + showPanel(panel); + }); + + installMethodHandlers('failed'); + installMethodHandlers('skipped'); + installMethodHandlers('passed', true); // hide passed methods by default + + $('a.method').on("click", function() { + showMethod($(this)); + return false; + }); + + // Hide all the panels and display the first one (do this last + // to make sure the click() will invoke the listeners) + $('.panel').hide(); + $('.navigator-link').first().trigger("click"); + + // Collapse/expand the suites + $('a.collapse-all-link').on("click", function() { + var contents = $('.navigator-suite-content'); + if (contents.css('display') == 'none') { + contents.show(); + } else { + contents.hide(); + } + }); +}); + +// The handlers that take care of showing/hiding the methods +function installMethodHandlers(name, hide) { + function getContent(t) { + return $('.method-list-content.' + name + "." + t.attr('panel-name')); + } + + function getHideLink(t, name) { + var s = 'a.hide-methods.' + name + "." + t.attr('panel-name'); + return $(s); + } + + function getShowLink(t, name) { + return $('a.show-methods.' + name + "." + t.attr('panel-name')); + } + + function getMethodPanelClassSel(element, name) { + var panelName = getPanelName(element); + var sel = '.' + panelName + "-class-" + name; + return $(sel); + } + + $('a.hide-methods.' + name).on("click", function() { + var w = getContent($(this)); + w.hide(); + getHideLink($(this), name).hide(); + getShowLink($(this), name).show(); + getMethodPanelClassSel($(this), name).hide(); + }); + + $('a.show-methods.' + name).on("click", function() { + var w = getContent($(this)); + w.show(); + getHideLink($(this), name).show(); + getShowLink($(this), name).hide(); + showPanel(getPanelName($(this))); + getMethodPanelClassSel($(this), name).show(); + }); + + if (hide) { + $('a.hide-methods.' + name).trigger("click"); + } else { + $('a.show-methods.' + name).trigger("click"); + } +} + +function getHashForMethod(element) { + return element.attr('hash-for-method'); +} + +function getPanelName(element) { + return element.attr('panel-name'); +} + +function showPanel(panelName) { + $('.panel').hide(); + var panel = $('.panel[panel-name="' + panelName + '"]'); + panel.show(); +} + +function showMethod(element) { + var hashTag = getHashForMethod(element); + var panelName = getPanelName(element); + showPanel(panelName); + var current = document.location.href; + var base = current.substring(0, current.indexOf('#')) + document.location.href = base + '#' + hashTag; + var newPosition = $(document).scrollTop() - 65; + $(document).scrollTop(newPosition); +} + +function drawTable() { + for (var i = 0; i < suiteTableInitFunctions.length; i++) { + window[suiteTableInitFunctions[i]](); + } + + for (var k in window.suiteTableData) { + var v = window.suiteTableData[k]; + var div = v.tableDiv; + var data = v.tableData + var table = new google.visualization.Table(document.getElementById(div)); + table.draw(data, { + showRowNumber : false + }); + } +} diff --git a/jans-config-api/server/test-output/testng-reports1.css b/jans-config-api/server/test-output/testng-reports1.css new file mode 100644 index 00000000000..570323ffb8f --- /dev/null +++ b/jans-config-api/server/test-output/testng-reports1.css @@ -0,0 +1,344 @@ +body { + background-color: whitesmoke; + margin: 0 0 5px 5px; +} +ul { + margin-top: 10px; + margin-left:-10px; +} + li { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + padding:5px 5px; + } + a { + text-decoration: none; + color: black; + font-size: 14px; + } + + a:hover { + color:black ; + text-decoration: underline; + } + + .navigator-selected { + /* #ffa500; Mouse hover color after click Orange.*/ + background:#027368 + } + + .wrapper { + position: absolute; + top: 60px; + bottom: 0; + left: 400px; + right: 0; + margin-right:9px; + overflow: auto;/*imortant*/ + } + + .navigator-root { + position: absolute; + top: 60px; + bottom: 0; + left: 0; + width: 400px; + overflow-y: auto;/*important*/ + } + + .suite { + margin: -5px 10px 10px 5px; + background-color: whitesmoke ;/*Colour of the left bside box*/ + } + + .suite-name { + font-size: 24px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;/*All TEST SUITE*/ + color: white; + } + + .main-panel-header { + padding: 5px; + background-color: #027368; /*afeeee*/; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + color:white; + font-size: 18px; + } + + .main-panel-content { + padding: 5px; + margin-bottom: 10px; + background-color: #CCD0D1; /*d0ffff*/; /*Belongs to backGround of rightSide boxes*/ + } + + .rounded-window { + border-style: dotted; + border-width: 1px;/*Border of left Side box*/ + background-color: whitesmoke; + border-radius: 10px; + } + + .rounded-window-top { + border-top-right-radius: 10px 10px; + border-top-left-radius: 10px 10px; + border-style: solid; + border-width: 1px; + overflow: auto;/*Top of RightSide box*/ + } + + .light-rounded-window-top { + background-color: #027368; + padding-left:120px; + border-radius: 10px; + + } + + .rounded-window-bottom { + border-bottom-right-radius: 10px 10px; + border-bottom-left-radius: 10px 10px; + overflow: auto;/*Bottom of rightSide box*/ + } + + .method-name { + font-size: 14px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: bold; + } + + .method-content { + border-style: solid; + border-width: 0 0 1px 0; + margin-bottom: 10px; + padding-bottom: 5px; + width: 100%; + } + + .parameters { + font-size: 14px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + } + + .stack-trace { + white-space: pre; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 12px; + font-weight: bold; + margin-top: 0; + margin-left: 20px; /*Error Stack Trace Message*/ + } + + .testng-xml { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + } + + .method-list-content { + margin-left: 10px; + } + + .navigator-suite-content { + margin-left: 10px; + font: 12px 'Lucida Grande'; + } + + .suite-section-title { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + font-weight:bold; + background-color: #8C8887; + margin-left: -10px; + margin-top:10px; + padding:6px; + } + + .suite-section-content { + list-style-image: url(bullet_point.png); + background-color: whitesmoke; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + overflow: hidden; + } + + .top-banner-root { + position: absolute; + top: 0; + height: 45px; + left: 0; + right: 0; + padding: 5px; + margin: 0 0 5px 0; + background-color: #027368; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 18px; + color: #fff; + text-align: center;/*Belongs to the Top of Report*//*Status: - Completed*/ + } + + .top-banner-title-font { + font-size: 25px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + padding: 3px; + float: right; + } + + .test-name { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 16px; + } + + .suite-icon { + padding: 5px; + float: right; + height: 20px; + } + + .test-group { + font: 20px 'Lucida Grande'; + margin: 5px 5px 10px 5px; + border-width: 0 0 1px 0; + border-style: solid; + padding: 5px; + } + + .test-group-name { + font-weight: bold; + } + + .method-in-group { + font-size: 16px; + margin-left: 80px; + } + + table.google-visualization-table-table { + width: 100%; + } + + .reporter-method-name { + font-size: 14px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + } + + .reporter-method-output-div { + padding: 5px; + margin: 0 0 5px 20px; + font-size: 12px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + border-width: 0 0 0 1px; + border-style: solid; + } + + .ignored-class-div { + font-size: 14px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + } + + .ignored-methods-div { + padding: 5px; + margin: 0 0 5px 20px; + font-size: 12px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + border-width: 0 0 0 1px; + border-style: solid; + } + + .border-failed { + border-radius:2px; + border-style: solid; + border-width: 0 0 0 10px; + border-color: #F20505; + } + + .border-skipped { + border-radius:2px; + border-style: solid; + border-width: 0 0 0 10px; + border-color: #F2BE22; + } + + .border-passed { + border-radius:2px; + border-style: solid; + border-width: 0 0 0 10px; + border-color: #038C73; + } + + .times-div { + text-align: center; + padding: 5px; + } + + .suite-total-time { + font: 16px 'Lucida Grande'; + } + + .configuration-suite { + margin-left: 20px; + } + + .configuration-test { + margin-left: 40px; + } + + .configuration-class { + margin-left: 60px; + } + + .configuration-method { + margin-left: 80px; + } + + .test-method { + margin-left: 100px; + } + + .chronological-class { + background-color: #CCD0D1; + border-width: 0 0 1px 1px;/*Chronological*/ + } + + .method-start { + float: right; + } + + .chronological-class-name { + padding: 0 0 0 5px; + margin-top:5px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #008; + } + + .after, .before, .test-method { + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + margin-top:5px; + } + + .navigator-suite-header { + font-size: 18px; + margin: 0px 10px 10px 5px; + padding: 5px; + border-radius: 10px; + background-color: #027368; + color: white; + font-weight:bold; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + text-align: center; /*All Suites on top of left box*//*Status: -Completed*/ + } + + .collapse-all-icon { + padding: 3px; + float: right; + } + .button{ + position: absolute; + margin-left:500px; + margin-top:8px; + background-color: white; + color:#027368; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight:bold; + border-color:#027368; + border-radius:25px; + cursor: pointer; + height:30px; + width:150px; + outline: none; +} +/*Author: - Akhil Gullapalli*/ \ No newline at end of file diff --git a/jans-config-api/server/test-output/testng-reports2.js b/jans-config-api/server/test-output/testng-reports2.js new file mode 100644 index 00000000000..5342859fa4d --- /dev/null +++ b/jans-config-api/server/test-output/testng-reports2.js @@ -0,0 +1,76 @@ +window.onload = function () { + let cookies = document.cookie; + let cookieValue = cookies.split('='); + if (cookieValue[1] === 'null' || localStorage.getItem('Theme') === 'null') { + document.getElementById('retro').setAttribute('disabled', 'false'); + } else if (cookieValue[1] === 'Switch Ultra Theme' || + localStorage.getItem('Theme') === 'Switch Ultra Theme') { + document.getElementById('button').innerText = "Switch Retro Theme"; + document.getElementById('retro').setAttribute('disabled', 'false'); + + } else if (cookieValue[1] === 'Switch Retro Theme' || + localStorage.getItem('Theme') === 'Switch Retro Theme') { + if (cookieValue[1] === 'Switch Ultra Theme' || + localStorage.getItem('Theme') === 'Switch Ultra Theme') { + document.getElementById('button').innerText = "Switch Retro Theme"; + document.getElementById('retro').setAttribute('disabled', 'false'); + + document.getElementById('button').innerText = "Switch Ultra Theme"; + document.getElementById('retro').removeAttribute('disabled'); + document.getElementById('ultra').setAttribute('disabled', 'false'); + localStorage.setItem('Theme', select); + + } else if (select === 'Switch Ultra Theme') { + document.getElementById('button').innerText = "Switch Retro Theme"; + document.getElementById('ultra').removeAttribute('disabled'); + document.getElementById('retro').setAttribute('disabled', 'false'); + localStorage.setItem('Theme', select); + } + } else if (cookieValue[1] === 'Switch Retro Theme' || + localStorage.getItem('Theme') === 'Switch Retro Theme') { + document.getElementById('button').innerText = "Switch Ultra Theme"; + document.getElementById('ultra').setAttribute('disabled', 'false'); + } +} +document.getElementById('button').onclick = function () { + let select = document.getElementById('button').innerText; + if (select === 'Switch Retro Theme') { + let d = new Date(); + days = 365; + d.setTime(+d + (days * 86400000)); //24 * 60 * 60 * 1000 + document.cookie = "Theme =" + select + "; expires=" + d.toGMTString() + ";"; + document.getElementById('button').innerText = "Switch Ultra Theme"; + document.getElementById('retro').removeAttribute('disabled'); + document.getElementById('ultra').setAttribute('disabled', 'false'); + localStorage.setItem('Theme', select); + + } else if (select === 'Switch Ultra Theme') { + let d = new Date(); + days = 365; + d.setTime(+d + (days * 86400000)); //24 * 60 * 60 * 1000 + document.cookie = "Theme =" + select + "; expires=" + d.toGMTString() + ";"; + document.getElementById('button').innerText = "Switch Retro Theme"; + document.getElementById('ultra').removeAttribute('disabled'); + document.getElementById('retro').setAttribute('disabled', 'false'); + localStorage.setItem('Theme', select); + } +} +//Function to mouse hovering affect. +document.getElementById('button').onmouseover = function () { + document.getElementById('button').style.borderRadius = "25px"; + document.getElementById('button').style.width = "180px"; + document.getElementById('button').style.height = "45px"; + document.getElementById('button').style.marginTop = "1px"; + +} +//Function to mouse out affect +document.getElementById('button').onmouseout = function () { + document.getElementById('button').style.borderRadius = "25px"; + document.getElementById('button').style.width = "150px"; + document.getElementById('button').style.height = "30px"; + document.getElementById('button').style.marginTop = "8px"; + +} + +//This is the file where we handle the switching of the Themes. +/*Author:- Akhil Gullapalli*/ diff --git a/jans-config-api/server/test-output/testng.css b/jans-config-api/server/test-output/testng.css new file mode 100644 index 00000000000..5124ba863b3 --- /dev/null +++ b/jans-config-api/server/test-output/testng.css @@ -0,0 +1,9 @@ +.invocation-failed, .test-failed { background-color: #DD0000; } +.invocation-percent, .test-percent { background-color: #006600; } +.invocation-passed, .test-passed { background-color: #00AA00; } +.invocation-skipped, .test-skipped { background-color: #CCCC00; } + +.main-page { + font-size: x-large; +} + diff --git a/jans-config-api/shared/pom.xml b/jans-config-api/shared/pom.xml index 15efc9f1800..8ed902e773a 100644 --- a/jans-config-api/shared/pom.xml +++ b/jans-config-api/shared/pom.xml @@ -13,6 +13,10 @@ + + io.jans + jans-auth-client + io.jans jans-auth-common @@ -54,6 +58,12 @@ org.apache.commons commons-collections4 + + + + org.testng + testng + diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/BaseTest.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/BaseTest.java new file mode 100644 index 00000000000..f5a296575e4 --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/BaseTest.java @@ -0,0 +1,151 @@ +/* + * Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.configapi.core.test; + +import io.jans.as.model.common.GrantType; +import io.jans.as.model.util.Util; +import io.jans.configapi.core.test.service.HttpService; +import io.jans.configapi.core.test.service.ResteasyService; +import io.jans.configapi.core.test.service.TokenService; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Map; +import java.net.URLEncoder; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; + +import org.testng.ITestContext; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; + + +public class BaseTest { + + private static final String FILE_PREFIX = "file:"; + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + private static final String NEW_LINE = System.getProperty("line.separator"); + protected static final String CONTENT_TYPE = "Content-Type"; + protected static final String AUTHORIZATION = "Authorization"; + protected static final String AUTHORIZATION_TYPE = "Bearer"; + + protected Logger log = LogManager.getLogger(getClass()); + protected Base64 base64; + protected static Map propertiesMap = null; + protected ResteasyService resteasyService = new ResteasyService();; + protected HttpService httpService = new HttpService(); + protected TokenService tokenService = new TokenService(); + protected String accessToken; + + @BeforeSuite + public void initTestSuite(ITestContext context) { + String propertiesFile = context.getCurrentXmlTest().getParameter("propertiesFile"); + log.info("Invoked initTestSuite propertiesFile '{}'", propertiesFile); + propertiesMap = context.getSuite().getXmlSuite().getParameters(); + log.info("End initTestSuite propertiesMap: {}", propertiesMap); + } + + + @BeforeMethod + public void getAccessToken() { + log.info("getAccessToken - propertiesMap:{}", propertiesMap); + String tokenUrl = propertiesMap.get("tokenEndpoint"); + String strGrantType = propertiesMap.get("tokenGrantType"); + String clientId = propertiesMap.get("clientId"); + String clientSecret = propertiesMap.get("clientSecret"); + String scopes = propertiesMap.get("scopes"); + GrantType grantType = GrantType.fromString(strGrantType); + this.accessToken = getToken(tokenUrl, clientId, clientSecret, grantType, scopes); + log.info("accessToken:{}", accessToken); + } + + protected String getToken(final String tokenUrl, final String clientId, final String clientSecret, GrantType grantType, + final String scopes) { + return getTokenService().getToken(tokenUrl, clientId, clientSecret, grantType, scopes); + } + + protected HttpService getHttpService() { + return this.httpService; + } + + protected ResteasyService getResteasyService() { + return this.resteasyService; + } + + protected TokenService getTokenService() { + return this.tokenService; + } + + protected String getCredentials(final String clientId, final String clientSecret) + throws UnsupportedEncodingException { + return URLEncoder.encode(clientId, Util.UTF8_STRING_ENCODING) + ":" + + URLEncoder.encode(clientSecret, Util.UTF8_STRING_ENCODING); + } + + /** + * Returns the client credentials encoded using base64. + * + * @return The encoded client credentials. + */ + protected String getEncodedCredentials() { + try { + String clientId = propertiesMap.get("clientId"); + String clientSecret = propertiesMap.get("clientSecret"); + if (StringUtils.isNotBlank(clientId) && StringUtils.isNotBlank(clientSecret)) { + return Base64.encodeBase64String(Util.getBytes(getCredentials(clientId, clientSecret))); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return null; + } + + protected String decodeFileValue(String value) { + log.info("\n\n decodeFileValue"); + String decoded = value; + if (value.startsWith(FILE_PREFIX)) { + value = value.substring(FILE_PREFIX.length()); // remove the prefix + + try (BufferedReader bfr = Files.newBufferedReader(Paths.get(value), DEFAULT_CHARSET)) { // create reader + // appends every line after another + decoded = bfr.lines().reduce("", (partial, next) -> partial + NEW_LINE + next); + if (decoded.length() == 0) + log.warn("Key '{}' is empty", value); + } catch (IOException e) { + log.error(e.getMessage(), e); + decoded = null; + } + } + + log.info("\n\n decodeFileValue - decoded:{}", decoded); + return decoded; + } + + protected boolean isServiceDeployed(String serviceName) { + log.info("\n\n\n *** Check if service is deployed - serviceName:{}", serviceName+" *** \n\n\n"); + boolean isDeployed = false; + try { + Class.forName(serviceName); + isDeployed = true; + } catch (ClassNotFoundException ex) { + log.error("*** \n\n\n'{}' service is NOT deployed ***\n\n", serviceName); + return isDeployed; + } + return isDeployed; + } + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/AlterSuiteListener.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/AlterSuiteListener.java new file mode 100644 index 00000000000..da2fbe6db19 --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/AlterSuiteListener.java @@ -0,0 +1,80 @@ +package io.jans.configapi.core.test.listener; + + +import io.jans.util.security.SecurityProviderUtility; + +import java.io.BufferedReader; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Hashtable; +import java.util.Map; +import java.util.List; +import java.util.Properties; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.testng.IAlterSuiteListener; +import org.testng.xml.XmlSuite; + +public class AlterSuiteListener implements IAlterSuiteListener { + + static PersistenceType persistenceType; + + private static final String FILE_PREFIX = "file:"; + private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); + private static final String NEW_LINE = System.getProperty("line.separator"); + + private Logger logger = LogManager.getLogger(getClass()); + + public void alter(List suites) { + + try { + SecurityProviderUtility.installBCProvider(); + logger.info("\n\n Parsing XML suite"); + XmlSuite suite = suites.get(0); + + //Properties with the file: preffix will point to real .json files stored under src/test/resources folder + String propertiesFile = suite.getParameter("propertiesFile"); + + Properties prop = new Properties(); + prop.load(Files.newBufferedReader(Paths.get(propertiesFile), DEFAULT_CHARSET)); + + persistenceType = PersistenceType.fromString(prop.getProperty("persistenceType")); + logger.info("Using persistence type = {}", persistenceType); + + Map parameters = new Hashtable<>(); + prop.forEach((Object key, Object value) -> parameters.put(key.toString(), decodeFileValue(value.toString()))); + // Override test parameters + suite.setParameters(parameters); + + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + + } + + private String decodeFileValue(String value) { + logger.debug("\n\n decodeFileValue"); + String decoded = value; + if (value.startsWith(FILE_PREFIX)) { + value = value.substring(FILE_PREFIX.length()); //remove the prefix + + try (BufferedReader bfr = Files.newBufferedReader(Paths.get(value), DEFAULT_CHARSET)) { //create reader + //appends every line after another + decoded = bfr.lines().reduce("", (partial, next) -> partial + NEW_LINE + next); + if (decoded.length() == 0) + logger.warn("Key '{}' is empty", value); + } catch (IOException e) { + logger.error(e.getMessage(), e); + decoded = null; + } + } + + logger.debug("\n\n decodeFileValue - decoded:{}",decoded); + return decoded; + + } + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/ApiUnitTestListener.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/ApiUnitTestListener.java new file mode 100644 index 00000000000..cb95b62d3ca --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/ApiUnitTestListener.java @@ -0,0 +1,75 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2021, Janssen Project + */ +package io.jans.configapi.core.test.listener; + +import org.testng.ITestContext; +import org.testng.ITestListener; +import org.testng.ITestResult; +import org.testng.Reporter; + +import com.google.common.base.Throwables; + +public class ApiUnitTestListener implements ITestListener { + + @Override + public void onTestStart(ITestResult result) { + Reporter.log("Test STARTED: " + getTestInfo(result), true); + } + + @Override + public void onTestSuccess(ITestResult result) { + Reporter.log("Test SUCCESS: " + getTestInfo(result), true); + Reporter.log("", true); + } + + @Override + public void onTestFailure(ITestResult result) { + Reporter.log("Test FAILED: " + getTestInfo(result), true); + testFailed(result); + } + + @Override + public void onTestSkipped(ITestResult result) { + Reporter.log("Test SKIPPED: " + getTestInfo(result), true); + Reporter.log("", true); + } + + @Override + public void onTestFailedButWithinSuccessPercentage(ITestResult result) { + Reporter.log("Test FAILED with Success Percentage: " + getTestInfo(result), true); + testFailed(result); + } + + @Override + public void onStart(ITestContext context) { + } + + @Override + public void onFinish(ITestContext context) { + } + + private void testFailed(ITestResult result) { + Object[] parameters = result.getParameters(); + if(parameters != null) { + Reporter.log("Test Parameters: ", true); + for(Object parameter : parameters) { + Reporter.log("parameter = " + parameter, true); + } + } + Throwable throwable = result.getThrowable(); + if(throwable != null) { + Reporter.log("", true); + Reporter.log("Exception: ", true); + Reporter.log(Throwables.getStackTraceAsString(result.getThrowable()), true); + Reporter.log("", true); + } + } + + private String getTestInfo(ITestResult result) { + return result.getInstanceName() + "." + result.getName(); + } + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/PersistenceType.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/PersistenceType.java new file mode 100644 index 00000000000..3b235c6b130 --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/PersistenceType.java @@ -0,0 +1,15 @@ +package io.jans.configapi.core.test.listener; + +import io.jans.util.StringHelper; +import java.util.stream.Stream; + +public enum PersistenceType { + LDAP, COUCHBASE, SPANNER, SQL; + + public static PersistenceType fromString(String from) { + return Stream.of(PersistenceType.values()) + .filter(bt -> StringHelper.equalsIgnoreCase(bt.name(), from)) + .findFirst().orElse(null); + } + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/SkipTest.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/SkipTest.java new file mode 100644 index 00000000000..cd8ef5e2aea --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/SkipTest.java @@ -0,0 +1,17 @@ +package io.jans.configapi.core.test.listener; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD}) +public @interface SkipTest { + + /** + * See valid values for databases in enum {@link PersistenceType} + */ + String[] databases() default {}; + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/SkipTestsListener.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/SkipTestsListener.java new file mode 100644 index 00000000000..cad279b4863 --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/listener/SkipTestsListener.java @@ -0,0 +1,39 @@ +package io.jans.configapi.core.test.listener; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.stream.Stream; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.testng.IAnnotationTransformer; +import org.testng.annotations.ITestAnnotation; + +public class SkipTestsListener implements IAnnotationTransformer { + + private Logger logger = LogManager.getLogger(getClass()); + + public void transform(ITestAnnotation annotation, Class testClass, + Constructor testConstructor, Method testMethod) { + + if (testMethod != null) { + // Try to find SkipTest annotation at method level or at class level + SkipTest skipper = testMethod.getAnnotation(SkipTest.class); + + if (skipper == null) { + skipper = testMethod.getDeclaringClass().getAnnotation(SkipTest.class); + } + + if (skipper != null) { + // Search for a match with value of BaseTest.persistenceType (it's computed before suite) + boolean disable = Stream.of(skipper.databases()) + .map(PersistenceType::fromString).anyMatch(AlterSuiteListener.persistenceType::equals); + + if (disable) { + logger.warn("Disabling test method {}", testMethod.getName()); + annotation.setEnabled(false); + } + } + } + } + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/HttpService.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/HttpService.java new file mode 100644 index 00000000000..43b2bcad8fe --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/HttpService.java @@ -0,0 +1,352 @@ +/* + * 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.configapi.core.test.service; + +import io.jans.model.net.HttpServiceResponse; +import io.jans.util.StringHelper; + +import java.io.File; +import java.io.IOException; +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.Map; +import java.util.Map.Entry; + +import javax.net.ssl.SSLContext; + +import jakarta.annotation.PostConstruct; +import jakarta.servlet.http.HttpServletRequest; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import org.apache.commons.codec.binary.Base64; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.client.HttpClient; +import org.apache.http.client.config.CookieSpecs; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.routing.HttpRoutePlanner; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.DefaultProxyRoutePlanner; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.ssl.SSLContexts; +import org.apache.http.ssl.TrustStrategy; +import org.apache.http.util.EntityUtils; + +public class HttpService implements Serializable { + + private static final long serialVersionUID = -2398422090669045605L; + protected transient Logger log = LogManager.getLogger(getClass()); + private static final String CON_STATS_STR = "Connection manager stats: {}"; + private transient Base64 base64; + + private transient PoolingHttpClientConnectionManager connectionManager; + + @PostConstruct + public void init() { + connectionManager = new PoolingHttpClientConnectionManager(); + connectionManager.setMaxTotal(200); // Increase max total connection to 200 + connectionManager.setDefaultMaxPerRoute(50); // Increase default max connection per route to 50 + + this.base64 = new Base64(); + } + + public CloseableHttpClient getHttpsClientTrustAll() + throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { + log.trace(CON_STATS_STR, connectionManager.getTotalStats()); + + TrustStrategy acceptingTrustStrategy = (cert, authType) -> true; + SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); + SSLConnectionSocketFactory sslConSocFactory = new SSLConnectionSocketFactory(sslContext, + NoopHostnameVerifier.INSTANCE); + + return HttpClients.custom().setSSLSocketFactory(sslConSocFactory) + .setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()) + .setConnectionManager(connectionManager).build(); + } + + public CloseableHttpClient getHttpsClient() { + return getHttpsClient(RequestConfig.custom().build()); + } + + public CloseableHttpClient getHttpsClient(RequestConfig requestConfig) { + log.trace(CON_STATS_STR, connectionManager.getTotalStats()); + + return HttpClients.custom() + .setDefaultRequestConfig(RequestConfig.copy(requestConfig).setCookieSpec(CookieSpecs.STANDARD).build()) + .setConnectionManager(connectionManager).build(); + } + + public CloseableHttpClient getHttpsClient(HttpRoutePlanner routerPlanner) { + log.trace(CON_STATS_STR, connectionManager.getTotalStats()); + + return getHttpsClient(RequestConfig.custom().build(), routerPlanner); + } + + public CloseableHttpClient getHttpsClient(RequestConfig requestConfig, HttpRoutePlanner routerPlanner) { + log.trace(CON_STATS_STR, connectionManager.getTotalStats()); + + return HttpClients.custom() + .setDefaultRequestConfig(RequestConfig.copy(requestConfig).setCookieSpec(CookieSpecs.STANDARD).build()) + .setConnectionManager(connectionManager).setRoutePlanner(routerPlanner).build(); + } + + public CloseableHttpClient getHttpsClient(String trustStorePath, String trustStorePassword) + throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, + IOException { + log.trace(CON_STATS_STR, connectionManager.getTotalStats()); + + SSLContext sslContext = SSLContexts.custom() + .loadTrustMaterial(new File(trustStorePath), trustStorePassword.toCharArray()).build(); + SSLConnectionSocketFactory sslConSocFactory = new SSLConnectionSocketFactory(sslContext); + + return HttpClients.custom().setSSLSocketFactory(sslConSocFactory) + .setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()) + .setConnectionManager(connectionManager).build(); + } + + public CloseableHttpClient getHttpsClient(String trustStorePath, String trustStorePassword, String keyStorePath, + String keyStorePassword) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, + CertificateException, IOException, UnrecoverableKeyException { + log.trace(CON_STATS_STR, connectionManager.getTotalStats()); + + SSLContext sslContext = SSLContexts.custom() + .loadTrustMaterial(new File(trustStorePath), trustStorePassword.toCharArray()) + .loadKeyMaterial(new File(keyStorePath), keyStorePassword.toCharArray(), keyStorePassword.toCharArray()) + .build(); + SSLConnectionSocketFactory sslConSocFactory = new SSLConnectionSocketFactory(sslContext); + + return HttpClients.custom().setSSLSocketFactory(sslConSocFactory) + .setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build()) + .setConnectionManager(connectionManager).build(); + } + + public HttpServiceResponse executePost(HttpClient httpClient, String uri, String authCode, + Map headers, String postData, ContentType contentType, String authType) { + + HttpPost httpPost = new HttpPost(uri); + + if (StringHelper.isEmpty(authType)) { + authType = "Basic "; + } else { + authType = authType + " "; + } + if (StringHelper.isNotEmpty(authCode)) { + httpPost.setHeader("Authorization", authType + authCode); + } + + if (contentType == null) { + contentType = ContentType.APPLICATION_JSON; + } + + if (headers != null) { + for (Entry headerEntry : headers.entrySet()) { + httpPost.setHeader(headerEntry.getKey(), headerEntry.getValue()); + } + } + + StringEntity stringEntity = new StringEntity(postData, contentType); + httpPost.setEntity(stringEntity); + + try { + HttpResponse httpResponse = httpClient.execute(httpPost); + + return new HttpServiceResponse(httpPost, httpResponse); + } catch (IOException ex) { + log.error("Failed to execute post request", ex); + } + + return null; + } + + public HttpServiceResponse executePost(HttpClient httpClient, String uri, String authCode, + Map headers, String postData) { + return executePost(httpClient, uri, authCode, headers, postData, null, null); + } + + public HttpServiceResponse executePost(HttpClient httpClient, String uri, String authCode, String postData, + ContentType contentType) { + return executePost(httpClient, uri, authCode, null, postData, contentType, null); + } + + public HttpServiceResponse executePost(String uri, String authCode, Map headers, String postData, + ContentType contentType, String authType) { + return executePost(this.getHttpsClient(), uri, authCode, null, postData, contentType, authType); + } + + public String encodeBase64(String value) { + return new String(base64.encode((value).getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); + } + + public String encodeUrl(String value) { + return URLEncoder.encode(value, StandardCharsets.UTF_8); + } + + public HttpServiceResponse executeGet(HttpClient httpClient, String requestUri, Map headers) { + HttpGet httpGet = new HttpGet(requestUri); + + if (headers != null) { + for (Entry headerEntry : headers.entrySet()) { + httpGet.setHeader(headerEntry.getKey(), headerEntry.getValue()); + } + } + + try { + HttpResponse httpResponse = httpClient.execute(httpGet); + + return new HttpServiceResponse(httpGet, httpResponse); + } catch (IOException ex) { + log.error("Failed to execute get request", ex); + } + + return null; + } + + public HttpServiceResponse executeGet(String requestUri, Map headers) { + HttpClient httpClient = this.getHttpsClient(); + return executeGet(httpClient, requestUri, headers); + } + + public HttpServiceResponse executeGet(HttpClient httpClient, String requestUri) { + return executeGet(httpClient, requestUri, null); + } + + public byte[] getResponseContent(HttpResponse httpResponse) throws IOException { + if ((httpResponse == null) || !isResponseStastusCodeOk(httpResponse)) { + return null; + } + + HttpEntity entity = httpResponse.getEntity(); + byte[] responseBytes = new byte[0]; + if (entity != null) { + responseBytes = EntityUtils.toByteArray(entity); + } + + // Consume response content + if (entity != null) { + EntityUtils.consume(entity); + } + + return responseBytes; + } + + public void consume(HttpResponse httpResponse) throws IOException { + if ((httpResponse == null) || !isResponseStastusCodeOk(httpResponse)) { + return; + } + + // Consume response content + HttpEntity entity = httpResponse.getEntity(); + if (entity != null) { + EntityUtils.consume(entity); + } + } + + public String convertEntityToString(byte[] responseBytes) { + if (responseBytes == null) { + return null; + } + + return new String(responseBytes); + } + + public String convertEntityToString(byte[] responseBytes, Charset charset) { + if (responseBytes == null) { + return null; + } + + return new String(responseBytes, charset); + } + + public String convertEntityToString(byte[] responseBytes, String charsetName) throws UnsupportedEncodingException { + if (responseBytes == null) { + return null; + } + + return new String(responseBytes, charsetName); + } + + public boolean isResponseStastusCodeOk(HttpResponse httpResponse) { + int responseStastusCode = httpResponse.getStatusLine().getStatusCode(); + if ((responseStastusCode == HttpStatus.SC_OK) || (responseStastusCode == HttpStatus.SC_CREATED) + || (responseStastusCode == HttpStatus.SC_ACCEPTED) + || (responseStastusCode == HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION) + || (responseStastusCode == HttpStatus.SC_NO_CONTENT) + || (responseStastusCode == HttpStatus.SC_RESET_CONTENT) + || (responseStastusCode == HttpStatus.SC_PARTIAL_CONTENT) + || (responseStastusCode == HttpStatus.SC_MULTI_STATUS)) { + return true; + } else { + return false; + } + } + + public boolean isResponseStatusCodeOk(HttpResponse httpResponse) { + return isResponseStastusCodeOk(httpResponse); + } + + public boolean isContentTypeXml(HttpResponse httpResponse) { + Header contentType = httpResponse.getEntity().getContentType(); + if (contentType == null) { + return false; + } + + String contentTypeValue = contentType.getValue(); + if (StringHelper.equals(contentTypeValue, ContentType.APPLICATION_XML.getMimeType()) + || StringHelper.equals(contentTypeValue, ContentType.TEXT_XML.getMimeType())) { + return true; + } else { + return false; + } + } + + public String constructServerUrl(final HttpServletRequest request) { + int serverPort = request.getServerPort(); + + String redirectUrl; + if ((serverPort == 80) || (serverPort == 443)) { + redirectUrl = String.format("%s://%s%s", request.getScheme(), request.getServerName(), + request.getContextPath()); + } else { + redirectUrl = String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), + request.getServerPort(), request.getContextPath()); + } + + return redirectUrl.toLowerCase(); + } + + public HttpRoutePlanner buildDefaultRoutePlanner(final String hostname, final int port, final String scheme) { + // Creating an HttpHost object for proxy + HttpHost proxyHost = new HttpHost(hostname, port, scheme); + + return new DefaultProxyRoutePlanner(proxyHost); + } + + public HttpRoutePlanner buildDefaultRoutePlanner(final String proxy) { + return buildDefaultRoutePlanner(proxy, -1, null); + } + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/ResteasyService.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/ResteasyService.java new file mode 100644 index 00000000000..e21bdfa8d41 --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/ResteasyService.java @@ -0,0 +1,34 @@ +/* + * 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.configapi.core.test.service; + +import java.io.Serializable; + + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import jakarta.ws.rs.client.ClientBuilder; + +import jakarta.ws.rs.client.Invocation.Builder; + + + + +public class ResteasyService implements Serializable { + + private static final long serialVersionUID = 1L; + protected Logger logger = LogManager.getLogger(getClass()); + + + public Builder getClientBuilder(String url) { + return ClientBuilder.newClient().target(url).request(); + } + + + +} diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/TokenService.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/TokenService.java new file mode 100644 index 00000000000..6a6d2251080 --- /dev/null +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/test/service/TokenService.java @@ -0,0 +1,151 @@ +/* + * 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.configapi.core.test.service; + +import io.jans.as.client.TokenRequest; +import io.jans.as.client.TokenResponse; +import io.jans.as.model.common.GrantType; +import io.jans.as.model.util.Util; +import io.jans.configapi.core.util.Jackson; +import io.jans.configapi.core.test.service.HttpService; +import io.jans.configapi.core.test.service.ResteasyService; +import io.jans.configapi.core.test.service.TokenService; + +import static java.nio.charset.StandardCharsets.UTF_8; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; + +import java.util.Hashtable; +import java.util.Map; +import java.util.Properties; +import java.net.URLEncoder; +import java.io.UnsupportedEncodingException; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.*; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.time.Duration; +import java.util.*; +import java.util.Map.Entry; + +import jakarta.servlet.http.HttpServletRequest; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.CookieStore; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.routing.HttpRoutePlanner; +import org.apache.http.client.config.CookieSpecs; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.entity.ContentType; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.client.LaxRedirectStrategy; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.ssl.SSLContexts; + +import org.jboss.resteasy.client.jaxrs.ClientHttpEngine; +import org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine; +import org.jboss.resteasy.client.jaxrs.ResteasyClient; +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import jakarta.annotation.PostConstruct; +import jakarta.ws.rs.core.UriBuilder; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation.Builder; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MultivaluedHashMap; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; + +public class TokenService implements Serializable { + + private static final long serialVersionUID = 1L; + private Logger log = LogManager.getLogger(getClass()); + private static final String CONTENT_TYPE = "Content-Type"; + private static final String AUTHORIZATION = "Authorization"; + private static final String AUTHORIZATION_TYPE = "Bearer"; + + public String getToken(final String tokenUrl, final String clientId, final String clientSecret, GrantType grantType, + final String scopes) { + log.info("Request for token tokenUrl:{}, clientId:{}, grantType:{}, scopes:{}", tokenUrl, clientId, grantType, + scopes); + String accessToken = null; + TokenResponse tokenResponse = this.requestAccessToken(tokenUrl, clientId, clientSecret, grantType, scopes); + if (tokenResponse != null) { + accessToken = tokenResponse.getAccessToken(); + log.trace("accessToken:{}, ", accessToken); + } + + return accessToken; + } + + public TokenResponse requestAccessToken(final String tokenUrl, final String clientId, final String clientSecret, + GrantType grantType, final String scope) { + log.info("Request for access token tokenUrl:{}, clientId:{},scope:{}", tokenUrl, clientId, scope); + Response response = null; + try { + if (grantType == null) { + grantType = GrantType.CLIENT_CREDENTIALS; + } + TokenRequest tokenRequest = new TokenRequest(grantType); + tokenRequest.setScope(scope); + tokenRequest.setAuthUsername(clientId); + tokenRequest.setAuthPassword(clientSecret); + Builder request = new ResteasyService().getClientBuilder(tokenUrl); + request.header(AUTHORIZATION, "Basic " + tokenRequest.getEncodedCredentials()); + request.header(CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); + final MultivaluedHashMap multivaluedHashMap = new MultivaluedHashMap<>( + tokenRequest.getParameters()); + response = request.post(Entity.form(multivaluedHashMap)); + log.trace("Response for Access Token - response:{}", response); + if (response.getStatus() == 200) { + String entity = response.readEntity(String.class); + TokenResponse tokenResponse = new TokenResponse(); + tokenResponse.setEntity(entity); + tokenResponse.injectDataFromJson(entity); + return tokenResponse; + } + } finally { + + if (response != null) { + response.close(); + } + } + return null; + } + +}