diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java index ea871dd9b3..95a3cf7c94 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/identity/integration/common/utils/ISIntegrationTest.java @@ -40,6 +40,7 @@ public class ISIntegrationTest { protected Log log = LogFactory.getLog(getClass()); protected AutomationContext isServer; protected String backendURL; + protected String serverURL; protected String sessionCookie; protected Tenant tenantInfo; protected User userInfo; @@ -54,6 +55,7 @@ protected void init() throws Exception { protected void init(TestUserMode userMode) throws Exception { isServer = new AutomationContext("IDENTITY", userMode); backendURL = isServer.getContextUrls().getBackEndUrl(); + serverURL = backendURL.replace("services/", ""); loginLogoutClient = new LoginLogoutClient(isServer); sessionCookie = loginLogoutClient.login(); identityContextUrls = isServer.getContextUrls(); @@ -66,6 +68,7 @@ protected void init(String instance, String domainKey, String userKey) throws Ex loginLogoutClient = new LoginLogoutClient(isServer); sessionCookie = loginLogoutClient.login(); backendURL = isServer.getContextUrls().getBackEndUrl(); + serverURL = backendURL.replace("services/", ""); } protected String login() throws Exception{ @@ -86,6 +89,7 @@ protected void initPublisher(String productGroupName, String instanceName, TestU throws XPathExpressionException { isServer = new AutomationContext(productGroupName, instanceName, userMode); backendURL = isServer.getContextUrls().getBackEndUrl(); + serverURL = backendURL.replace("services/", ""); } protected String getBackendURL() throws XPathExpressionException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockEnabledTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockEnabledTestCase.java index 50286eea7e..739c530778 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockEnabledTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/identity/mgt/AccountLockEnabledTestCase.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, @@ -18,8 +18,7 @@ package org.wso2.identity.integration.test.identity.mgt; -import junit.framework.Assert; -import org.apache.commons.lang.ArrayUtils; +import org.testng.Assert; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,91 +29,84 @@ import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; import org.wso2.carbon.automation.engine.annotations.SetEnvironment; import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider; -import org.wso2.carbon.identity.core.util.IdentityUtil; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.um.ws.api.stub.ClaimValue; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; import org.wso2.identity.integration.common.utils.ISIntegrationTest; import org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorsPatchReq; import org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorsPatchReq.OperationEnum; import org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyReq; +import org.wso2.identity.integration.test.rest.api.user.common.model.ListObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.RoleItemAddGroupobj; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; +import org.wso2.identity.integration.test.restclients.AuthenticatorRestClient; import org.wso2.identity.integration.test.restclients.EmailTemplatesRestClient; import org.wso2.identity.integration.test.restclients.IdentityGovernanceRestClient; +import org.wso2.identity.integration.test.restclients.SCIM2RestClient; public class AccountLockEnabledTestCase extends ISIntegrationTest { private static final Log log = LogFactory.getLog(AccountLockEnabledTestCase.class.getName()); + private static final String DEFAULT_LOCALITY_CLAIM_VALUE = "en_US"; + private static final String TEST_LOCK_USER_1 = "TestLockUser1"; + private static final String TEST_LOCK_USER_1_PASSWORD = "TestLockUser1Password"; + private static final String TEST_LOCK_USER_1_WRONG_PASSWORD = "TestLockUser1WrongPassword"; + private static final String TEST_LOCK_USER_2 = "TestLockUser2"; + private static final String TEST_LOCK_USER_2_PASSWORD = "TestLockUser2Password"; + private static final String TEST_LOCK_USER_3 = "TestLockUser3"; + private static final String TEST_LOCK_USER_3_PASSWORD = "TestLockUser3Password"; + + private static final String ACCOUNT_LOCK_TEMPLATE_WHEN_USER_EXCEEDS_FAILED_ATTEMPTS = "accountlockfailedattempt"; + private static final String ACCOUNT_LOCK_TEMPLATE_WHEN_ADMIN_TRIGGERED = "accountlockadmin"; + private static final String ACCOUNT_UNLOCK_TEMPLATE_ADMIN_TRIGGERED = "accountunlockadmin"; + private static final String ACCOUNT_UNLOCK_TEMPLATE_TIME_BASED = "accountunlocktimebased"; + private static final String ACCOUNT_LOCK_ATTRIBUTE = "accountLocked"; + private static final String ENABLE_ACCOUNT_LOCK = "account.lock.handler.lock.on.max.failed.attempts.enable"; + private static final String CATEGORY_LOGIN_ATTEMPTS_SECURITY = "TG9naW4gQXR0ZW1wdHMgU2VjdXJpdHk"; + private static final String CONNECTOR_ACCOUNT_LOCK_HANDLER = "YWNjb3VudC5sb2NrLmhhbmRsZXI"; + private static final String LOCALE_ATTRIBUTE = "locale"; + private static final String USERS_PATH = "users"; + private static final String USER_SCHEMA = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"; - private String defaultLocalityClaimUri = IdentityUtil.getClaimUriLocale(); - private String accountLockClaimUri = "http://wso2.org/claims/identity/accountLocked"; - private String defaultLocalityClaimValue = "en_us"; - private String registryResourcePath = "/_system/config/identity/email/"; - - private String testLockUser1 = "TestLockUser1"; - private String testLockUser1Password = "TestLockUser1Password"; - private String testLockUser1WrongPassword = "TestLockUser1WrongPassword"; - private String testLockUser2 = "TestLockUser2"; - private String testLockUser2Password = "TestLockUser2Password"; - private String testLockUser3 = "TestLockUser3"; - private String testLockUser3Password = "TestLockUser3Password"; - - private String accountLockTemplateWhenUserExceedsFailedAttempts = "accountlockfailedattempt"; - private String accountLockTemplateWhenAdminTriggered = "accountlockadmin"; - private String accountUnlockTemplateAdminTriggered = "accountunlockadmin"; - private String accountUnlockTemplateTimeBased = "accountunlocktimebased"; - - private AuthenticatorClient authenticatorClient; - private RemoteUserStoreManagerServiceClient usmClient; + + private SCIM2RestClient scim2RestClient; + private AuthenticatorRestClient authenticatorRestClient; private EmailTemplatesRestClient emailTemplatesRestClient; private IdentityGovernanceRestClient identityGovernanceRestClient; private ConnectorsPatchReq connectorPatchRequest; - private static final String ENABLE_ACCOUNT_LOCK = "account.lock.handler.lock.on.max.failed.attempts.enable"; - private static final String CATEGORY_LOGIN_ATTEMPTS_SECURITY = "TG9naW4gQXR0ZW1wdHMgU2VjdXJpdHk"; - private static final String CONNECTOR_ACCOUNT_LOCK_HANDLER = "YWNjb3VudC5sb2NrLmhhbmRsZXI"; - private static final String TRUE_STRING = "true"; - private static final String DEFAULT = "default"; - private static final String USER_LOCALE = "en_US"; + private String testLockUserId; + private String testLockUser2Id; + private String testLockUser3Id; @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(); - authenticatorClient = new AuthenticatorClient(backendURL); - enableAccountLocking(ENABLE_ACCOUNT_LOCK); - usmClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); - emailTemplatesRestClient = new EmailTemplatesRestClient(backendURL.replace("services/", - ""), tenantInfo); + authenticatorRestClient = new AuthenticatorRestClient(serverURL); + enableAccountLocking(); + scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); + emailTemplatesRestClient = new EmailTemplatesRestClient(serverURL, tenantInfo); } @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) @Test(groups = "wso2.is", description = "Check whether the user account lock successfully") public void testSuccessfulLockedInitially() { try { - usmClient.addUser(testLockUser1, testLockUser1Password, new String[]{"admin"}, new ClaimValue[0], null, false); + testLockUserId = addAdminUser(TEST_LOCK_USER_1, TEST_LOCK_USER_1_PASSWORD, null); int maximumAllowedFailedLogins = 5; for (int i = 0; i < maximumAllowedFailedLogins; i++) { - try { - authenticatorClient.login(testLockUser1, testLockUser1WrongPassword, "localhost"); - } catch (Exception e) { - log.error("Login attempt: " + i + " for user: " + testLockUser1 + " failed"); - } - } - - ClaimValue[] claimValues = usmClient.getUserClaimValuesForClaims(testLockUser1, new String[] - {accountLockClaimUri}, "default"); + JSONObject response = authenticatorRestClient.login(TEST_LOCK_USER_1, TEST_LOCK_USER_1_WRONG_PASSWORD); - String userAccountLockClaimValue = null; - - if (ArrayUtils.isNotEmpty(claimValues)) { - userAccountLockClaimValue = claimValues[0].getValue(); + if (!response.containsKey("token")) { + log.error("Login attempt: " + i + " for user: " + TEST_LOCK_USER_1 + " failed"); + } } - Assert.assertTrue - ("Test Failure : User Account Didn't Locked Properly", Boolean.valueOf(userAccountLockClaimValue)); + JSONObject userParameters = (JSONObject) scim2RestClient.getUser(testLockUserId).get(USER_SCHEMA); + Assert.assertTrue((Boolean) userParameters.get(ACCOUNT_LOCK_ATTRIBUTE), + "Test Failure : User Account Didn't Locked Properly"); } catch (Exception e) { log.error("Error occurred when locking the test user.", e); } @@ -127,22 +119,18 @@ public void testSuccessfulLockedInitially() { dependsOnMethods = "testSuccessfulLockedInitially") public void testSuccessfulEmailTemplateRetrieval() throws Exception { - ClaimValue claimValue = new ClaimValue(); - claimValue.setClaimURI(defaultLocalityClaimUri); - claimValue.setValue(defaultLocalityClaimValue); - ClaimValue[] claimvalues = { claimValue }; - usmClient.addUser(testLockUser2, testLockUser2Password, new String[] { "admin" }, claimvalues, null, false); + testLockUser2Id = addAdminUser(TEST_LOCK_USER_2, TEST_LOCK_USER_2_PASSWORD, DEFAULT_LOCALITY_CLAIM_VALUE); + String locale = scim2RestClient.getUser(testLockUser2Id).get(LOCALE_ATTRIBUTE).toString(); JSONObject emailTemplateResourceContent = - emailTemplatesRestClient.getEmailTemplate(accountLockTemplateWhenUserExceedsFailedAttempts, - USER_LOCALE); - Assert.assertTrue("Test Failure : Email Content applicable for account lock is not available.", - StringUtils.isNotEmpty((String) emailTemplateResourceContent.get("body"))); + emailTemplatesRestClient.getEmailTemplate(ACCOUNT_LOCK_TEMPLATE_WHEN_USER_EXCEEDS_FAILED_ATTEMPTS, locale); + Assert.assertTrue(StringUtils.isNotEmpty((String) emailTemplateResourceContent.get("body")), + "Test Failure : Email Content applicable for account lock is not available."); JSONObject emailTemplateResourceContentAdminTriggered = - emailTemplatesRestClient.getEmailTemplate(accountLockTemplateWhenAdminTriggered, USER_LOCALE); - Assert.assertTrue("Test Failure : Email Content applicable for account lock is not available.", - StringUtils.isNotEmpty((String) emailTemplateResourceContentAdminTriggered.get("body"))); + emailTemplatesRestClient.getEmailTemplate(ACCOUNT_LOCK_TEMPLATE_WHEN_ADMIN_TRIGGERED, locale); + Assert.assertTrue(StringUtils.isNotEmpty((String) emailTemplateResourceContentAdminTriggered.get("body")), + "Test Failure : Email Content applicable for account lock is not available."); } @SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL }) @@ -151,48 +139,43 @@ public void testSuccessfulEmailTemplateRetrieval() throws Exception { + "template successfully retrieved when admin triggered account lock.") public void testSuccessfulEmailTemplateRetrievalAccountUnLock() throws Exception { - ClaimValue claimValue = new ClaimValue(); - claimValue.setClaimURI(defaultLocalityClaimUri); - claimValue.setValue(defaultLocalityClaimValue); - ClaimValue[] claimvalues = { claimValue }; - usmClient.addUser(testLockUser3, testLockUser3Password, new String[] { "admin" }, claimvalues, null, false); - - JSONObject emailTemplateResourceContent = - emailTemplatesRestClient.getEmailTemplate(accountUnlockTemplateTimeBased, USER_LOCALE); - Assert.assertTrue("Test Failure : Email Content applicable for account unlock is not available.", - StringUtils.isNotEmpty((String) emailTemplateResourceContent.get("body"))); - - JSONObject emailTemplateResourceContentAdminTriggered = - emailTemplatesRestClient.getEmailTemplate(accountUnlockTemplateAdminTriggered, USER_LOCALE); - Assert.assertTrue("Test Failure : Email Content applicable for account unlock is not available.", - StringUtils.isNotEmpty((String) emailTemplateResourceContentAdminTriggered.get("body"))); + testLockUser3Id = addAdminUser(TEST_LOCK_USER_3, TEST_LOCK_USER_3_PASSWORD, DEFAULT_LOCALITY_CLAIM_VALUE); + String locale = scim2RestClient.getUser(testLockUser3Id).get(LOCALE_ATTRIBUTE).toString(); + + JSONObject emailTemplateResourceContent = + emailTemplatesRestClient.getEmailTemplate(ACCOUNT_UNLOCK_TEMPLATE_TIME_BASED, locale); + Assert.assertTrue(StringUtils.isNotEmpty((String) emailTemplateResourceContent.get("body")), + "Test Failure : Email Content applicable for account unlock is not available."); + + JSONObject emailTemplateResourceContentAdminTriggered = + emailTemplatesRestClient.getEmailTemplate(ACCOUNT_UNLOCK_TEMPLATE_ADMIN_TRIGGERED, locale); + Assert.assertTrue(StringUtils.isNotEmpty((String) emailTemplateResourceContentAdminTriggered.get("body")), + "Test Failure : Email Content applicable for account unlock is not available."); } @SetEnvironment(executionEnvironments = {ExecutionEnvironment.ALL}) @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - usmClient.deleteUser(testLockUser1); - usmClient.deleteUser(testLockUser2); - disableAccountLocking(ENABLE_ACCOUNT_LOCK); + scim2RestClient.deleteUser(testLockUserId); + scim2RestClient.deleteUser(testLockUser2Id); + scim2RestClient.deleteUser(testLockUser3Id); + disableAccountLocking(); emailTemplatesRestClient.closeHttpClient(); identityGovernanceRestClient.closeHttpClient(); + scim2RestClient.closeHttpClient(); + authenticatorRestClient.closeHttpClient(); } protected String getISResourceLocation() { return TestConfigurationProvider.getResourceLocation("IS"); } - protected void enableAccountLocking(String option) throws Exception { + protected void enableAccountLocking() throws Exception { identityGovernanceRestClient = new IdentityGovernanceRestClient(backendURL.replace("services/", ""), tenantInfo); - Thread.sleep(5000); - authenticatorClient.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), - isServer.getSuperTenant().getTenantAdmin().getPassword(), - isServer.getInstance().getHosts().get(DEFAULT)); - PropertyReq property = new PropertyReq(); - property.setName(option); + property.setName(ENABLE_ACCOUNT_LOCK); property.setValue("true"); connectorPatchRequest = new ConnectorsPatchReq(); @@ -203,10 +186,27 @@ protected void enableAccountLocking(String option) throws Exception { connectorPatchRequest); } - protected void disableAccountLocking(String option) throws Exception { + protected void disableAccountLocking() throws Exception { connectorPatchRequest.getProperties().get(0).setValue("false"); identityGovernanceRestClient.updateConnectors(CATEGORY_LOGIN_ATTEMPTS_SECURITY , CONNECTOR_ACCOUNT_LOCK_HANDLER, connectorPatchRequest); } + protected String addAdminUser(String username, String password, String locale) throws Exception { + UserObject userInfo = new UserObject(); + userInfo.setUserName(username); + userInfo.setPassword(password); + userInfo.setLocale(locale); + + String userId = scim2RestClient.createUser(userInfo); + String roleId = scim2RestClient.getRoleIdByName("admin"); + + RoleItemAddGroupobj patchRoleItem = new RoleItemAddGroupobj(); + patchRoleItem.setOp(RoleItemAddGroupobj.OpEnum.ADD); + patchRoleItem.setPath(USERS_PATH); + patchRoleItem.addValue(new ListObject().value(userId)); + + scim2RestClient.updateUserRole(new PatchOperationRequestObject().addOperations(patchRoleItem), roleId); + return userId; + } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2BackChannelLogoutTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2BackChannelLogoutTestCase.java index 2ee2b3878c..a4b06b508c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2BackChannelLogoutTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2BackChannelLogoutTestCase.java @@ -1,8 +1,8 @@ /* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 LLC. (http://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * @@ -18,7 +18,6 @@ package org.wso2.identity.integration.test.oauth2; -import org.apache.commons.lang.StringUtils; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; @@ -36,16 +35,18 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Factory; import org.testng.annotations.Test; -import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig; -import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig; -import org.wso2.carbon.identity.application.common.model.xsd.Property; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.um.ws.api.stub.ClaimValue; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OIDCLogoutConfiguration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.rest.api.user.common.model.Email; +import org.wso2.identity.integration.test.rest.api.user.common.model.ListObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.RoleItemAddGroupobj; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; +import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.CommonConstants; import org.wso2.identity.integration.test.utils.DataExtractUtil; @@ -53,6 +54,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -66,23 +68,21 @@ public class OAuth2BackChannelLogoutTestCase extends OAuth2ServiceAbstractIntegr private HttpClient client; private final String OIDC_APP_NAME = "playground2"; - private String oidcAppClientId = ""; - private String oidcAppClientSecret = ""; - private OauthAdminClient adminClient; - private ApplicationManagementServiceClient applicationManagementServiceClient; + private String oidcAppClientId; private String sessionDataKeyConsent; private String sessionDataKey; - private final String CONSENT = "consent"; - private final String APPROVE = "approve"; - private final String SCOPE_APPROVAL = "scope-approval"; - private final String USER_AGENT = "User-Agent"; - private final String username; - private final String userPassword; - private final String activeTenant; + private static final String CONSENT = "consent"; + private static final String APPROVE = "approve"; + private static final String SCOPE_APPROVAL = "scope-approval"; + private static final String USER_AGENT = "User-Agent"; + private static final String USERS_PATH = "users"; private static final String USER_EMAIL = "abc@wso2.com"; private static final String USERNAME = "testUser"; private static final String PASSWORD = "pass123"; + private String applicationId; + private SCIM2RestClient scim2RestClient; + private String userId; @DataProvider(name = "configProvider") public static Object[][] configProvider() { @@ -93,38 +93,23 @@ public static Object[][] configProvider() { public OAuth2BackChannelLogoutTestCase(TestUserMode userMode) throws Exception { super.init(userMode); - AutomationContext context = new AutomationContext("IDENTITY", userMode); - this.username = context.getContextTenant().getTenantAdmin().getUserName(); - this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); - this.activeTenant = context.getContextTenant().getDomain(); } @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - init(); client = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore()).build(); - createOIDCApplication(); - createServiceProvider(); - - remoteUSMServiceClient.addUser(USERNAME, PASSWORD, new String[]{"admin"}, - getUserClaims(), "default", true); + scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); + createOIDCApplication(); + addAdminUser(); } @AfterClass(alwaysRun = true) public void testCleanUp() throws Exception { removeApplications(); - - remoteUSMServiceClient.deleteUser(USERNAME); - } - - protected void init() throws Exception { - - super.init(); - adminClient = new OauthAdminClient(backendURL, sessionCookie); - applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); + scim2RestClient.deleteUser(userId); } @Test(groups = "wso2.is", description = "Test back channel logout for OIDC.") @@ -140,25 +125,38 @@ public void testOIDCLogout() throws IOException { } private void createOIDCApplication() throws Exception { + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL); - OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO(); - appDTO.setApplicationName(OIDC_APP_NAME); - appDTO.setCallbackUrl(OAuth2Constant.CALLBACK_URL); - appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appDTO.setGrantTypes(OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE); - appDTO.setBackChannelLogoutUrl("http://localhost:" + DEFAULT_TOMCAT_PORT + "/playground2/bclogout"); - - adminClient.registerOAuthApplicationData(appDTO); - OAuthConsumerAppDTO createdApp = adminClient.getOAuthAppByName(OIDC_APP_NAME); - Assert.assertNotNull(createdApp, "Adding OIDC app failed."); - oidcAppClientId = createdApp.getOauthConsumerKey(); - oidcAppClientSecret = createdApp.getOauthConsumerSecret(); + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + oidcConfig.setLogout(new OIDCLogoutConfiguration().backChannelLogoutUrl("http://localhost:" + + DEFAULT_TOMCAT_PORT + "/playground2/bclogout")); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OIDC_APP_NAME); + + String appId = addApplication(application); + ApplicationResponseModel createdApplication = getApplication(appId); + + applicationId = createdApplication.getId(); + oidcConfig = getOIDCInboundDetailsOfApplication(applicationId); + + oidcAppClientId = oidcConfig.getClientId(); } private void removeApplications() throws Exception { - adminClient.removeOAuthApplicationData(oidcAppClientId); - applicationManagementServiceClient.deleteApplication(OIDC_APP_NAME); + deleteApp(applicationId); } private void initiateOIDCRequest(boolean isCheckLogoutConfirmation) throws IOException { @@ -281,7 +279,7 @@ public HttpResponse sendPostRequestWithParameters(List urlParamet private List getOIDCInitiationRequestParams() { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE)); urlParameters.add(new BasicNameValuePair("consumerKey", oidcAppClientId)); urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL)); @@ -291,40 +289,20 @@ private List getOIDCInitiationRequestParams() { return urlParameters; } - private ServiceProvider createServiceProvider() throws Exception { - - ServiceProvider serviceProvider = new ServiceProvider(); - serviceProvider.setApplicationName(OIDC_APP_NAME); - serviceProvider.setManagementApp(true); - applicationManagementServiceClient.createApplication(serviceProvider); - serviceProvider = applicationManagementServiceClient.getApplication(OIDC_APP_NAME); - - InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig(); - requestConfig.setInboundAuthKey(oidcAppClientId); - requestConfig.setInboundAuthType("oauth2"); - if (StringUtils.isNotBlank(oidcAppClientSecret)) { - Property property = new Property(); - property.setName("oauthConsumerSecret"); - property.setValue(oidcAppClientSecret); - Property[] properties = {property}; - requestConfig.setProperties(properties); - } + private void addAdminUser() throws Exception { + UserObject userInfo = new UserObject(); + userInfo.setUserName(USERNAME); + userInfo.setPassword(PASSWORD); + userInfo.addEmail(new Email().value(USER_EMAIL)); - InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig(); - inboundAuthenticationConfig - .setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[]{requestConfig}); - serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig); - applicationManagementServiceClient.updateApplicationData(serviceProvider); - return serviceProvider; - } + userId = scim2RestClient.createUser(userInfo); + String roleId = scim2RestClient.getRoleIdByName("admin"); - protected ClaimValue[] getUserClaims() { + RoleItemAddGroupobj patchRoleItem = new RoleItemAddGroupobj(); + patchRoleItem.setOp(RoleItemAddGroupobj.OpEnum.ADD); + patchRoleItem.setPath(USERS_PATH); + patchRoleItem.addValue(new ListObject().value(userId)); - ClaimValue[] claimValues = new ClaimValue[1]; - ClaimValue email = new ClaimValue(); - email.setClaimURI(EMAIL_CLAIM_URI); - email.setValue(USER_EMAIL); - claimValues[0] = email; - return claimValues; + scim2RestClient.updateUserRole(new PatchOperationRequestObject().addOperations(patchRoleItem), roleId); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2DeviceFlowTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2DeviceFlowTestCase.java index 5068e3fe95..67631ca0e1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2DeviceFlowTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2DeviceFlowTestCase.java @@ -1,30 +1,31 @@ /* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.wso2.identity.integration.test.oauth2; -import org.apache.commons.codec.binary.Base64; import org.apache.http.Header; import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.json.simple.JSONObject; @@ -36,8 +37,10 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.CommonConstants; import org.wso2.identity.integration.test.utils.DataExtractUtil; @@ -47,6 +50,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -64,20 +68,17 @@ public class OAuth2DeviceFlowTestCase extends OAuth2ServiceAbstractIntegrationTe private String sessionDataKey; private String consumerKey; private String consumerSecret; + private String appId; private String userCode; private String deviceCode; + private CloseableHttpClient client; - private DefaultHttpClient client; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - AuthenticatorClient logManger = new AuthenticatorClient(backendURL); - logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), - isServer.getSuperTenant().getTenantAdmin().getPassword(), - isServer.getInstance().getHosts().get("default")); - client = new DefaultHttpClient(); + client = HttpClients.createDefault(); setSystemproperties(); } @@ -85,20 +86,28 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + deleteApp(appId); + consumerKey = null; + consumerSecret = null; + appId = null; + client.close(); + restClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApp(); - Assert.assertNotNull(appDto, "Application creation failed."); + ApplicationResponseModel application = createApp(); + Assert.assertNotNull(application, "OAuth App creation failed."); - consumerKey = appDto.getOauthConsumerKey(); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); + + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); + appId = application.getId(); } @Test(groups = "wso2.is", description = "Send authorize user request without redirect_uri param", dependsOnMethods @@ -108,7 +117,8 @@ public void testSendDeviceAuthorize() throws Exception { List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair(CLIENT_ID_PARAM, consumerKey)); urlParameters.add(new BasicNameValuePair(SCOPE_PLAYGROUND_NAME, "device")); - AutomationContext automationContext = new AutomationContext("IDENTITY", TestUserMode.SUPER_TENANT_ADMIN); + AutomationContext automationContext = new AutomationContext("IDENTITY", + TestUserMode.SUPER_TENANT_ADMIN); String deviceAuthEndpoint = automationContext.getContextUrls().getBackEndUrl() .replace("services/", "oauth2/device_authorize"); JSONObject responseObject = responseObjectNew(urlParameters, deviceAuthEndpoint); @@ -129,9 +139,10 @@ public void testNonUsedDeviceTokenRequest() throws Exception { @Test(groups = "wso2.is", description = "Send authorize user request", dependsOnMethods = "testSendDeviceAuthorize") public void testSendDeviceAuthorozedPost() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair(USER_CODE, userCode)); - AutomationContext automationContext = new AutomationContext("IDENTITY", TestUserMode.SUPER_TENANT_ADMIN); + AutomationContext automationContext = new AutomationContext("IDENTITY", + TestUserMode.SUPER_TENANT_ADMIN); String authenticationEndpoint = automationContext.getContextUrls().getBackEndUrl() .replace("services/", "authenticationendpoint/device.do"); String response = responsePost(urlParameters,authenticationEndpoint); @@ -143,7 +154,8 @@ public void testDevicePost() throws Exception { List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair(USER_CODE, userCode)); - AutomationContext automationContext = new AutomationContext("IDENTITY", TestUserMode.SUPER_TENANT_ADMIN); + AutomationContext automationContext = new AutomationContext("IDENTITY", + TestUserMode.SUPER_TENANT_ADMIN); String deviceEndpoint = automationContext.getContextUrls().getBackEndUrl() .replace("services/", "oauth2/device"); HttpResponse response = sendPostRequestWithParameters(client, urlParameters, deviceEndpoint); @@ -156,7 +168,7 @@ public void testDevicePost() throws Exception { response = sendGetRequest(client, locationHeader.getValue()); Assert.assertNotNull(response, "Authorized user response is null."); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"sessionDataKey\"", 1); List keyValues = DataExtractUtil.extractDataFromResponse(response, keyPositionMap); @@ -189,7 +201,7 @@ public void testSendLoginPost() throws Exception { EntityUtils.consume(response.getEntity()); response = sendGetRequest(client, locationHeader.getValue()); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"" + OAuth2Constant.SESSION_DATA_KEY_CONSENT + "\"", 1); List keyValues = DataExtractUtil.extractSessionConsentDataFromResponse(response, @@ -228,7 +240,8 @@ public void testTokenRequest() throws Exception { Assert.assertNotNull(accessToken, "Assess token is null"); } - @Test(groups = "wso2.is", description = "Send token post request with used code", dependsOnMethods = "testTokenRequest") + @Test(groups = "wso2.is", description = "Send token post request with used code", + dependsOnMethods = "testTokenRequest") public void testExpiredDeviceTokenRequest() throws Exception { // Wait 5 seconds because of the token polling interval. @@ -297,19 +310,34 @@ public HttpResponse sendGetRequest(HttpClient client, String locationURL) throws /** * Create Application with the given app configurations * - * @return OAuthConsumerAppDTO - * @throws Exception + * @return ApplicationResponseModel + * @throws Exception exception */ - private OAuthConsumerAppDTO createApp() throws Exception { - - OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO(); - appDTO.setApplicationName(OAuth2Constant.OAUTH_APPLICATION_NAME); - appDTO.setCallbackUrl(OAuth2Constant.CALLBACK_URL); - appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token " + - "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm " + - "urn:ietf:params:oauth:grant-type:device_code"); - appDTO.setBypassClientCredentials(true); - return createApplication(appDTO, SERVICE_PROVIDER_NAME); + private ApplicationResponseModel createApp() throws Exception { + + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "implicit", "password", "client_credentials", + "refresh_token", "urn:ietf:params:oauth:grant-type:saml2-bearer", "iwa:ntlm", + "urn:ietf:params:oauth:grant-type:device_code"); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + oidcConfig.setPublicClient(true); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OAuth2Constant.OAUTH_APPLICATION_NAME); + + String appId = addApplication(application); + + return getApplication(appId); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2IDTokenEncryptionTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2IDTokenEncryptionTestCase.java index 57ef26a1fa..b0cde8d123 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2IDTokenEncryptionTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2IDTokenEncryptionTestCase.java @@ -1,12 +1,12 @@ /* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2018, WSO2 LLC. (https://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -14,7 +14,6 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * */ package org.wso2.identity.integration.test.oauth2; @@ -53,16 +52,17 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.DataExtractUtil; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.security.KeyStore; import java.security.cert.Certificate; import java.security.cert.X509Certificate; @@ -91,6 +91,10 @@ public class OAuth2IDTokenEncryptionTestCase extends OAuth2ServiceAbstractIntegr private String sessionDataKeyConsent; private AuthorizationCode authorizationCode; private String idToken; + private String consumerKey; + private String consumerSecret; + private ApplicationResponseModel application; + private OpenIDConnectConfiguration oidcInboundConfig; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { @@ -101,15 +105,17 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + deleteApp(application.getId()); consumerKey = null; consumerSecret = null; spPrivateKey = null; spX509PublicCert = null; + application = null; + oidcInboundConfig = null; client.close(); + restClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Check Service Provider key generation.") @@ -124,10 +130,13 @@ public void testGenerateServiceProviderKeys() throws Exception { dependsOnMethods = "testGenerateServiceProviderKeys") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO oAuthConsumerAppDTO = getBasicOAuthApp(CALLBACK_URL); - ServiceProvider serviceProvider = registerServiceProviderWithOAuthInboundConfigs(oAuthConsumerAppDTO); - Assert.assertNotNull(serviceProvider, "OAuth App creation failed."); + application = getBasicOAuthApplication(CALLBACK_URL); + Assert.assertNotNull(application, "OAuth App creation failed."); + + oidcInboundConfig = getOIDCInboundDetailsOfApplication(application.getId()); + consumerKey = oidcInboundConfig.getClientId(); Assert.assertNotNull(consumerKey, "Consumer Key is null."); + consumerSecret = oidcInboundConfig.getClientSecret(); Assert.assertNotNull(consumerSecret, "Consumer Secret is null."); } @@ -135,32 +144,29 @@ public void testRegisterApplication() throws Exception { dependsOnMethods = "testRegisterApplication") public void updateServiceProviderCert() throws Exception { - ServiceProvider application = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); - Assert.assertNotNull(application, "Application: " + SERVICE_PROVIDER_NAME + " retrieval failed."); + updateApplicationCertificate(application.getId(), spX509PublicCert); - application.setCertificateContent(convertToPem(spX509PublicCert)); - appMgtclient.updateApplicationData(application); - - ServiceProvider updatedApp = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); - Assert.assertNotNull(updatedApp, "Updated application: " + SERVICE_PROVIDER_NAME + - " retrieval failed."); - Assert.assertNotNull(updatedApp.getCertificateContent(), "Updating application certificate failed."); + ApplicationResponseModel updatedApplication = getApplication(application.getId()); + Assert.assertNotNull(updatedApplication, "Application: " + application.getName() + " retrieval failed."); + Assert.assertNotNull(updatedApplication.getAdvancedConfigurations().getCertificate(), + "Application Certificate update failed"); } @Test(groups = "wso2.is", description = "Setup encryption algorithm and encryption method.", dependsOnMethods = "updateServiceProviderCert") public void testConfigureIDTokenEncryptionAlgorithms() throws Exception { - OAuthConsumerAppDTO consumerAppDTO = adminClient.getOAuthAppByConsumerKey(consumerKey); - consumerAppDTO.setIdTokenEncryptionEnabled(true); - consumerAppDTO.setIdTokenEncryptionAlgorithm(ENCRYPTION_ALGORITHM); - consumerAppDTO.setIdTokenEncryptionMethod(ENCRYPTION_METHOD); - adminClient.updateConsumerApp(consumerAppDTO); - OAuthConsumerAppDTO updateApp = adminClient.getOAuthAppByConsumerKey(consumerKey); - Assert.assertTrue(updateApp.getIdTokenEncryptionEnabled(), "Enforcing ID Token encryption failed."); - Assert.assertEquals(updateApp.getIdTokenEncryptionAlgorithm(), + oidcInboundConfig.getIdToken().getEncryption().setEnabled(true); + oidcInboundConfig.getIdToken().getEncryption().setAlgorithm(ENCRYPTION_ALGORITHM); + oidcInboundConfig.getIdToken().getEncryption().setMethod(ENCRYPTION_METHOD); + updateApplicationInboundConfig(application.getId(), oidcInboundConfig, OIDC); + + OpenIDConnectConfiguration updatedOidcInboundConfig = getOIDCInboundDetailsOfApplication(application.getId()); + Assert.assertTrue(updatedOidcInboundConfig.getIdToken().getEncryption().getEnabled(), + "Enforcing ID Token encryption failed."); + Assert.assertEquals(updatedOidcInboundConfig.getIdToken().getEncryption().getAlgorithm(), ENCRYPTION_ALGORITHM, "Configuring encryption algorithm failed."); - Assert.assertEquals(updateApp.getIdTokenEncryptionMethod(), + Assert.assertEquals(updatedOidcInboundConfig.getIdToken().getEncryption().getMethod(), ENCRYPTION_METHOD, "Configuring encryption method failed."); } @@ -407,7 +413,7 @@ private String getLocationHeaderValue(HttpResponse response) { /** * Initiate service provider keys required for the tests. * - * @throws Exception + * @throws Exception error */ private void initServiceProviderKeys() throws Exception { @@ -416,7 +422,7 @@ private void initServiceProviderKeys() throws Exception { File.separator + "keystores" + File.separator + "sp1KeyStore.jks"; String jksPassword = "wso2carbon"; - keyStore.load(new FileInputStream(jksPath), jksPassword.toCharArray()); + keyStore.load(Files.newInputStream(Paths.get(jksPath)), jksPassword.toCharArray()); String alias = "wso2carbon"; KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(alias, @@ -434,8 +440,8 @@ private void initServiceProviderKeys() throws Exception { * @param client CloseableHttpClient object to send the login post. * @param sessionDataKey String sessionDataKey obtained. * @return Extracted sessionDataKeyConsent. - * @throws IOException - * @throws URISyntaxException + * @throws IOException Error + * @throws URISyntaxException Error */ private String getSessionDataKeyConsent(CloseableHttpClient client, String sessionDataKey) throws IOException, URISyntaxException { @@ -467,8 +473,8 @@ private String getSessionDataKeyConsent(CloseableHttpClient client, String sessi * @param idToken Encrypted ID token to be decrypted and checked. * @param audience Audience value that should be appeared in the token. * @return Boolean True if audience matches, False otherwise. - * @throws ParseException - * @throws JOSEException + * @throws ParseException Error + * @throws JOSEException Error */ private boolean decryptAndCheckIDToken(String idToken, String audience) throws ParseException, JOSEException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RequestObjectSignatureValidationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RequestObjectSignatureValidationTestCase.java index 22ad2810a2..70bf1693b9 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RequestObjectSignatureValidationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RequestObjectSignatureValidationTestCase.java @@ -1,17 +1,19 @@ /* - * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2018, WSO2 LLC. (https://www.wso2.com). * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.wso2.identity.integration.test.oauth2; @@ -25,8 +27,10 @@ import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; import org.apache.http.client.params.HttpClientParams; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -34,32 +38,31 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.automation.test.utils.common.TestConfigurationProvider; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.*; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.io.File; -import java.io.FileInputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.security.KeyStore; -import java.security.cert.Certificate; import java.security.cert.X509Certificate; +import java.security.cert.Certificate; import java.security.interfaces.RSAPrivateKey; import java.util.Collections; import java.util.Date; import java.util.UUID; -/* +/** Integration tests for Signed Request Object validation. */ public class OAuth2RequestObjectSignatureValidationTestCase extends OAuth2ServiceAbstractIntegrationTest { private RSAPrivateKey sp1PrivateKey; - private X509Certificate sp1X509PublicCert; - private RSAPrivateKey sp2PrivateKey; - private static final String CALLBACK_URL = "https://localhost/callback"; + private ApplicationResponseModel application; + private OpenIDConnectConfiguration oidcInboundConfig; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { @@ -69,14 +72,16 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + deleteApp(application.getId()); consumerKey = null; consumerSecret = null; sp1PrivateKey = null; sp2PrivateKey = null; sp1X509PublicCert = null; + application = null; + oidcInboundConfig = null; + restClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Check Service Provider key generation") @@ -92,26 +97,27 @@ public void testGenerateServiceProviderKeys() throws Exception { dependsOnMethods = "testGenerateServiceProviderKeys") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO oAuthConsumerAppDTO = getBasicOAuthApp(CALLBACK_URL); - ServiceProvider serviceProvider = registerServiceProviderWithOAuthInboundConfigs(oAuthConsumerAppDTO); - Assert.assertNotNull(serviceProvider, "OAuth App creation failed"); - Assert.assertNotNull(consumerKey); - Assert.assertNotNull(consumerSecret); + application = getBasicOAuthApplication(CALLBACK_URL); + Assert.assertNotNull(application, "OAuth App creation failed."); + + oidcInboundConfig = getOIDCInboundDetailsOfApplication(application.getId()); + + consumerKey = oidcInboundConfig.getClientId(); + Assert.assertNotNull(consumerKey, "Application creation failed."); + + consumerSecret = oidcInboundConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); } @Test(groups = "wso2.is", description = "Check Updating public cert of Service Provider", dependsOnMethods = "testRegisterApplication") public void updateServiceProviderCert() throws Exception { - ServiceProvider application = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); - Assert.assertNotNull(application); + updateApplicationCertificate(application.getId(), sp1X509PublicCert); - application.setCertificateContent(convertToPem(sp1X509PublicCert)); - appMgtclient.updateApplicationData(application); - - ServiceProvider updatedApp = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); - Assert.assertNotNull(updatedApp); - Assert.assertNotNull(updatedApp.getCertificateContent()); + ApplicationResponseModel updatedApplication = getApplication(application.getId()); + Assert.assertNotNull(updatedApplication.getAdvancedConfigurations().getCertificate(), + "Application Certificate update failed"); } @Test(groups = "wso2.is", description = "Check Initial OAuth2 Authorize Request", @@ -119,7 +125,7 @@ public void updateServiceProviderCert() throws Exception { public void sentAuthorizationGrantRequest() throws Exception { HttpClient client = getRedirectDisabledClient(); - HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, CALLBACK_URL)); + HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey)); // If the request is valid it will return a 302 to redirect to the login page. assertForLoginPage(response); EntityUtils.consume(response.getEntity()); @@ -131,7 +137,7 @@ public void sendAuthorizationGrantRequestWithPlainJWTRequestObject() throws Exce HttpClient client = getRedirectDisabledClient(); String unsignedRequestObject = buildPlainJWT(consumerKey); - HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, CALLBACK_URL, unsignedRequestObject)); + HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, unsignedRequestObject)); assertForLoginPage(response); EntityUtils.consume(response.getEntity()); } @@ -140,11 +146,12 @@ public void sendAuthorizationGrantRequestWithPlainJWTRequestObject() throws Exce dependsOnMethods = "sendAuthorizationGrantRequestWithPlainJWTRequestObject") public void testEnforceRequestObjectSignatureValidation() throws Exception { - OAuthConsumerAppDTO consumerAppDTO = adminClient.getOAuthAppByConsumerKey(consumerKey); - consumerAppDTO.setRequestObjectSignatureValidationEnabled(true); - adminClient.updateConsumerApp(consumerAppDTO); - OAuthConsumerAppDTO updateApp = adminClient.getOAuthAppByConsumerKey(consumerKey); - Assert.assertTrue(updateApp.getRequestObjectSignatureValidationEnabled()); + oidcInboundConfig.setValidateRequestObjectSignature(true); + updateApplicationInboundConfig(application.getId(), oidcInboundConfig, OIDC); + + OpenIDConnectConfiguration updatedOidcInboundConfig = getOIDCInboundDetailsOfApplication(application.getId()); + Assert.assertTrue(updatedOidcInboundConfig.getValidateRequestObjectSignature(), + "ValidateRequestObjectSignature enable failed"); } @Test(groups = "wso2.is", description = "Check request object signature validation was enforced by sending" + @@ -153,7 +160,7 @@ public void sendUnsuccessfulAuthorizationGrantRequestWithPlainJWTRequestObject() HttpClient client = getRedirectDisabledClient(); String unsignedRequestObject = buildPlainJWT(consumerKey); - HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, CALLBACK_URL, unsignedRequestObject)); + HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, unsignedRequestObject)); // Since we have enforced request object validation we should be redirected to the error page. assertForErrorPage(response); EntityUtils.consume(response.getEntity()); @@ -165,7 +172,7 @@ public void sendSuccessfulAuthorizationGrantRequestWithSignedRequestObject() thr HttpClient client = getRedirectDisabledClient(); String signedRequestObject = buildSignedJWT(consumerKey, sp1PrivateKey); - HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, CALLBACK_URL, signedRequestObject)); + HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, signedRequestObject)); assertForLoginPage(response); EntityUtils.consume(response.getEntity()); } @@ -177,7 +184,7 @@ public void sendUnSuccessfulAuthorizationGrantRequestWithSignedRequestObjectWith HttpClient client = getRedirectDisabledClient(); String signedRequestObject = buildSignedJWT(consumerKey, sp2PrivateKey); - HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, CALLBACK_URL, signedRequestObject)); + HttpResponse response = sendGetRequest(client, getAuthzRequestUrl(consumerKey, signedRequestObject)); assertForErrorPage(response); EntityUtils.consume(response.getEntity()); } @@ -204,20 +211,19 @@ private String getLocationHeaderValue(HttpResponse response) { } private HttpClient getRedirectDisabledClient() { - HttpClient client = new DefaultHttpClient(); HttpClientParams.setRedirecting(client.getParams(), false); return client; } - private String getAuthzRequestUrl(String clientId, String callbackUrl, String requestObject) { + private String getAuthzRequestUrl(String clientId, String requestObject) { - return getAuthzRequestUrl(clientId, callbackUrl) + "&request=" + requestObject; + return getAuthzRequestUrl(clientId) + "&request=" + requestObject; } - private String getAuthzRequestUrl(String clientId, String callbackUrl) { + private String getAuthzRequestUrl(String clientId) { - return OAuth2Constant.AUTHORIZE_ENDPOINT_URL + "?" + "client_id=" + clientId + "&redirect_uri=" + callbackUrl + + return OAuth2Constant.AUTHORIZE_ENDPOINT_URL + "?" + "client_id=" + clientId + "&redirect_uri=" + CALLBACK_URL + "&response_type=code&scope=openid%20internal_login"; } @@ -258,7 +264,7 @@ private void initServiceProviderKeys() throws Exception { File.separator + "keystores" + File.separator + "sp1KeyStore.jks"; String jksPassword = "wso2carbon"; - keyStore.load(new FileInputStream(jksPath), jksPassword.toCharArray()); + keyStore.load(Files.newInputStream(Paths.get(jksPath)), jksPassword.toCharArray()); String alias = "wso2carbon"; @@ -274,7 +280,7 @@ private void initServiceProviderKeys() throws Exception { jksPath = TestConfigurationProvider.getResourceLocation("IS") + File.separator + "sp" + File.separator + "keystores" + File.separator + "sp2KeyStore.jks"; - keyStore.load(new FileInputStream(jksPath), jksPassword.toCharArray()); + keyStore.load(Files.newInputStream(Paths.get(jksPath)), jksPassword.toCharArray()); pkEntry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(alias, new KeyStore.PasswordProtection(jksPassword.toCharArray())); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java index 439a653338..535147d549 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2RoleClaimTestCase.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2017, WSO2 LLC. (https://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -23,89 +23,103 @@ import org.apache.http.NameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.json.simple.JSONObject; import org.json.simple.JSONValue; -import org.json.simple.JSONArray; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.application.common.model.xsd.Claim; -import org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig; -import org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping; -import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig; -import org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig; -import org.wso2.carbon.identity.application.common.model.xsd.Property; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.um.ws.api.stub.ClaimValue; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.rest.api.user.common.model.*; +import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class OAuth2RoleClaimTestCase extends OAuth2ServiceAbstractIntegrationTest { - private static final String OAUTH_ROLE = "Internal/oauthRole"; - private static final String ROLES_CLAIM_URI = "http://wso2.org/claims/roles"; + private static final String OAUTH_ROLE = "oauthRole"; + private static final String USERS_PATH = "users"; private static final String OIDC_ROLES_CLAIM_URI = "roles"; - private static final String FIRST_NAME_VALUE = "FirstName"; - private static final String LAST_NAME_VALUE = "LastName"; - private static final String EMAIL_VALUE = "email@wso2.com"; - private static final String OPENID_SCOPE_PROPERTY = "openid"; - private static final String OPENID_SCOPE_RESOURCE = "/_system/config/oidc"; - private static final String MULTI_ATTRIBUTE_SEPARATOR = ","; + private static final String GIVEN_NAME = "testUser"; + private static final String FAMILY_NAME = "test"; + private static final String HOME_ATTRIBUTE = "home"; + private static final String HOME_EMAIL = "testuser11@gmail.com"; + private static final String WORK_ATTRIBUTE = "work"; + private static final String WORK_EMAIL = "testuser99@wso2.com"; + private static final String USER_USERNAME = "testuser99"; + private static final String USER_PASSWORD = "testuser@123"; + private static final String EMPLOYEE_NUMBER = "Abc123"; + private static final String MANAGER_NAME = "wso2TestManage"; + private String consumerKey; private String consumerSecret; + private String applicationId; + private String roleId; + private String userId; - private DefaultHttpClient client; - - private static final String FIRST_NAME_CLAIM_URI = "http://wso2.org/claims/givenname"; - private static final String LAST_NAME_CLAIM_URI = "http://wso2.org/claims/lastname"; + private CloseableHttpClient client; + private SCIM2RestClient scim2RestClient; - private static final String USERNAME = "oauthuser"; - private static final String PASSWORD = "oauthuser"; + private String USERNAME; + private String PASSWORD; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.TENANT_USER); + this.USERNAME = tenantInfo.getContextUser().getUserName(); + this.PASSWORD = tenantInfo.getContextUser().getPassword(); setSystemproperties(); - client = new DefaultHttpClient(); + client = HttpClients.createDefault(); + scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); - remoteUSMServiceClient.addRole(OAUTH_ROLE, null, null); - remoteUSMServiceClient.addUser(USERNAME, PASSWORD, null, getUserClaims(), "default", - false); + roleId = scim2RestClient.addRole(getRoleCreationInfo()); + userId = scim2RestClient.createUser(getUserCreationInfo()); } @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - - deleteApplication(); - remoteUSMServiceClient.deleteRole(OAUTH_ROLE); - remoteUSMServiceClient.deleteUser(USERNAME); + deleteApp(applicationId); + scim2RestClient.deleteRole(roleId); + scim2RestClient.deleteUser(userId); consumerKey = null; + consumerSecret = null; + applicationId = null; + roleId = null; + userId = null; + + client.close(); + restClient.closeHttpClient(); + scim2RestClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); - consumerKey = appDto.getOauthConsumerKey(); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); + + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); + + applicationId = application.getId(); } @Test(groups = "wso2.is", description = "Check id_token before updating roles.", dependsOnMethods = @@ -116,7 +130,7 @@ public void testSendAuthorizedPost() throws Exception { List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); - urlParameters.add(new BasicNameValuePair("username", USERNAME + "@" + isServer.getContextTenant().getDomain())); + urlParameters.add(new BasicNameValuePair("username", USERNAME )); urlParameters.add(new BasicNameValuePair("password", PASSWORD)); urlParameters.add(new BasicNameValuePair("scope", "openid")); @@ -143,13 +157,13 @@ public void testSendAuthorizedPost() throws Exception { "testSendAuthorizedPost") public void testSendAuthorizedPostAfterRoleUpdate() throws Exception { - remoteUSMServiceClient.updateRoleListOfUser(USERNAME, null, new String[]{OAUTH_ROLE}); + scim2RestClient.updateUserRole(getAddUserPatchRole(userId), roleId); HttpPost request = new HttpPost(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); - urlParameters.add(new BasicNameValuePair("username", USERNAME + "@" + isServer.getContextTenant().getDomain())); + urlParameters.add(new BasicNameValuePair("username", USERNAME)); urlParameters.add(new BasicNameValuePair("password", PASSWORD)); urlParameters.add(new BasicNameValuePair("scope", "openid")); @@ -172,112 +186,51 @@ public void testSendAuthorizedPostAfterRoleUpdate() throws Exception { "Id token must not contain role claim which is not configured for the requested scope."); } - private ClaimValue[] getUserClaims() { + private UserObject getUserCreationInfo() { + UserObject userInfo = new UserObject(); + + userInfo.setUserName(USER_USERNAME); + userInfo.setPassword(USER_PASSWORD); - ClaimValue[] claimValues = new ClaimValue[3]; + Name name = new Name(); + name.setGivenName(GIVEN_NAME); + name.setFamilyName(FAMILY_NAME); + userInfo.setName(name); - ClaimValue firstName = new ClaimValue(); - firstName.setClaimURI(FIRST_NAME_CLAIM_URI); - firstName.setValue(FIRST_NAME_VALUE); - claimValues[0] = firstName; + Email homeEmail = new Email(); + homeEmail.setPrimary(true); + homeEmail.setType(HOME_ATTRIBUTE); + homeEmail.setValue(HOME_EMAIL); - ClaimValue lastName = new ClaimValue(); - lastName.setClaimURI(LAST_NAME_CLAIM_URI); - lastName.setValue(LAST_NAME_VALUE); - claimValues[1] = lastName; + Email workEmail = new Email(); + workEmail.setType(WORK_ATTRIBUTE); + workEmail.setValue(WORK_EMAIL); - ClaimValue email = new ClaimValue(); - email.setClaimURI(EMAIL_CLAIM_URI); - email.setValue(EMAIL_VALUE); - claimValues[2] = email; + userInfo.addEmail(homeEmail); + userInfo.addEmail(workEmail); - return claimValues; + ScimSchemaExtensionEnterprise scimSchema = new ScimSchemaExtensionEnterprise(); + scimSchema.setEmployeeNumber(EMPLOYEE_NUMBER); + scimSchema.setManager(new Manager().value(MANAGER_NAME)); + + userInfo.setScimSchemaExtensionEnterprise(scimSchema); + + return userInfo; + } + + private RoleRequestObject getRoleCreationInfo() { + RoleRequestObject roleInfo = new RoleRequestObject(); + roleInfo.setDisplayName(OAUTH_ROLE); + + return roleInfo; } - public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO) throws Exception { - - OAuthConsumerAppDTO appDtoResult = null; - - adminClient.registerOAuthApplicationData(appDTO); - OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData(); - - for (OAuthConsumerAppDTO appDto : appDtos) { - if (appDto.getApplicationName().equals(OAuth2Constant.OAUTH_APPLICATION_NAME)) { - appDtoResult = appDto; - consumerKey = appDto.getOauthConsumerKey(); - consumerSecret = appDto.getOauthConsumerSecret(); - } - } - ServiceProvider serviceProvider = new ServiceProvider(); - serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME); - serviceProvider.setDescription(SERVICE_PROVIDER_DESC); - appMgtclient.createApplication(serviceProvider); - - serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); - - ClaimConfig claimConfig = new ClaimConfig(); - - Claim emailClaim = new Claim(); - emailClaim.setClaimUri(EMAIL_CLAIM_URI); - ClaimMapping emailClaimMapping = new ClaimMapping(); - emailClaimMapping.setRequested(true); - emailClaimMapping.setLocalClaim(emailClaim); - emailClaimMapping.setRemoteClaim(emailClaim); - - Claim roleClaim = new Claim(); - roleClaim.setClaimUri(ROLES_CLAIM_URI); - ClaimMapping roleClaimMapping = new ClaimMapping(); - roleClaimMapping.setRequested(true); - roleClaimMapping.setLocalClaim(roleClaim); - roleClaimMapping.setRemoteClaim(roleClaim); - - claimConfig.setClaimMappings(new org.wso2.carbon.identity.application.common.model.xsd - .ClaimMapping[]{emailClaimMapping, roleClaimMapping}); - - serviceProvider.setClaimConfig(claimConfig); - serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig()); - List authRequestList = - new ArrayList(); - - if (consumerKey != null) { - InboundAuthenticationRequestConfig opicAuthenticationRequest = - new InboundAuthenticationRequestConfig(); - opicAuthenticationRequest.setInboundAuthKey(consumerKey); - opicAuthenticationRequest.setInboundAuthType("oauth2"); - if (consumerSecret != null && !consumerSecret.isEmpty()) { - Property property = new Property(); - property.setName("oauthConsumerSecret"); - property.setValue(consumerSecret); - Property[] properties = {property}; - opicAuthenticationRequest.setProperties(properties); - } - authRequestList.add(opicAuthenticationRequest); - } - - String passiveSTSRealm = SERVICE_PROVIDER_NAME; - if (passiveSTSRealm != null) { - InboundAuthenticationRequestConfig opicAuthenticationRequest = - new InboundAuthenticationRequestConfig(); - opicAuthenticationRequest.setInboundAuthKey(passiveSTSRealm); - opicAuthenticationRequest.setInboundAuthType("passivests"); - authRequestList.add(opicAuthenticationRequest); - } - - String openidRealm = SERVICE_PROVIDER_NAME; - if (openidRealm != null) { - InboundAuthenticationRequestConfig opicAuthenticationRequest = - new InboundAuthenticationRequestConfig(); - opicAuthenticationRequest.setInboundAuthKey(openidRealm); - opicAuthenticationRequest.setInboundAuthType("openid"); - authRequestList.add(opicAuthenticationRequest); - } - - if (authRequestList.size() > 0) { - serviceProvider.getInboundAuthenticationConfig() - .setInboundAuthenticationRequestConfigs(authRequestList.toArray(new - InboundAuthenticationRequestConfig[authRequestList.size()])); - } - appMgtclient.updateApplicationData(serviceProvider); - return appDtoResult; + private PatchOperationRequestObject getAddUserPatchRole(String userId) { + RoleItemAddGroupobj patchRoleItem = new RoleItemAddGroupobj(); + patchRoleItem.setOp(RoleItemAddGroupobj.OpEnum.ADD); + patchRoleItem.setPath(USERS_PATH); + patchRoleItem.addValue(new ListObject().value(userId)); + + return new PatchOperationRequestObject().addOperations(patchRoleItem); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java index bd4463af14..17252b78db 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceAbstractIntegrationTest.java @@ -35,17 +35,15 @@ import org.json.simple.parser.JSONParser; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.identity.application.common.model.xsd.Claim; -import org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig; -import org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping; -import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig; -import org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig; import org.wso2.carbon.identity.application.common.model.xsd.Property; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; +import org.wso2.carbon.identity.application.common.model.xsd.*; import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; import org.wso2.identity.integration.common.utils.ISIntegrationTest; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.*; +import org.wso2.identity.integration.test.restclients.OAuth2RestClient; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.OAuth2Constant; import sun.security.provider.X509Factory; @@ -54,6 +52,7 @@ import java.security.cert.CertificateEncodingException; import java.security.cert.X509Certificate; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import static org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH_APPLICATION_NAME; @@ -74,11 +73,14 @@ public class OAuth2ServiceAbstractIntegrationTest extends ISIntegrationTest { private static final String customClaimURI2 = "http://wso2.org/claims/challengeQuestion2"; private static final String GRANT_TYPE_PASSWORD = "password"; private static final String SCOPE_PRODUCTION = "PRODUCTION"; + public static final String OIDC = "oidc"; + public static final String SAML = "saml"; private final static int TOMCAT_PORT = 8490; protected ApplicationManagementServiceClient appMgtclient; protected OauthAdminClient adminClient; protected RemoteUserStoreManagerServiceClient remoteUSMServiceClient; + protected OAuth2RestClient restClient; /** @@ -93,6 +95,7 @@ protected void init(TestUserMode userMode) throws Exception { appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); adminClient = new OauthAdminClient(backendURL, sessionCookie); remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); + restClient = new OAuth2RestClient(serverURL, tenantInfo); } /** @@ -111,6 +114,32 @@ public OAuthConsumerAppDTO createApplication() throws Exception { return createApplication(appDTO, SERVICE_PROVIDER_NAME); } + public ApplicationResponseModel addApplication() throws Exception { + + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "implicit", "password", "client_credentials", + "refresh_token", "urn:ietf:params:oauth:grant-type:saml2-bearer", "iwa:ntlm"); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OAuth2Constant.OAUTH_APPLICATION_NAME); + + String appId = addApplication(application); + + return getApplication(appId); + } + /** * To set ServiceProvider Provider Claim configuration. * @@ -143,11 +172,72 @@ ServiceProvider setServiceProviderClaimConfig(ServiceProvider serviceProvider) { } /** - * Create Application with a given appDTO + * Create Application with a given ApplicationModel * - * @return OAuthConsumerAppDTO - * @throws Exception + * @param application application creation object + * @return application id + * @throws Exception Exception + */ + public String addApplication(ApplicationModel application) throws Exception { + return restClient.createApplication(application); + } + + /** + * Get Application details with a given id + * + * @param appId application Id + * @return ApplicationResponseModel + * @throws Exception Exception + */ + public ApplicationResponseModel getApplication(String appId) throws Exception { + return restClient.getApplication(appId); + } + + /** + * Get Application details with a given id + * + * @param appId application Id + * @param application application update patch object + * @throws Exception Exception + */ + public void updateApplication(String appId, ApplicationPatchModel application) throws Exception { + restClient.updateApplication(appId, application); + } + + /** + * Get Application oidc inbound configuration details with a given id + * + * @param appId application Id + * @return OpenIDConnectConfiguration + * @throws Exception Exception + */ + public OpenIDConnectConfiguration getOIDCInboundDetailsOfApplication(String appId) throws Exception { + return restClient.getOIDCInboundDetails(appId); + } + + /** + * Get Application saml inbound configuration details with a given id + * + * @param appId application Id + * @return SAML2ServiceProvider + * @throws Exception Exception */ + public SAML2ServiceProvider getSAMLInboundDetailsOfApplication(String appId) throws Exception { + return restClient.getSAMLInboundDetails(appId); + } + + /** + * Update Application inbound configuration details with a given id and the inbound Type + * + * @param appId application Id + * @param InboundConfig InboundConfig object + * @param inboundType inbound configuration type + */ + public void updateApplicationInboundConfig(String appId, Object InboundConfig, String inboundType) + throws IOException { + restClient.updateInboundDetailsOfApplication(appId, InboundConfig, inboundType); + } + public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO, String serviceProviderName) throws Exception { OAuthConsumerAppDTO appDtoResult = null; @@ -211,6 +301,8 @@ public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO, String return appDtoResult; } + + public void UpdateApplicationClaimConfig() throws Exception { ServiceProvider serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); ClaimConfig claimConfig = getClaimConfig(); @@ -482,6 +574,10 @@ public void deleteApplication() throws Exception { appMgtclient.deleteApplication(SERVICE_PROVIDER_NAME); } + public void deleteApp(String appId) throws Exception { + restClient.deleteApplication(appId); + } + /** * Remove OAuth Application * @@ -538,6 +634,20 @@ public String getBase64EncodedString(String consumerKey, String consumerSecret) return new String(Base64.encodeBase64((consumerKey + ":" + consumerSecret).getBytes())); } + public void updateApplicationCertificate(String appId, X509Certificate sp1X509PublicCert) throws Exception { + + Certificate certificate = new Certificate(); + certificate.setType(Certificate.TypeEnum.PEM); + certificate.setValue(convertToPem(sp1X509PublicCert)); + + ApplicationPatchModel applicationPatch = new ApplicationPatchModel(); + applicationPatch = applicationPatch.advancedConfigurations(new AdvancedApplicationConfiguration()); + applicationPatch.getAdvancedConfigurations().setCertificate(certificate); + + updateApplication(appId, applicationPatch); + } + + /** * Convert a x509 certificate to pem format. * @@ -569,6 +679,38 @@ public OAuthConsumerAppDTO getBasicOAuthApp(String callBackURL) { return appDTO; } + /** + * Create and return a basic consumer application with all OAuth2 grant types. + * + * @param callBackURL String callback URL. + * @return ApplicationResponseModel object. + */ + public ApplicationResponseModel getBasicOAuthApplication(String callBackURL) throws Exception { + + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "implicit", "password", "client_credentials", + "refresh_token"); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, callBackURL); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OAuth2Constant.OAUTH_APPLICATION_NAME); + + String appId = addApplication(application); + + return getApplication(appId); + } + /** * Register a service provider and setup consumer key and secret when a OAuthConsumerAppDTO is given. * @@ -656,10 +798,10 @@ private void setInboundOAuthConfig(List auth /** * Build post request and return json response object. * - * @param endpoint Endpoint. - * @param postParameters postParameters. - * @param key Basic authentication key. - * @param secret Basic authentication secret. + * @param endpoint Endpoint. + * @param postParameters postParameters. + * @param client httpclient. + * @param authorizationHeader Authentication header. * @return JSON object of the response. * @throws Exception */ diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java index c746736deb..659e2e5ff1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceClientCredentialTestCase.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2022, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -41,12 +41,9 @@ import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.automation.engine.context.beans.Tenant; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.integration.common.utils.LoginLogoutClient; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.restclients.OAuth2RestClient; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.net.URI; @@ -58,7 +55,6 @@ */ public class OAuth2ServiceClientCredentialTestCase extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; private String accessToken; private String consumerKey; private String consumerSecret; @@ -66,6 +62,7 @@ public class OAuth2ServiceClientCredentialTestCase extends OAuth2ServiceAbstract private final String userPassword; private final AutomationContext context; private Tenant tenantInfo; + private String applicationId; private CloseableHttpClient client; @@ -77,7 +74,7 @@ public static Object[][] configProvider() { @Factory(dataProvider = "configProvider") public OAuth2ServiceClientCredentialTestCase(TestUserMode userMode) throws Exception { - + super.init(userMode); context = new AutomationContext("IDENTITY", userMode); this.username = context.getContextTenant().getTenantAdmin().getUserName(); this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); @@ -85,18 +82,9 @@ public OAuth2ServiceClientCredentialTestCase(TestUserMode userMode) throws Excep @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - - String backendURL = context.getContextUrls().getBackEndUrl(); - loginLogoutClient = new LoginLogoutClient(context); - logManger = new AuthenticatorClient(backendURL); - identityContextUrls = context.getContextUrls(); tenantInfo = context.getContextTenant(); userInfo = tenantInfo.getContextUser(); - - String sessionCookie = logManger.login(username, userPassword, context.getInstance().getHosts().get("default")); - appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); - adminClient = new OauthAdminClient(backendURL, sessionCookie); - remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); + restClient = new OAuth2RestClient(serverURL, tenantInfo); setSystemproperties(); client = HttpClientBuilder.create().build(); @@ -104,26 +92,30 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - - appMgtclient.deleteApplication(SERVICE_PROVIDER_NAME); - adminClient.removeOAuthApplicationData(consumerKey); + deleteApp(applicationId); client.close(); - logManger = null; + restClient.closeHttpClient(); + consumerKey = null; accessToken = null; + applicationId = null; } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); + + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); - consumerKey = appDto.getOauthConsumerKey(); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); Assert.assertNotNull(consumerSecret, "Application creation failed."); + + applicationId = application.getId(); } @Test(groups = "wso2.is", description = "Send client credentials token request.", dependsOnMethods = "testRegisterApplication") diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java index 060b4a24ac..852434b613 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceErrorResponseTest.java @@ -1,75 +1,83 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 LLC. (https://www.wso2.com). * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.wso2.identity.integration.test.oauth2; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.OAuth2Constant; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class OAuth2ServiceErrorResponseTest extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; - private DefaultHttpClient client; + private String applicationId; + private CloseableHttpClient client; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - logManger = new AuthenticatorClient(backendURL); - logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), - isServer.getSuperTenant().getTenantAdmin().getPassword(), - isServer.getInstance().getHosts().get("default")); setSystemproperties(); - client = new DefaultHttpClient(); + client = HttpClients.createDefault(); } @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - removeOAuthApplicationData(); - logManger = null; + deleteApp(applicationId); consumerKey = null; + applicationId = null; + client.close(); + restClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); - consumerKey = appDto.getOauthConsumerKey(); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "Application creation failed."); + + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); + + applicationId = application.getId(); } @Test(groups = "wso2.is", description = "Test unsupported grant type error response", dependsOnMethods = "testRegisterApplication") public void testUnsupportedGrantTypeErrorResponse() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("response_type", OAuth2Constant.OAUTH2_GRANT_TYPE_IMPLICIT)); urlParameters.add(new BasicNameValuePair("client_id", consumerKey)); @@ -89,26 +97,28 @@ public void testUnsupportedGrantTypeErrorResponse() throws Exception { Assert.assertTrue(locationURI.contains("not.authorized.to.use.requested.grant.type")); } - public OAuthConsumerAppDTO createApplication() throws Exception { + public ApplicationResponseModel addApplication() throws Exception { + + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, ""); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); - OAuthConsumerAppDTO appDtoResult = null; + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); - OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO(); - appDTO.setApplicationName(OAuth2Constant.OAUTH_APPLICATION_NAME); - appDTO.setCallbackUrl(OAuth2Constant.CALLBACK_URL); - appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appDTO.setGrantTypes(""); + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OAuth2Constant.OAUTH_APPLICATION_NAME); - adminClient.registerOAuthApplicationData(appDTO); - OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData(); + String appId = addApplication(application); - for (OAuthConsumerAppDTO appDto : appDtos) { - if (appDto.getApplicationName().equals(OAuth2Constant.OAUTH_APPLICATION_NAME)) { - appDtoResult = appDto; - consumerKey = appDto.getOauthConsumerKey(); - consumerSecret = appDto.getOauthConsumerSecret(); - } - } - return appDtoResult; + return getApplication(appId); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java index a965ca59d0..ee5f26d885 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceImplicitGrantTestCase.java @@ -1,20 +1,21 @@ /* -* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ + * Copyright (c) 2015, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.identity.integration.test.oauth2; import org.apache.http.Header; @@ -32,15 +33,9 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.automation.engine.context.beans.ContextUrls; import org.wso2.carbon.automation.engine.context.beans.Tenant; -import org.wso2.carbon.automation.engine.context.beans.User; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.integration.common.utils.LoginLogoutClient; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.DataExtractUtil; import org.wso2.identity.integration.test.utils.DataExtractUtil.KeyValue; @@ -56,7 +51,6 @@ public class OAuth2ServiceImplicitGrantTestCase extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; private String accessToken; private String scopes; private String sessionDataKeyConsent; @@ -69,13 +63,8 @@ public class OAuth2ServiceImplicitGrantTestCase extends OAuth2ServiceAbstractInt private final String username; private final String userPassword; private final AutomationContext context; - private String backendURL; - private String sessionCookie; private Tenant tenantInfo; - private User userInfo; - private LoginLogoutClient loginLogoutClient; - private ContextUrls identityContextUrls; - private RemoteUserStoreManagerServiceClient remoteUSMServiceClient; + private String applicationId; @DataProvider(name = "configProvider") public static Object[][] configProvider() { @@ -94,16 +83,7 @@ public OAuth2ServiceImplicitGrantTestCase(TestUserMode userMode) throws Exceptio @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - backendURL = context.getContextUrls().getBackEndUrl(); - loginLogoutClient = new LoginLogoutClient(context); - logManger = new AuthenticatorClient(backendURL); - sessionCookie = logManger.login(username, userPassword, context.getInstance().getHosts().get("default")); - identityContextUrls = context.getContextUrls(); tenantInfo = context.getContextTenant(); - userInfo = tenantInfo.getContextUser(); - appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); - adminClient = new OauthAdminClient(backendURL, sessionCookie); - remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); setSystemproperties(); client = HttpClientBuilder.create().build(); @@ -113,27 +93,33 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - appMgtclient.deleteApplication(SERVICE_PROVIDER_NAME); - adminClient.removeOAuthApplicationData(consumerKey); + deleteApp(applicationId); client.close(); - logManger = null; + restClient.closeHttpClient(); consumerKey = null; accessToken = null; + applicationId = null; } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); + + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); - consumerKey = appDto.getOauthConsumerKey(); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + + consumerSecret = oidcConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); + + applicationId = application.getId(); } @Test(groups = "wso2.is", description = "Send authorize user request", dependsOnMethods = "testRegisterApplication") public void testSendAuthorozedPost() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_IMPLICIT)); urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); @@ -156,7 +142,7 @@ public void testSendAuthorozedPost() throws Exception { response = sendGetRequest(client, locationHeader.getValue()); Assert.assertNotNull(response, "Authorized user response is null."); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"sessionDataKey\"", 1); List keyValues = DataExtractUtil.extractDataFromResponse(response, keyPositionMap); @@ -187,7 +173,7 @@ public void testSendLoginPost() throws Exception { EntityUtils.consume(response.getEntity()); response = sendGetRequest(client, locationHeader.getValue()); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"sessionDataKeyConsent\"", 1); List keyValues = DataExtractUtil.extractSessionConsentDataFromResponse(response, @@ -202,7 +188,7 @@ public void testSendLoginPost() throws Exception { @Test(groups = "wso2.is", description = "Send approval post request", dependsOnMethods = "testSendLoginPost") public void testSendApprovalPost() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("consent", "approve")); urlParameters.add(new BasicNameValuePair("sessionDataKeyConsent", sessionDataKeyConsent)); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java index 43119f6467..f82a55ed2e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceIntrospectionTestCase.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 LLC. (https://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.identity.integration.test.oauth2; import org.apache.http.HttpResponse; @@ -29,17 +30,9 @@ import org.testng.annotations.Factory; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.automation.engine.context.beans.ContextUrls; -import org.wso2.carbon.automation.engine.context.beans.Tenant; -import org.wso2.carbon.automation.engine.context.beans.User; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.integration.common.utils.LoginLogoutClient; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.DataExtractUtil; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -52,23 +45,12 @@ public class OAuth2ServiceIntrospectionTestCase extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; private String accessToken; private String consumerKey; private String consumerSecret; private CloseableHttpClient client; - private final String username; - private final String userPassword; - private final String activeTenant; - private final AutomationContext context; - private String backendURL; - private String sessionCookie; - private Tenant tenantInfo; - private User userInfo; - private LoginLogoutClient loginLogoutClient; - private ContextUrls identityContextUrls; - private RemoteUserStoreManagerServiceClient remoteUSMServiceClient; + private String applicationId; @DataProvider(name = "configProvider") public static Object[][] configProvider() { @@ -77,28 +59,12 @@ public static Object[][] configProvider() { @Factory(dataProvider = "configProvider") public OAuth2ServiceIntrospectionTestCase(TestUserMode userMode) throws Exception { - - - context = new AutomationContext("IDENTITY", userMode); - this.username = context.getContextTenant().getTenantAdmin().getUserName(); - this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); - this.activeTenant = context.getContextTenant().getDomain(); + super.init(userMode); } @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - backendURL = context.getContextUrls().getBackEndUrl(); - loginLogoutClient = new LoginLogoutClient(context); - logManger = new AuthenticatorClient(backendURL); - sessionCookie = logManger.login(username, userPassword, context.getInstance().getHosts().get("default")); - identityContextUrls = context.getContextUrls(); - tenantInfo = context.getContextTenant(); - userInfo = tenantInfo.getContextUser(); - appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); - adminClient = new OauthAdminClient(backendURL, sessionCookie); - remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); - setSystemproperties(); client = HttpClientBuilder.create().build(); } @@ -106,30 +72,33 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - appMgtclient.deleteApplication(SERVICE_PROVIDER_NAME); - adminClient.removeOAuthApplicationData(consumerKey); + deleteApp(applicationId); client.close(); - logManger = null; + restClient.closeHttpClient(); consumerKey = null; accessToken = null; + applicationId = null; } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); - consumerKey = appDto.getOauthConsumerKey(); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); Assert.assertNotNull(consumerSecret, "Application creation failed."); + + applicationId = application.getId(); } @Test(groups = "wso2.is", description = "Send authorize user request and get access token", dependsOnMethods = "testRegisterApplication") public void testGetAccessToken() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair( "grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_CLIENT_CREDENTIALS)); @@ -146,7 +115,7 @@ public void testGetAccessToken() throws Exception { response = sendPostRequest(client, OAuth2Constant.AUTHORIZED_URL); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"accessToken\"", 1); List keyValues = @@ -161,7 +130,7 @@ public void testGetAccessToken() throws Exception { @Test(groups = "wso2.is", description = "Test introspection endpoint", dependsOnMethods = "testGetAccessToken") public void testIntrospectionEndpoint() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("accessToken", accessToken)); urlParameters.add(new BasicNameValuePair("resource_url", "https://localhost:9443/oauth2/introspect")); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java index 5e9f386012..77471bc561 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRefreshTokenGrantTestCase.java @@ -1,17 +1,19 @@ /* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2017, WSO2 LLC. (https://www.wso2.com). * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. */ package org.wso2.identity.integration.test.oauth2; @@ -20,7 +22,8 @@ import org.apache.http.NameValuePair; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.json.simple.JSONObject; @@ -30,61 +33,63 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.util.ArrayList; import java.util.List; public class OAuth2ServiceRefreshTokenGrantTestCase extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; private String adminUsername; private String adminPassword; private String refreshToken; private String consumerKey; private String consumerSecret; + private String applicationId; - private DefaultHttpClient client; + private CloseableHttpClient client; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - logManger = new AuthenticatorClient(backendURL); adminUsername = userInfo.getUserName(); adminPassword = userInfo.getPassword(); - logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), - isServer.getSuperTenant().getTenantAdmin().getPassword(), - isServer.getInstance().getHosts().get("default")); setSystemproperties(); - client = new DefaultHttpClient(); + client = HttpClients.createDefault(); } @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + deleteApp(applicationId); - logManger = null; consumerKey = null; refreshToken = null; + applicationId = null; + client.close(); + restClient.closeHttpClient(); } @Test(alwaysRun = true, description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); - consumerKey = appDto.getOauthConsumerKey(); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); + + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); + + applicationId = application.getId(); } @Test(groups = "wso2.is", description = "Validate refresh token", dependsOnMethods = "testRegisterApplication") public void testSendAuthorizedPost() throws Exception { - List postParameters = new ArrayList(); + List postParameters = new ArrayList<>(); postParameters.add(new BasicNameValuePair("username", adminUsername)); postParameters.add(new BasicNameValuePair("password", adminPassword)); postParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); @@ -96,7 +101,7 @@ public void testSendAuthorizedPost() throws Exception { @Test(groups = "wso2.is", description = "Validate refresh token", dependsOnMethods = "testSendAuthorizedPost") public void testRefreshTokenGrant() throws Exception { - List postParameters = new ArrayList(); + List postParameters = new ArrayList<>(); postParameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_REFRESH_TOKEN)); postParameters.add(new BasicNameValuePair(OAuth2Constant.OAUTH2_GRANT_TYPE_REFRESH_TOKEN, refreshToken)); JSONObject responseObject = responseObject(postParameters); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRegexCallbackUrlTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRegexCallbackUrlTestCase.java index 58db8ed12d..246495a913 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRegexCallbackUrlTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceRegexCallbackUrlTestCase.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 LLC. (https://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -30,14 +30,16 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.identity.integration.common.utils.ISIntegrationTest; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.DataExtractUtil; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -47,27 +49,19 @@ public class OAuth2ServiceRegexCallbackUrlTestCase extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; - private String adminUsername; - private String adminPassword; private String accessToken; private String sessionDataKeyConsent; private String sessionDataKey; private String consumerKey; private String consumerSecret; + private String applicationId; private CloseableHttpClient client; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - logManger = new AuthenticatorClient(backendURL); - adminUsername = userInfo.getUserName(); - adminPassword = userInfo.getPassword(); - logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), - isServer.getSuperTenant().getTenantAdmin().getPassword(), - isServer.getInstance().getHosts().get("default")); setSystemproperties(); client = HttpClientBuilder.create().build(); @@ -75,35 +69,31 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + + deleteApp(applicationId); client.close(); - logManger = null; + restClient.closeHttpClient(); consumerKey = null; accessToken = null; + applicationId = null; } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { + ApplicationResponseModel application = createTestApplication(); + applicationId = application.getId(); - OAuthConsumerAppDTO appConfigData = new OAuthConsumerAppDTO(); - appConfigData.setApplicationName(org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH_APPLICATION_NAME); - appConfigData.setCallbackUrl(OAuth2Constant.CALLBACK_URL_REGEXP); - appConfigData.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appConfigData.setGrantTypes("authorization_code implicit password client_credentials refresh_token " - + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm"); - - OAuthConsumerAppDTO appDto = createApplication(appConfigData, SERVICE_PROVIDER_NAME); - Assert.assertNotNull(appDto, "Application creation failed."); - - consumerKey = appDto.getOauthConsumerKey(); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + + consumerSecret = oidcConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); } @Test(groups = "wso2.is", description = "Send authorize user request", dependsOnMethods = "testRegisterApplication") public void testSendAuthorozedPost() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_IMPLICIT)); urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); @@ -124,7 +114,7 @@ public void testSendAuthorozedPost() throws Exception { response = sendGetRequest(client, locationHeader.getValue()); Assert.assertNotNull(response, "Authorized user response is null."); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"sessionDataKey\"", 1); List keyValues = DataExtractUtil.extractDataFromResponse(response, keyPositionMap); @@ -155,7 +145,7 @@ public void testSendLoginPost() throws Exception { EntityUtils.consume(response.getEntity()); response = sendGetRequest(client, locationHeader.getValue()); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"sessionDataKeyConsent\"", 1); List keyValues = DataExtractUtil.extractSessionConsentDataFromResponse(response, @@ -170,7 +160,7 @@ public void testSendLoginPost() throws Exception { @Test(groups = "wso2.is", description = "Send approval post request", dependsOnMethods = "testSendLoginPost") public void testSendApprovalPost() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("consent", "approve")); urlParameters.add(new BasicNameValuePair("sessionDataKeyConsent", sessionDataKeyConsent)); @@ -194,7 +184,7 @@ public void testValidateAccessToken() throws Exception { HttpResponse response = sendValidateAccessTokenPost(client, accessToken); Assert.assertNotNull(response, "Validate access token response is invalid."); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"valid\"", 1); List keyValues = @@ -206,4 +196,29 @@ public void testValidateAccessToken() throws Exception { Assert.assertEquals(valid, "true", "Token Validation failed"); EntityUtils.consume(response.getEntity()); } + + private ApplicationResponseModel createTestApplication() throws Exception { + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "implicit", "password", "client_credentials", + "refresh_token", "urn:ietf:params:oauth:grant-type:saml2-bearer", "iwa:ntlm"); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL_REGEXP); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OAuth2Constant.OAUTH_APPLICATION_NAME); + + String appId = addApplication(application); + + return getApplication(appId); + } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java index eb0cfb9ce9..01968f1941 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceResourceOwnerTestCase.java @@ -1,20 +1,20 @@ /* -* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ + * Copyright (c) 2015, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.oauth2; @@ -37,18 +37,13 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.automation.engine.context.beans.ContextUrls; import org.wso2.carbon.automation.engine.context.beans.Tenant; -import org.wso2.carbon.automation.engine.context.beans.User; -import org.wso2.carbon.identity.governance.stub.bean.Property; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.integration.common.utils.LoginLogoutClient; -import org.wso2.carbon.um.ws.api.stub.ClaimValue; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.mgt.IdentityGovernanceServiceClient; -import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.rest.api.user.common.model.ScimSchemaExtensionEnterprise; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; +import org.wso2.identity.integration.test.restclients.OAuth2RestClient; +import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.utils.DataExtractUtil; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -63,31 +58,24 @@ import static org.wso2.identity.integration.test.utils.DataExtractUtil.KeyValue; public class OAuth2ServiceResourceOwnerTestCase extends OAuth2ServiceAbstractIntegrationTest { - private AuthenticatorClient logManger; - private String adminUsername; - private String adminPassword; + private String accessToken; private String consumerKey; private String consumerSecret; private CloseableHttpClient client; private final AutomationContext context; - private String backendURL; - private String sessionCookie; private Tenant tenantInfo; - private User userInfo; - private LoginLogoutClient loginLogoutClient; - private ContextUrls identityContextUrls; - private RemoteUserStoreManagerServiceClient remoteUSMServiceClient; + private SCIM2RestClient scim2RestClient; private static final String lockedUser = "test_locked_user"; private static final String lockedUserPassword = "test_locked_user_pass"; - private static final String ACCOUNT_LOCK_CLAIM_URI = "http://wso2.org/claims/identity/accountLocked"; - protected IdentityGovernanceServiceClient identityGovernanceServiceClient; private final String username; private final String userPassword; private final String activeTenant; private static final String TENANT_DOMAIN = "wso2.com"; + private String applicationId; + private String userId; @DataProvider(name = "configProvider") public static Object[][] configProvider() { @@ -97,6 +85,7 @@ public static Object[][] configProvider() { @Factory(dataProvider = "configProvider") public OAuth2ServiceResourceOwnerTestCase(TestUserMode userMode) throws Exception { + super.init(userMode); context = new AutomationContext("IDENTITY", userMode); this.username = context.getContextTenant().getTenantAdmin().getUserName(); this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); @@ -106,51 +95,48 @@ public OAuth2ServiceResourceOwnerTestCase(TestUserMode userMode) throws Exceptio @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - backendURL = context.getContextUrls().getBackEndUrl(); - loginLogoutClient = new LoginLogoutClient(context); - logManger = new AuthenticatorClient(backendURL); - sessionCookie = logManger.login(username, userPassword, context.getInstance().getHosts().get("default")); - identityContextUrls = context.getContextUrls(); tenantInfo = context.getContextTenant(); - userInfo = tenantInfo.getContextUser(); - appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); - adminClient = new OauthAdminClient(backendURL, sessionCookie); - remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); + + restClient = new OAuth2RestClient(serverURL, tenantInfo); + scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); setSystemproperties(); client = HttpClientBuilder.create().build(); - identityGovernanceServiceClient = new IdentityGovernanceServiceClient(sessionCookie, backendURL); - createLockedUser(lockedUser, lockedUserPassword); + createLockedUser(); } @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteUser(lockedUser); + scim2RestClient.deleteUser(userId); + restClient.deleteApplication(applicationId); - appMgtclient.deleteApplication(SERVICE_PROVIDER_NAME); - adminClient.removeOAuthApplicationData(consumerKey); client.close(); - logManger = null; + restClient.closeHttpClient(); + scim2RestClient.closeHttpClient(); consumerKey = null; accessToken = null; } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testRegisterApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); + applicationId = application.getId(); + + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId); - consumerKey = appDto.getOauthConsumerKey(); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); + Assert.assertNotNull(consumerSecret, "Application creation failed."); } @Test(groups = "wso2.is", description = "Send authorize user request", dependsOnMethods = "testRegisterApplication") public void testSendAuthorozedPost() throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER)); urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); @@ -169,7 +155,7 @@ public void testSendAuthorozedPost() throws Exception { response = sendPostRequest(client, OAuth2Constant.AUTHORIZED_URL); - Map keyPositionMap = new HashMap(1); + Map keyPositionMap = new HashMap<>(1); keyPositionMap.put("name=\"accessToken\"", 1); List keyValues = @@ -366,30 +352,16 @@ public void testSendLockedAuthenticationPost() throws Exception { } } - private void createLockedUser(String username, String password) { - - log.info("Creating User " + username); - - ClaimValue[] claimValues = new ClaimValue[1]; - // Need to add this claim and have the value true in order to test the fix - ClaimValue accountLockClaim = new ClaimValue(); - accountLockClaim.setClaimURI(ACCOUNT_LOCK_CLAIM_URI); - accountLockClaim.setValue(Boolean.TRUE.toString()); - claimValues[0] = accountLockClaim; + private void createLockedUser() { try { - remoteUSMServiceClient.addUser(username, password, null, claimValues, null, false); + UserObject userInfo = new UserObject(); + userInfo.setUserName(lockedUser); + userInfo.setPassword(lockedUserPassword); + userInfo.setScimSchemaExtensionEnterprise(new ScimSchemaExtensionEnterprise().accountLocked(true)); + userId = scim2RestClient.createUser(userInfo); } catch (Exception e) { Assert.fail("Error while creating the user", e); } } - - private void deleteUser(String username) { - log.info("Deleting User " + username); - try { - remoteUSMServiceClient.deleteUser(username); - } catch (Exception e) { - Assert.fail("Error while deleting the user", e); - } - } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java index 6b42466669..2270592967 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2ServiceSAML2BearerGrantTestCase.java @@ -35,13 +35,17 @@ import org.testng.annotations.Test; import org.w3c.dom.Document; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig; -import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException; -import org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO; -import org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAML2Configuration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAML2ServiceProvider; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAMLAssertionConfiguration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAMLAttributeProfile; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAMLResponseSigning; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SingleLogoutProfile; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SingleSignOnProfile; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.CommonConstants; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -51,10 +55,9 @@ import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; -import java.nio.charset.Charset; -import java.rmi.RemoteException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -78,33 +81,33 @@ public class OAuth2ServiceSAML2BearerGrantTestCase extends OAuth2ServiceAbstract private static final String ACS_URL = "http://localhost:8490/%s/home.jsp"; private static final String TENANT_DOMAIN_PARAM = "tenantDomain"; private static final String SAML_SSO_URL = "https://localhost:9853/samlsso"; + private static final String ISSUER = "travelocity.com"; private CloseableHttpClient client; - - private SAMLSSOConfigServiceClient ssoConfigServiceClient; + private String samlAppId; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { super.init(TestUserMode.SUPER_TENANT_USER); - ssoConfigServiceClient = new SAMLSSOConfigServiceClient(backendURL, sessionCookie); - - OAuthConsumerAppDTO oauthApp = createDefaultOAuthApplication(); - createDefaultSAMLApplication(); + ApplicationResponseModel application = createSAMLApplication(); - consumerKey = oauthApp.getOauthConsumerKey(); - consumerSecret = oauthApp.getOauthConsumerSecret(); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); + consumerKey = oidcConfig.getClientId(); + consumerSecret = oidcConfig.getClientSecret(); client = HttpClientBuilder.create().build(); log.info(String.format("Oauth app initialized with key: %s, secret: %s.", consumerKey, consumerSecret)); + samlAppId = application.getId(); } @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + deleteApp(samlAppId); + client.close(); + restClient.closeHttpClient(); } @Test @@ -130,29 +133,18 @@ public void testSAML2BearerValidSAMLAssertion() { } } - @Test - public void testSAML2BearerInvalidAudience() throws RemoteException, IdentitySAMLSSOConfigServiceIdentityException { + @Test(dependsOnMethods = "testSAML2BearerValidSAMLAssertion") + public void testSAML2BearerInvalidAudience() { try { - client = HttpClientBuilder.create().build(); - // Set some invalid audience. - ServiceProvider application = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); - SAMLSSOServiceProviderDTO[] serviceProviders = - ssoConfigServiceClient.getServiceProviders().getServiceProviders(); - SAMLSSOServiceProviderDTO serviceProvider = null; - for (SAMLSSOServiceProviderDTO serviceProviderDTO : serviceProviders) { - if ("travelocity.com".equals(serviceProviderDTO.getIssuer())) { - serviceProvider = serviceProviderDTO; - break; - } - } - - Assert.assertNotNull(serviceProvider, "No service provider exists for issuer travelocity.com"); - serviceProvider.setRequestedAudiences(new String[]{}); - ssoConfigServiceClient.removeServiceProvider("travelocity.com"); - ssoConfigServiceClient.addServiceProvider(serviceProvider); - appMgtclient.updateApplicationData(application); + + SAML2ServiceProvider saml2AppConfig = getSAMLInboundDetailsOfApplication(samlAppId); + Assert.assertNotNull(saml2AppConfig, "No service provider exists for issuer" + ISSUER); + + saml2AppConfig.getSingleSignOnProfile().getAssertion().setAudiences(new ArrayList<>()); + updateApplicationInboundConfig(samlAppId, new SAML2Configuration().manualConfiguration(saml2AppConfig), + SAML); // Get a SAML response. String samlResponse = getSAMLResponse(); @@ -166,104 +158,82 @@ public void testSAML2BearerInvalidAudience() throws RemoteException, IdentitySAM // We should get an http 400 error code. Assert.assertEquals(httpResponse.getStatusLine().getStatusCode(), 400); - // We should get a non empty error message. + // We should get a non-empty error message. Assert.assertTrue(StringUtils.isNotBlank(IOUtils.toString(httpResponse.getEntity().getContent()))); } catch (Exception e) { Assert.fail("SAML Bearer Grant test failed with an exception.", e); - } finally { - - // Restore the default service provider. - ssoConfigServiceClient.removeServiceProvider("travelocity.com"); - ssoConfigServiceClient.addServiceProvider(createDefaultSSOServiceProviderDTO()); - - // We have to initiate the http client again or other tests will fail. - client = HttpClientBuilder.create().build(); } } /** - * Create and attache the default OAUTH application to a service provider for testing. + * Create a SAML Application for testing. * - * @return OAuth app DTO. - * @throws Exception + * @return ApplicationResponseModel application. + * @throws Exception Exception */ - private OAuthConsumerAppDTO createDefaultOAuthApplication() throws Exception { - - OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO(); - appDTO.setApplicationName(OAuth2Constant.OAUTH_APPLICATION_NAME); - appDTO.setCallbackUrl(OAuth2Constant.AUTHORIZED_URL); - appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appDTO.setGrantTypes("urn:ietf:params:oauth:grant-type:saml2-bearer"); - return createApplication(appDTO, SERVICE_PROVIDER_NAME); + private ApplicationResponseModel createSAMLApplication() throws Exception { + ApplicationModel applicationCreationModel = new ApplicationModel().name(SERVICE_PROVIDER_NAME); + applicationCreationModel.inboundProtocolConfiguration(new InboundProtocols().oidc(getOIDCConfigurations())); + applicationCreationModel.getInboundProtocolConfiguration().setSaml(getSAMLConfigurations()); + + String appId = addApplication(applicationCreationModel); + + return getApplication(appId); } /** - * Create and attach the SAML application to a service provider for testing. + * Create OIDC Configured ApplicationModel object. * - * @throws Exception + * @return ApplicationModel application. */ - private void createDefaultSAMLApplication() throws Exception { + private OpenIDConnectConfiguration getOIDCConfigurations() { + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "urn:ietf:params:oauth:grant-type:saml2-bearer"); - ServiceProvider serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME); + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.AUTHORIZED_URL); - InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = - new InboundAuthenticationRequestConfig(); - inboundAuthenticationRequestConfig.setInboundAuthType("samlsso"); - inboundAuthenticationRequestConfig.setInboundAuthKey("travelocity.com"); + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); - InboundAuthenticationRequestConfig[] inboundAuthenticationRequestConfigs = - serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs(); - List inboundAuthenticationRequestConfigsList = - new ArrayList<>(Arrays.asList(inboundAuthenticationRequestConfigs)); - inboundAuthenticationRequestConfigsList.add(inboundAuthenticationRequestConfig); - - InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig(); - inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs( - inboundAuthenticationRequestConfigsList.toArray(new InboundAuthenticationRequestConfig[0])); - - serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig); - - SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = createDefaultSSOServiceProviderDTO(); - boolean isCreated = ssoConfigServiceClient.addServiceProvider(samlssoServiceProviderDTO); - if (!isCreated) { - throw new Exception("App creation failed."); - } - - appMgtclient.updateApplicationData(serviceProvider); + return oidcConfig; } /** - * Create the SAML SSO DTO. + * Create SAML Configured ApplicationModel object. * - * @return SAML SSO DTO. + * @return ApplicationModel application. */ - private SAMLSSOServiceProviderDTO createDefaultSSOServiceProviderDTO() { - - SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO(); - samlssoServiceProviderDTO.setIssuer("travelocity.com"); - samlssoServiceProviderDTO.setAssertionConsumerUrls( - new String[]{String.format("http://localhost:8490/%s/home.jsp", "travelocity.com")}); - samlssoServiceProviderDTO.setDefaultAssertionConsumerUrl( - String.format("http://localhost:8490/%s/home.jsp", "travelocity.com")); - samlssoServiceProviderDTO.setAttributeConsumingServiceIndex("1239245949"); - samlssoServiceProviderDTO.setNameIDFormat("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"); - samlssoServiceProviderDTO.setDoSignAssertions(true); - samlssoServiceProviderDTO.setDoSignResponse(true); - samlssoServiceProviderDTO.setDoSingleLogout(true); - samlssoServiceProviderDTO.addRequestedAudiences(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); - samlssoServiceProviderDTO.addRequestedRecipients(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); - samlssoServiceProviderDTO.setLoginPageURL("/carbon/admin/login.jsp"); - samlssoServiceProviderDTO.setEnableAttributeProfile(true); - samlssoServiceProviderDTO.setEnableAttributesByDefault(true); - - return samlssoServiceProviderDTO; + private SAML2Configuration getSAMLConfigurations() { + SAML2ServiceProvider serviceProvider = new SAML2ServiceProvider(); + serviceProvider.setIssuer(ISSUER); + serviceProvider.addAssertionConsumerUrl(String.format("http://localhost:8490/%s/home.jsp", ISSUER)); + serviceProvider.setDefaultAssertionConsumerUrl(String.format("http://localhost:8490/%s/home.jsp", ISSUER)); + serviceProvider.setAttributeProfile(new SAMLAttributeProfile().enabled(true)); + serviceProvider.setSingleLogoutProfile(new SingleLogoutProfile().enabled(true)); + serviceProvider.setResponseSigning(new SAMLResponseSigning().enabled(true)); + + SAMLAssertionConfiguration assertion = new SAMLAssertionConfiguration(); + assertion.addAudiencesItem(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + assertion.addRecipientsItem(OAuth2Constant.ACCESS_TOKEN_ENDPOINT); + + SingleSignOnProfile ssoProfile = new SingleSignOnProfile().attributeConsumingServiceIndex("1239245949"); + ssoProfile.setAssertion(assertion); + + serviceProvider.setSingleSignOnProfile(ssoProfile); + + SAML2Configuration saml2Configuration = new SAML2Configuration(); + saml2Configuration.setManualConfiguration(serviceProvider); + + return saml2Configuration; } /** * Get the SAML response by calling the default SAML endpoint. * * @return SAML response. - * @throws Exception + * @throws Exception Exception */ private String getSAMLResponse() throws Exception { @@ -275,7 +245,7 @@ private String getSAMLResponse() throws Exception { "initiation request"); String samlRequest = Utils.extractDataFromResponse(response, CommonConstants.SAML_REQUEST_PARAM, 5); Assert.assertTrue(StringUtils.isNotBlank(samlRequest), "SAML request in response body is empty"); - response = sendSAMLRequest(SAML_SSO_URL, CommonConstants.SAML_REQUEST_PARAM, samlRequest); + response = sendSAMLRequest(samlRequest); EntityUtils.consume(response.getEntity()); // Added temporarily to debug intermittent failure. @@ -323,9 +293,9 @@ private String getSAMLResponse() throws Exception { * * @param samlResponse SAML response. * @return Extracted SAML assertion. - * @throws ParserConfigurationException - * @throws IOException - * @throws SAXException + * @throws ParserConfigurationException Exception + * @throws IOException Exception + * @throws SAXException Exception */ private String getSAMLAssersion(String samlResponse) throws ParserConfigurationException, IOException, SAXException { @@ -345,26 +315,24 @@ private String getSAMLAssersion(String samlResponse) throws ParserConfigurationE Assert.fail("Error while parsing the SAML response."); } - return Base64.encodeBase64String(sw.toString().getBytes(Charset.forName("UTF-8"))); + return Base64.encodeBase64String(sw.toString().getBytes(StandardCharsets.UTF_8)); } /** * Send SAML request to the SAML endpoint. * - * @param url URL of the endpoint. - * @param samlMsgKey Message key. * @param samlMsgValue Message value. * @return HTTP Response object that we get from calling the SAML endpoint. - * @throws IOException + * @throws IOException Exception */ - private HttpResponse sendSAMLRequest(String url, String samlMsgKey, String samlMsgValue) throws IOException { + private HttpResponse sendSAMLRequest(String samlMsgValue) throws IOException { List urlParameters = new ArrayList<>(); - HttpPost post = new HttpPost(url); + HttpPost post = new HttpPost(SAML_SSO_URL); post.setHeader("User-Agent", USER_AGENT); - urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue)); + urlParameters.add(new BasicNameValuePair(CommonConstants.SAML_REQUEST_PARAM, samlMsgValue)); urlParameters.add(new BasicNameValuePair(TENANT_DOMAIN_PARAM, "carbon.super")); post.setEntity(new UrlEncodedFormEntity(urlParameters)); @@ -377,7 +345,7 @@ private HttpResponse sendSAMLRequest(String url, String samlMsgKey, String samlM * * @param samlAssertion SAML assertion. * @return HTTP Response object that we get from calling the token endpoint. - * @throws IOException + * @throws IOException Exception */ private HttpResponse sendSAMLAssertion(String samlAssertion) throws IOException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java index d769942ada..c742999a3f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationAfterAccountDisablingTestCase.java @@ -35,17 +35,14 @@ import com.nimbusds.oauth2.sdk.id.ClientID; import com.nimbusds.oauth2.sdk.token.AccessToken; import com.nimbusds.oauth2.sdk.token.BearerAccessToken; -import java.rmi.RemoteException; -import java.util.Arrays; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.context.ConfigurationContextFactory; -import org.apache.commons.lang.ArrayUtils; + import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicNameValuePair; +import org.json.simple.JSONObject; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -54,23 +51,19 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig; -import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider; -import org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.identity.user.profile.stub.UserProfileMgtServiceUserProfileExceptionException; -import org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO; -import org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.um.ws.api.stub.ClaimValue; -import org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceUserStoreExceptionException; -import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient; -import org.wso2.identity.integration.common.clients.UserManagementClient; -import org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.mgt.UserIdentityManagementAdminServiceClient; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AccessTokenConfiguration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorsPatchReq; +import org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.ConnectorsPatchReq.OperationEnum; +import org.wso2.identity.integration.test.rest.api.server.identity.governance.v1.dto.PropertyReq; +import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserItemAddGroupobj; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserItemAddGroupobj.OpEnum; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; +import org.wso2.identity.integration.test.restclients.IdentityGovernanceRestClient; +import org.wso2.identity.integration.test.restclients.SCIM2RestClient; import org.wso2.identity.integration.test.utils.DataExtractUtil; import org.wso2.identity.integration.test.utils.OAuth2Constant; @@ -78,6 +71,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -89,42 +83,35 @@ */ public class OAuth2TokenRevocationAfterAccountDisablingTestCase extends OAuth2ServiceAbstractIntegrationTest { - private UserManagementClient userMgtClient; - private IdentityProviderMgtServiceClient idPMgtClient; - private IdentityProvider residentIDP; - private IdentityProviderMgtServiceClient tenantIDPMgtClient; - private UserProfileMgtServiceClient userProfileMgtClient; - private UserIdentityManagementAdminServiceClient userIdentityManagementAdminServiceClient; - private ApplicationManagementServiceClient applicationManagementServiceClient; - private RemoteUserStoreManagerServiceClient usmClient; - private final String tokenType; private final String adminUsername; private final String adminPassword; private final String activeTenant; private static final String TENANT_DOMAIN = "wso2.com"; - private static final String DEFAULT_STRING = "default"; private static final String TEST_USER_USERNAME = "testUser"; private static final String TEST_USER_PASSWORD = "Ab@123"; - private static final String ADMIN = "admin"; - - private static final String ACCOUNT_DISABLED_CLAIM_URI = "http://wso2.org/claims/identity/accountDisabled"; private static final String ENABLE_ACCOUNT_DISABLING_PROPERTY = "account.disable.handler.enable"; + private static final String CONNECTOR_ACCOUNT_DISABLE_HANDLER = "YWNjb3VudC5kaXNhYmxlLmhhbmRsZXI"; + private static final String CATEGORY_ACCOUNT_MANAGEMENT = "QWNjb3VudCBNYW5hZ2VtZW50"; - private static final String OAUTH_APPLICATION_NAME_1 = "oauthTestApplication1"; - private static final String OAUTH_APPLICATION_NAME_2 = "oauthTestApplication2"; + private static final String USER_SCHEMA_ATTRIBUTE ="urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"; + private static final String ACCOUNT_DISABLED_ATTRIBUTE ="accountDisabled"; private static final String APP_CALLBACK_URL = "http://localhost:8490/playground2/oauth2client"; private static final String SERVICE_PROVIDER_1_NAME = "PlaygroundServiceProvider1"; private static final String SERVICE_PROVIDER_2_NAME = "PlaygroundServiceProvider2"; private static final String TEST_NONCE = "test_nonce"; - private Map applications = new HashMap<>(); - private Map accessTokens = new HashMap<>(); - private Map privilegedAccessTokens = new HashMap<>(); + private final Map applications = new HashMap<>(); + private final Map accessTokens = new HashMap<>(); + private final Map privilegedAccessTokens = new HashMap<>(); private HttpClient client; + private SCIM2RestClient scim2RestClient; + private String userId; + private IdentityGovernanceRestClient identityGovernanceRestClient; + private ConnectorsPatchReq connectorPatchRequest; @DataProvider public static Object[][] oAuthConsumerApplicationProvider() { @@ -150,49 +137,38 @@ public OAuth2TokenRevocationAfterAccountDisablingTestCase(TestUserMode userMode) @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - createServiceProviderApplication(OAUTH_APPLICATION_NAME_1, SERVICE_PROVIDER_1_NAME); - createServiceProviderApplication(OAUTH_APPLICATION_NAME_2, SERVICE_PROVIDER_2_NAME); - addNewTestUser(); - ConfigurationContext configContext = ConfigurationContextFactory - .createConfigurationContextFromFileSystem(null, null); - applicationManagementServiceClient = - new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext); + createServiceProviderApplication(SERVICE_PROVIDER_1_NAME); + createServiceProviderApplication(SERVICE_PROVIDER_2_NAME); + + scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo); + identityGovernanceRestClient = new IdentityGovernanceRestClient(serverURL, tenantInfo); + + userId = addNewTestUser(); client = HttpClientBuilder.create().disableRedirectHandling().build(); - idPMgtClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL); - residentIDP = idPMgtClient.getResidentIdP(); - usmClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); - userIdentityManagementAdminServiceClient = new UserIdentityManagementAdminServiceClient(backendURL, - sessionCookie); - AuthenticatorClient logManager = new AuthenticatorClient(backendURL); - String secondaryTenantDomain = isServer.getTenantList().get(1); - String tenantCookie = logManager.login(ADMIN + "@" + secondaryTenantDomain, - ADMIN, isServer.getInstance().getHosts().get(DEFAULT_STRING)); - tenantIDPMgtClient = new IdentityProviderMgtServiceClient(tenantCookie, backendURL); } @AfterClass(alwaysRun = true) public void testClear() throws Exception { deleteUser(); - deleteSpApplication(SERVICE_PROVIDER_1_NAME); - deleteSpApplication(SERVICE_PROVIDER_2_NAME); - IdentityProviderProperty[] idpProperties = residentIDP.getIdpProperties(); - for (IdentityProviderProperty providerProperty : idpProperties) { - if (ENABLE_ACCOUNT_DISABLING_PROPERTY.equalsIgnoreCase(providerProperty.getName())) { - providerProperty.setValue("false"); - } - } - updateResidentIDP(residentIDP, true); + deleteApp(applications.get(SERVICE_PROVIDER_1_NAME)); + deleteApp(applications.get(SERVICE_PROVIDER_2_NAME)); + disableUserAccountDisablingFeature(); + scim2RestClient.closeHttpClient(); + identityGovernanceRestClient.closeHttpClient(); } @Test(description = "Create access tokens") - public void testCreateAccessTokens() throws URISyntaxException, IOException, ParseException { + public void testCreateAccessTokens() throws Exception { Set appKeys = applications.keySet(); for (String appName : appKeys) { - OAuthConsumerAppDTO appDTO = applications.get(appName); - ClientID consumerKey = new ClientID(appDTO.getOauthConsumerKey()); - Secret consumerSecret = new Secret(appDTO.getOauthConsumerSecret()); + String appId = applications.get(appName); + + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(appId); + ClientID consumerKey = new ClientID(oidcConfig.getClientId()); + Secret consumerSecret = new Secret(oidcConfig.getClientSecret()); + AccessToken accessToken = requestAccessToken(consumerKey, consumerSecret); accessTokens.put(appName, accessToken); AccessToken privilegedAccessToken = requestPrivilegedAccessToken(consumerKey, consumerSecret); @@ -214,28 +190,29 @@ public void testCreateAccessTokens() throws URISyntaxException, IOException, Par ) private void enableUserAccountDisablingFeature() throws Exception { - IdentityProviderProperty[] idpProperties = residentIDP.getIdpProperties(); - for (IdentityProviderProperty providerProperty : idpProperties) { - if (ENABLE_ACCOUNT_DISABLING_PROPERTY.equalsIgnoreCase(providerProperty.getName())) { - providerProperty.setValue("true"); - } - } - updateResidentIDP(residentIDP, true); + PropertyReq property = new PropertyReq(); + property.setName(ENABLE_ACCOUNT_DISABLING_PROPERTY); + property.setValue("true"); + + connectorPatchRequest = new ConnectorsPatchReq(); + connectorPatchRequest.setOperation(OperationEnum.UPDATE); + connectorPatchRequest.addProperties(property); + + identityGovernanceRestClient.updateConnectors(CATEGORY_ACCOUNT_MANAGEMENT , CONNECTOR_ACCOUNT_DISABLE_HANDLER, + connectorPatchRequest); } @Test(description = "Disabling the test user account", dependsOnMethods = "enableUserAccountDisablingFeature") - private void testDisableUserAccount() - throws RemoteException, RemoteUserStoreManagerServiceUserStoreExceptionException, - UserProfileMgtServiceUserProfileExceptionException { - - setUserClaim(ACCOUNT_DISABLED_CLAIM_URI, "true"); - ClaimValue[] claimValues = usmClient.getUserClaimValuesForClaims(TEST_USER_USERNAME, new String[] - {ACCOUNT_DISABLED_CLAIM_URI}, "default"); - String accountDisabledClaimValue = null; - if (ArrayUtils.isNotEmpty(claimValues)) { - accountDisabledClaimValue = claimValues[0].getValue(); - } - Assert.assertTrue(Boolean.parseBoolean(accountDisabledClaimValue), "User account didn't disabled"); + private void testDisableUserAccount() throws Exception { + + UserItemAddGroupobj disableUserPatchOp = new UserItemAddGroupobj().op(OpEnum.REPLACE); + disableUserPatchOp.setPath(USER_SCHEMA_ATTRIBUTE + ":" + ACCOUNT_DISABLED_ATTRIBUTE); + disableUserPatchOp.setValue(true); + scim2RestClient.updateUser(new PatchOperationRequestObject().addOperations(disableUserPatchOp), userId); + + Boolean accountActiveValue = (Boolean) ((JSONObject) scim2RestClient.getUser(userId).get(USER_SCHEMA_ATTRIBUTE)) + .get(ACCOUNT_DISABLED_ATTRIBUTE); + Assert.assertTrue(accountActiveValue, "User account didn't disabled"); } @Test( @@ -255,54 +232,42 @@ private void testIntrospectAccessTokenOfDisabledAccount() throws URISyntaxExcept } } - private void createServiceProviderApplication(String oAuthAppName, String serviceProviderName) throws Exception { + private void createServiceProviderApplication(String serviceProviderName) throws Exception { - OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO(); - appDTO.setApplicationName(oAuthAppName); - appDTO.setCallbackUrl(OAuth2Constant.CALLBACK_URL); - appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appDTO.setTokenType(tokenType); - appDTO.setGrantTypes("authorization_code password"); - OAuthConsumerAppDTO oAuthConsumerAppDTO = createApplication(appDTO, serviceProviderName); - applications.put(serviceProviderName, oAuthConsumerAppDTO); - } + ApplicationModel application = new ApplicationModel(); - private void addNewTestUser() - throws UserStoreException, RemoteException, RemoteUserStoreManagerServiceUserStoreExceptionException { + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "password"); - remoteUSMServiceClient.addUser(TEST_USER_USERNAME, TEST_USER_PASSWORD, null, null, - DEFAULT_STRING, false); - } + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL); + + AccessTokenConfiguration accessTokenConfig = new AccessTokenConfiguration().type(tokenType); + accessTokenConfig.setUserAccessTokenExpiryInSeconds(3600L); + accessTokenConfig.setApplicationAccessTokenExpiryInSeconds(3600L); - private void setUserClaim(String claimURI, String claimValue) - throws RemoteException, UserProfileMgtServiceUserProfileExceptionException { - - userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, sessionCookie); - UserProfileDTO profile = new UserProfileDTO(); - profile.setProfileName(DEFAULT_STRING); - UserFieldDTO disableAccountClaim = new UserFieldDTO(); - disableAccountClaim.setClaimUri(claimURI); - disableAccountClaim.setFieldValue(claimValue); - UserFieldDTO[] fields = new UserFieldDTO[1]; - fields[0] = disableAccountClaim; - profile.setFieldValues(fields); - userProfileMgtClient.setUserProfile(TEST_USER_USERNAME, profile); + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + oidcConfig.setAccessToken(accessTokenConfig); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(serviceProviderName); + + String applicationId = addApplication(application); + applications.put(serviceProviderName, applicationId); } - private void updateResidentIDP(IdentityProvider residentIdentityProvider, boolean isSuperTenant) throws Exception { + private String addNewTestUser() throws Exception { - FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = - residentIdentityProvider.getFederatedAuthenticatorConfigs(); - federatedAuthenticatorConfigs = Arrays.stream(federatedAuthenticatorConfigs).filter( - config -> config.getName().equalsIgnoreCase("samlsso") - ).toArray(FederatedAuthenticatorConfig[]::new); + UserObject userInfo = new UserObject(); + userInfo.setUserName(TEST_USER_USERNAME); + userInfo.setPassword(TEST_USER_PASSWORD); - residentIdentityProvider.setFederatedAuthenticatorConfigs(federatedAuthenticatorConfigs); - if (isSuperTenant) { - idPMgtClient.updateResidentIdP(residentIdentityProvider); - } else { - tenantIDPMgtClient.updateResidentIdP(residentIdentityProvider); - } + return scim2RestClient.createUser(userInfo); } private AccessToken requestAccessToken(ClientID key, Secret secret) @@ -319,7 +284,7 @@ private AccessToken requestAccessToken(ClientID key, Secret secret) private AuthorizationGrant getAuthorizationCode(ClientID key) throws IOException, URISyntaxException { - String sessionDataKey = ""; + String sessionDataKey; String sessionDataKeyConsent = ""; String sessionDataKeyResponse = getSessionDataKeyRequest(key.getValue()); @@ -345,8 +310,7 @@ private AuthorizationGrant getAuthorizationCode(ClientID key) throws IOException OAuth2Constant.AUTHORIZATION_CODE_NAME)); Assert.assertNotNull(authorizationCode, "Authorization code is null."); URI callbackURI = new URI(APP_CALLBACK_URL); - AuthorizationGrant grant = new AuthorizationCodeGrant(authorizationCode, callbackURI); - return grant; + return new AuthorizationCodeGrant(authorizationCode, callbackURI); } private String getSessionDataKeyRequest(String consumerKey) throws IOException { @@ -426,15 +390,17 @@ private TokenIntrospectionResponse introspectAccessToken(AccessToken accessToken return TokenIntrospectionResponse.parse(introspectionHTTPResp); } - private void deleteSpApplication(String applicationName) throws Exception { + private void disableUserAccountDisablingFeature() throws Exception { - applicationManagementServiceClient.deleteApplication(applicationName); + connectorPatchRequest.getProperties().get(0).setValue("false"); + identityGovernanceRestClient.updateConnectors(CATEGORY_ACCOUNT_MANAGEMENT , CONNECTOR_ACCOUNT_DISABLE_HANDLER, + connectorPatchRequest); } private void deleteUser() { try { - remoteUSMServiceClient.deleteUser(TEST_USER_USERNAME); + scim2RestClient.deleteUser(userId); } catch (Exception e) { Assert.fail("Error while deleting the user", e); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java index ac18fb2b18..c7fdf84ee5 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithMultipleSessionTerminationTestCase.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 LLC. (http://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at @@ -39,7 +39,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.util.Utils; import org.wso2.identity.integration.test.utils.CommonConstants; import org.wso2.identity.integration.test.utils.DataExtractUtil; @@ -71,6 +72,7 @@ public class OAuth2TokenRevocationWithMultipleSessionTerminationTestCase extends private HttpClient httpClientForFirstSession; private HttpClient httpClientForSecondSession; private static final String SESSION_API_ENDPOINT = "https://localhost:9853/t/carbon.super/api/users/v1/me/sessions"; + private String applicationId; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { @@ -85,17 +87,21 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void testConclude() throws Exception { - deleteApplication(); + deleteApp(applicationId); + restClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Create OAuth2 application") public void testCreateApplication() throws Exception { - OAuthConsumerAppDTO appDto = createApplication(); - Assert.assertNotNull(appDto, "Application creation failed."); - consumerKey = appDto.getOauthConsumerKey(); - Assert.assertNotNull(consumerKey, "OAuth clientId is invalid."); - consumerSecret = appDto.getOauthConsumerSecret(); + ApplicationResponseModel application = addApplication(); + Assert.assertNotNull(application, "OAuth App creation failed."); + applicationId = application.getId(); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(application.getId()); + + consumerKey = oidcConfig.getClientId(); + Assert.assertNotNull(consumerKey, "Application creation failed."); + consumerSecret = oidcConfig.getClientSecret(); } @Test(groups = "wso2.is", dependsOnMethods = {"testCreateApplication"}, @@ -155,9 +161,8 @@ public void testGetUserSessions() { "sessions using session management REST API") public void testDeleteUserSessions() { - String endpointURI = SESSION_API_ENDPOINT; // Delete all sessions using session management api. - getResponseOfDelete(endpointURI).then() + getResponseOfDelete(SESSION_API_ENDPOINT).then() .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_NO_CONTENT); @@ -189,7 +194,7 @@ public void testTokensRevocationSessionsAreTerminated() throws Exception { * @param key Basic authentication key. * @param secret Basic authentication secret. * @return JSON object of the response. - * @throws Exception + * @throws Exception Exception */ private JSONObject responseObject(HttpClient client, String endpoint, List postParameters, String key, String secret) throws Exception { @@ -282,7 +287,7 @@ private String generateAuthzCodeAccessToken(String authorizationCode, HttpClient private List getOIDCInitiationRequestParams(String scope) { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("grantType", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE)); urlParameters.add(new BasicNameValuePair("consumerKey", consumerKey)); urlParameters.add(new BasicNameValuePair("callbackurl", OAuth2Constant.CALLBACK_URL)); @@ -335,11 +340,11 @@ private Response getResponseOfDelete(String endpointURI) { * Get introspection endpoint response by callling introspection endpoint. * * @return JSONObject - * @throws Exception + * @throws Exception Exception */ private JSONObject testIntrospectionEndpoint(String accessToken, HttpClient client) throws Exception { - List urlParameters = new ArrayList(); + List urlParameters = new ArrayList<>(); urlParameters.add(new BasicNameValuePair("token", accessToken)); return responseObject(client, OAuth2Constant.INTRO_SPEC_ENDPOINT, urlParameters, userInfo.getUserName(), userInfo.getPassword()); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java index 22381ab048..bfdbf5f409 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/OAuth2TokenRevocationWithRevokedAccessToken.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019, WSO2 LLC. (http://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at @@ -11,7 +11,7 @@ * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -33,7 +33,6 @@ import com.nimbusds.oauth2.sdk.id.ClientID; import com.nimbusds.oauth2.sdk.token.AccessToken; import com.nimbusds.oauth2.sdk.token.BearerAccessToken; -import org.apache.http.impl.client.HttpClientBuilder; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -42,10 +41,17 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AccessTokenConfiguration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * This test class is used to check the behaviour of OAuth token revocation flow. @@ -60,6 +66,7 @@ public class OAuth2TokenRevocationWithRevokedAccessToken extends OAuth2ServiceAb private final String userPassword; private final String activeTenant; private static final String TENANT_DOMAIN = "wso2.com"; + private String applicationId; @Factory(dataProvider = "oAuthConsumerApplicationProvider") public OAuth2TokenRevocationWithRevokedAccessToken(String tokenType, TestUserMode userMode) throws Exception { @@ -87,18 +94,13 @@ public static Object[][] oAuthConsumerApplicationProvider() { @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO(); - appDTO.setApplicationName(OAuth2Constant.OAUTH_APPLICATION_NAME); - appDTO.setCallbackUrl(OAuth2Constant.CALLBACK_URL); - appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appDTO.setTokenType(tokenType); - appDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token " - + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm"); + ApplicationResponseModel application = createApp(); + applicationId = application.getId(); - OAuthConsumerAppDTO oAuthConsumerAppDTO = createApplication(appDTO, SERVICE_PROVIDER_NAME); + OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId); - consumerKey = new ClientID(oAuthConsumerAppDTO.getOauthConsumerKey()); - consumerSecret = new Secret(oAuthConsumerAppDTO.getOauthConsumerSecret()); + consumerKey = new ClientID(oidcConfig.getClientId()); + consumerSecret = new Secret(oidcConfig.getClientSecret()); } @Test(description = "Call revocation request with a revoked access token") @@ -237,9 +239,41 @@ private TokenIntrospectionResponse introspectAccessToken(AccessToken accessToken return TokenIntrospectionResponse.parse(introspectionHTTPResp); } + private ApplicationResponseModel createApp() throws Exception { + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "implicit", "password", "client_credentials", + "refresh_token", "urn:ietf:params:oauth:grant-type:saml2-bearer", "iwa:ntlm"); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + + AccessTokenConfiguration accessTokenConfig = new AccessTokenConfiguration().type(tokenType); + accessTokenConfig.setUserAccessTokenExpiryInSeconds(3600L); + accessTokenConfig.setApplicationAccessTokenExpiryInSeconds(3600L); + + oidcConfig.setAccessToken(accessTokenConfig); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(OAuth2Constant.OAUTH_APPLICATION_NAME); + + String appId = addApplication(application); + + return getApplication(appId); + } + @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); + deleteApp(applicationId); + restClient.closeHttpClient(); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/Oauth2OPIframeTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/Oauth2OPIframeTestCase.java index 95da7d8875..fb4715fe0c 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/Oauth2OPIframeTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/Oauth2OPIframeTestCase.java @@ -1,8 +1,8 @@ /* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 LLC. (http://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * @@ -20,7 +20,8 @@ import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -30,17 +31,17 @@ import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.automation.engine.context.beans.ContextUrls; import org.wso2.carbon.automation.engine.context.beans.Tenant; -import org.wso2.carbon.automation.engine.context.beans.User; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; -import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient; -import org.wso2.carbon.integration.common.utils.LoginLogoutClient; -import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient; -import org.wso2.identity.integration.common.clients.oauth.OauthAdminClient; -import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.InboundProtocols; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.restclients.OAuth2RestClient; import org.wso2.identity.integration.test.utils.OAuth2Constant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import static org.wso2.identity.integration.test.utils.OAuth2Constant.USER_AGENT; public class Oauth2OPIframeTestCase extends OAuth2ServiceAbstractIntegrationTest { @@ -48,18 +49,9 @@ public class Oauth2OPIframeTestCase extends OAuth2ServiceAbstractIntegrationTest public static final String CALL_BACK_URL = "https://localhost:9853/oidc/checksession?client_id=%s&redirect_uri=http" + "://localhost:8888/playground2/oauth2client"; - private AuthenticatorClient logManger; - private DefaultHttpClient client; - private final String username; - private final String userPassword; + private CloseableHttpClient client; private final AutomationContext context; - private String backendURL; - private String sessionCookie; - private Tenant tenantInfo; - private User userInfo; - private LoginLogoutClient loginLogoutClient; - private ContextUrls identityContextUrls; - private RemoteUserStoreManagerServiceClient remoteUSMServiceClient; + private String applicationId; @DataProvider(name = "configProvider") public static Object[][] configProvider() { @@ -69,56 +61,56 @@ public static Object[][] configProvider() { @Factory(dataProvider = "configProvider") public Oauth2OPIframeTestCase(TestUserMode userMode) throws Exception { + super.init(userMode); context = new AutomationContext("IDENTITY", userMode); - this.username = context.getContextTenant().getTenantAdmin().getUserName(); - this.userPassword = context.getContextTenant().getTenantAdmin().getPassword(); } @BeforeClass(alwaysRun = true) public void testInit() throws Exception { - backendURL = context.getContextUrls().getBackEndUrl(); - loginLogoutClient = new LoginLogoutClient(context); - logManger = new AuthenticatorClient(backendURL); - sessionCookie = logManger.login(username, userPassword, context.getInstance().getHosts().get("default")); - identityContextUrls = context.getContextUrls(); - tenantInfo = context.getContextTenant(); - userInfo = tenantInfo.getContextUser(); - appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null); - adminClient = new OauthAdminClient(backendURL, sessionCookie); - remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie); - + Tenant tenantInfo = context.getContextTenant(); + restClient = new OAuth2RestClient(serverURL, tenantInfo); setSystemproperties(); - client = new DefaultHttpClient(); + client = HttpClients.createDefault(); } @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - appMgtclient.deleteApplication(SERVICE_PROVIDER_NAME); - adminClient.removeOAuthApplicationData(consumerKey); - - logManger = null; + deleteApp(applicationId); + restClient.closeHttpClient(); consumerKey = null; } @Test(groups = "wso2.is", description = "Check Oauth2 application registration") public void testOPIFrameRegex() throws Exception { - OAuthConsumerAppDTO appConfigData = new OAuthConsumerAppDTO(); - appConfigData - .setApplicationName(org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH_APPLICATION_NAME); - appConfigData.setCallbackUrl(OAuth2Constant.CALLBACK_URL_REGEXP); - appConfigData.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2); - appConfigData.setGrantTypes("authorization_code implicit password client_credentials refresh_token " - + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm"); + ApplicationModel application = new ApplicationModel(); + + List grantTypes = new ArrayList<>(); + Collections.addAll(grantTypes, "authorization_code", "implicit", "password", "client_credentials", + "refresh_token", "urn:ietf:params:oauth:grant-type:saml2-bearer", "iwa:ntlm"); + + List callBackUrls = new ArrayList<>(); + Collections.addAll(callBackUrls, OAuth2Constant.CALLBACK_URL_REGEXP); + + OpenIDConnectConfiguration oidcConfig = new OpenIDConnectConfiguration(); + oidcConfig.setGrantTypes(grantTypes); + oidcConfig.setCallbackURLs(callBackUrls); + + InboundProtocols inboundProtocolsConfig = new InboundProtocols(); + inboundProtocolsConfig.setOidc(oidcConfig); + + application.setInboundProtocolConfiguration(inboundProtocolsConfig); + application.setName(SERVICE_PROVIDER_NAME); - OAuthConsumerAppDTO appDto = createApplication(appConfigData, SERVICE_PROVIDER_NAME); - Assert.assertNotNull(appDto, "Application creation failed."); + applicationId = addApplication(application); + Assert.assertNotNull(applicationId, "Application creation failed."); - consumerKey = appDto.getOauthConsumerKey(); + oidcConfig = getOIDCInboundDetailsOfApplication(applicationId); + consumerKey = oidcConfig.getClientId(); Assert.assertNotNull(consumerKey, "Application creation failed."); - consumerSecret = appDto.getOauthConsumerSecret(); + consumerSecret = oidcConfig.getClientSecret(); HttpResponse response; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java index 01b2326caa..380880d0e1 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/PermissionBasedScopeValidatorTestCase.java @@ -1,20 +1,19 @@ /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019, WSO2 LLC. (https://www.wso2.com). * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. - * */ package org.wso2.identity.integration.test.oauth2; @@ -41,8 +40,8 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; -import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider; -import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; import org.wso2.identity.integration.test.utils.OAuth2Constant; import java.io.IOException; @@ -58,6 +57,7 @@ public class PermissionBasedScopeValidatorTestCase extends OAuth2ServiceAbstract private static final String SYSTEM_SCOPE = "SYSTEM"; private static final String CALLBACK_URL = "https://localhost/callback"; private CloseableHttpClient client; + private String applicationId; @BeforeClass(alwaysRun = true) public void testInit() throws Exception { @@ -69,10 +69,11 @@ public void testInit() throws Exception { @AfterClass(alwaysRun = true) public void atEnd() throws Exception { - deleteApplication(); - removeOAuthApplicationData(); + deleteApp(applicationId); consumerKey = null; consumerSecret = null; + applicationId = null; + restClient.closeHttpClient(); } @Test(groups = "wso2.is", description = "Testing secured API without authentication.") @@ -154,10 +155,15 @@ private TokenIntrospectionResponse invokeIntrospectionService(AccessToken access private void createOauthApplication() throws Exception { - OAuthConsumerAppDTO oAuthConsumerAppDTO = getBasicOAuthApp(CALLBACK_URL); - ServiceProvider serviceProvider = registerServiceProviderWithOAuthInboundConfigs(oAuthConsumerAppDTO); - Assert.assertNotNull(serviceProvider, "OAuth App creation failed."); + ApplicationResponseModel application = getBasicOAuthApplication(CALLBACK_URL); + Assert.assertNotNull(application, "OAuth App creation failed."); + + OpenIDConnectConfiguration oidcInboundConfig = getOIDCInboundDetailsOfApplication(application.getId()); + consumerKey = oidcInboundConfig.getClientId(); Assert.assertNotNull(consumerKey, "Consumer Key is null."); + consumerSecret = oidcInboundConfig.getClientSecret(); Assert.assertNotNull(consumerSecret, "Consumer Secret is null."); + + applicationId = application.getId(); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AccessTokenConfiguration.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AccessTokenConfiguration.java index 9496bed937..a97cf611c0 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AccessTokenConfiguration.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AccessTokenConfiguration.java @@ -1,18 +1,20 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; @@ -27,6 +29,8 @@ public class AccessTokenConfiguration { private String type; private Long userAccessTokenExpiryInSeconds; private Long applicationAccessTokenExpiryInSeconds; + private Boolean revokeTokensWhenIDPSessionTerminated; + private Boolean validateTokenBinding; /** **/ @@ -82,7 +86,41 @@ public void setApplicationAccessTokenExpiryInSeconds(Long applicationAccessToken this.applicationAccessTokenExpiryInSeconds = applicationAccessTokenExpiryInSeconds; } + /** + **/ + public AccessTokenConfiguration validateTokenBinding(Boolean validateTokenBinding) { + + this.validateTokenBinding = validateTokenBinding; + return this; + } + + @ApiModelProperty(example = "false", value = "") + @JsonProperty("validateTokenBinding") + @Valid + public boolean getValidateTokenBinding() { + return validateTokenBinding; + } + public void setValidateTokenBinding(Boolean validateTokenBinding) { + this.validateTokenBinding = validateTokenBinding; + } + /** + **/ + public AccessTokenConfiguration revokeTokensWhenIDPSessionTerminated(Boolean revokeTokensWhenIDPSessionTerminated) { + + this.revokeTokensWhenIDPSessionTerminated = revokeTokensWhenIDPSessionTerminated; + return this; + } + + @ApiModelProperty(example = "false", value = "") + @JsonProperty("revokeTokensWhenIDPSessionTerminated") + @Valid + public boolean getRevokeTokensWhenIDPSessionTerminated() { + return revokeTokensWhenIDPSessionTerminated; + } + public void setRevokeTokensWhenIDPSessionTerminated(Boolean revokeTokensWhenIDPSessionTerminated) { + this.revokeTokensWhenIDPSessionTerminated = revokeTokensWhenIDPSessionTerminated; + } @Override public boolean equals(Object o) { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdditionalSpProperties.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdditionalSpProperties.java new file mode 100644 index 0000000000..0ebd697eeb --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdditionalSpProperties.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class AdditionalSpProperties { + + private String name; + private String value; + private String displayName; + + /** + * + **/ + public AdditionalSpProperties name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "isB2BSelfServiceApp") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + * + **/ + public AdditionalSpProperties value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "isB2BSelfServiceApp") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + /** + * + **/ + public AdditionalSpProperties displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "isB2BSelfServiceApp") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalSpProperties additionalSpProperties = (AdditionalSpProperties) o; + return Objects.equals(this.name, additionalSpProperties.name) && + Objects.equals(this.value, additionalSpProperties.value) && + Objects.equals(this.displayName, additionalSpProperties.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, value, displayName); + } + + @Override + public String toString() { + + return "class InboundProtocolListItem {\n" + + " name: " + toIndentedString(name) + "\n" + + " value: " + toIndentedString(value) + "\n" + + " displayName: " + toIndentedString(displayName) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdvancedApplicationConfiguration.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdvancedApplicationConfiguration.java index 60a3c8b5a9..db44e54519 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdvancedApplicationConfiguration.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AdvancedApplicationConfiguration.java @@ -1,45 +1,56 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModelProperty; +import java.util.List; import java.util.Objects; import javax.validation.Valid; public class AdvancedApplicationConfiguration { private Boolean saas; + + private Boolean discoverableByEndUsers; private Certificate certificate; private Boolean skipLoginConsent; private Boolean skipLogoutConsent; private Boolean returnAuthenticatedIdpList; private Boolean enableAuthorization; + private Boolean fragment; + private List additionalSpProperties; + + private Boolean useExternalConsentPage; + /** - * Decide whether this application is allowed to be accessed across tenants. - **/ + * Decide whether this application is allowed to be accessed across tenants. + **/ public AdvancedApplicationConfiguration saas(Boolean saas) { this.saas = saas; return this; } - + @ApiModelProperty(example = "false", value = "Decide whether this application is allowed to be accessed across tenants.") @JsonProperty("saas") @Valid @@ -50,6 +61,25 @@ public void setSaas(Boolean saas) { this.saas = saas; } + /** + * + **/ + public AdvancedApplicationConfiguration discoverableByEndUsers(Boolean discoverableByEndUsers) { + + this.discoverableByEndUsers = discoverableByEndUsers; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("discoverableByEndUsers") + @Valid + public Boolean getDiscoverableByEndUsers() { + return discoverableByEndUsers; + } + public void setDiscoverableByEndUsers(Boolean discoverableByEndUsers) { + this.discoverableByEndUsers = discoverableByEndUsers; + } + /** **/ public AdvancedApplicationConfiguration certificate(Certificate certificate) { @@ -139,7 +169,62 @@ public void setEnableAuthorization(Boolean enableAuthorization) { this.enableAuthorization = enableAuthorization; } + /** + * + **/ + public AdvancedApplicationConfiguration fragment(Boolean fragment) { + + this.fragment = fragment; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("fragment") + @Valid + public Boolean getFragment() { + return fragment; + } + public void setFragment(Boolean fragment) { + this.fragment = fragment; + } + + /** + * + **/ + public AdvancedApplicationConfiguration additionalSpProperties(List additionalSpProperties) { + + this.additionalSpProperties = additionalSpProperties; + return this; + } + + @ApiModelProperty() + @JsonProperty("additionalSpProperties") + @Valid + public List getAdditionalSpProperties() { + return additionalSpProperties; + } + public void setAdditionalSpProperties(List additionalSpProperties) { + this.additionalSpProperties = additionalSpProperties; + } + + /** + * + **/ + public AdvancedApplicationConfiguration useExternalConsentPage(Boolean useExternalConsentPage) { + + this.useExternalConsentPage = useExternalConsentPage; + return this; + } + @ApiModelProperty(example = "false") + @JsonProperty("useExternalConsentPage") + @Valid + public Boolean getUseExternalConsentPage() { + return useExternalConsentPage; + } + public void setUseExternalConsentPage(Boolean useExternalConsentPage) { + this.useExternalConsentPage = useExternalConsentPage; + } @Override public boolean equals(Object o) { @@ -152,16 +237,20 @@ public boolean equals(Object o) { } AdvancedApplicationConfiguration advancedApplicationConfiguration = (AdvancedApplicationConfiguration) o; return Objects.equals(this.saas, advancedApplicationConfiguration.saas) && - Objects.equals(this.certificate, advancedApplicationConfiguration.certificate) && + Objects.equals(this.discoverableByEndUsers, advancedApplicationConfiguration.discoverableByEndUsers) && + Objects.equals(this.certificate, advancedApplicationConfiguration.certificate) && Objects.equals(this.skipLoginConsent, advancedApplicationConfiguration.skipLoginConsent) && Objects.equals(this.skipLogoutConsent, advancedApplicationConfiguration.skipLogoutConsent) && Objects.equals(this.returnAuthenticatedIdpList, advancedApplicationConfiguration.returnAuthenticatedIdpList) && - Objects.equals(this.enableAuthorization, advancedApplicationConfiguration.enableAuthorization); + Objects.equals(this.enableAuthorization, advancedApplicationConfiguration.enableAuthorization) && + Objects.equals(this.fragment, advancedApplicationConfiguration.fragment) && + Objects.equals(this.additionalSpProperties, advancedApplicationConfiguration.additionalSpProperties) && + Objects.equals(this.useExternalConsentPage, advancedApplicationConfiguration.useExternalConsentPage); } @Override public int hashCode() { - return Objects.hash(saas, certificate, skipLoginConsent, skipLogoutConsent, returnAuthenticatedIdpList, enableAuthorization); + return Objects.hash(saas, discoverableByEndUsers, certificate, skipLoginConsent, skipLogoutConsent, returnAuthenticatedIdpList, enableAuthorization, fragment, additionalSpProperties, useExternalConsentPage); } @Override @@ -171,11 +260,15 @@ public String toString() { sb.append("class AdvancedApplicationConfiguration {\n"); sb.append(" saas: ").append(toIndentedString(saas)).append("\n"); + sb.append(" discoverableByEndUsers: ").append(toIndentedString(discoverableByEndUsers)).append("\n"); sb.append(" certificate: ").append(toIndentedString(certificate)).append("\n"); sb.append(" skipLoginConsent: ").append(toIndentedString(skipLoginConsent)).append("\n"); sb.append(" skipLogoutConsent: ").append(toIndentedString(skipLogoutConsent)).append("\n"); sb.append(" returnAuthenticatedIdpList: ").append(toIndentedString(returnAuthenticatedIdpList)).append("\n"); sb.append(" enableAuthorization: ").append(toIndentedString(enableAuthorization)).append("\n"); + sb.append(" fragment: ").append(toIndentedString(fragment)).append("\n"); + sb.append(" additionalSpProperties: ").append(toIndentedString(additionalSpProperties)).append("\n"); + sb.append(" useExternalConsentPage: ").append(toIndentedString(useExternalConsentPage)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationPatchModel.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationPatchModel.java new file mode 100644 index 0000000000..958f09faa6 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationPatchModel.java @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.util.Objects; + +public class ApplicationPatchModel { + + private String name; + private String description; + private String imageUrl; + private String accessUrl; + private String templateId; + private ClaimConfiguration claimConfiguration; + private AuthenticationSequence authenticationSequence; + private AdvancedApplicationConfiguration advancedConfigurations; + private ProvisioningConfiguration provisioningConfigurations; + + /** + **/ + public ApplicationPatchModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "pickup", required = true) + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + @Pattern(regexp="^[a-zA-Z0-9._-]+(?: [a-zA-Z0-9._-]+)*$") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApplicationPatchModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "This is the configuration for Pickup application.") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ApplicationPatchModel imageUrl(String imageUrl) { + + this.imageUrl = imageUrl; + return this; + } + + @ApiModelProperty(example = "https://example.com/logo/my-logo.png") + @JsonProperty("imageUrl") + @Valid + public String getImageUrl() { + return imageUrl; + } + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + /** + **/ + public ApplicationPatchModel accessUrl(String accessUrl) { + + this.accessUrl = accessUrl; + return this; + } + + @ApiModelProperty(example = "https://example.com/accessUrl") + @JsonProperty("accessUrl") + @Valid + public String getAccessUrl() { + return accessUrl; + } + public void setAccessUrl(String accessUrl) { + this.accessUrl = accessUrl; + } + + /** + **/ + public ApplicationPatchModel templateId(String templateId) { + + this.templateId = templateId; + return this; + } + + @ApiModelProperty(example = "templateId") + @JsonProperty("templateId") + @Valid + public String getTemplateId() { + return templateId; + } + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + /** + **/ + public ApplicationPatchModel claimConfiguration(ClaimConfiguration claimConfiguration) { + + this.claimConfiguration = claimConfiguration; + return this; + } + + @ApiModelProperty() + @JsonProperty("claimConfiguration") + @Valid + public ClaimConfiguration getClaimConfiguration() { + return claimConfiguration; + } + public void setClaimConfiguration(ClaimConfiguration claimConfiguration) { + this.claimConfiguration = claimConfiguration; + } + + /** + **/ + public ApplicationPatchModel authenticationSequence(AuthenticationSequence authenticationSequence) { + + this.authenticationSequence = authenticationSequence; + return this; + } + + @ApiModelProperty() + @JsonProperty("authenticationSequence") + @Valid + public AuthenticationSequence getAuthenticationSequence() { + return authenticationSequence; + } + public void setAuthenticationSequence(AuthenticationSequence authenticationSequence) { + this.authenticationSequence = authenticationSequence; + } + + /** + **/ + public ApplicationPatchModel advancedConfigurations(AdvancedApplicationConfiguration advancedConfigurations) { + + this.advancedConfigurations = advancedConfigurations; + return this; + } + + @ApiModelProperty() + @JsonProperty("advancedConfigurations") + @Valid + public AdvancedApplicationConfiguration getAdvancedConfigurations() { + return advancedConfigurations; + } + public void setAdvancedConfigurations(AdvancedApplicationConfiguration advancedConfigurations) { + this.advancedConfigurations = advancedConfigurations; + } + + /** + **/ + public ApplicationPatchModel provisioningConfigurations(ProvisioningConfiguration provisioningConfigurations) { + + this.provisioningConfigurations = provisioningConfigurations; + return this; + } + + @ApiModelProperty() + @JsonProperty("provisioningConfigurations") + @Valid + public ProvisioningConfiguration getProvisioningConfigurations() { + return provisioningConfigurations; + } + public void setProvisioningConfigurations(ProvisioningConfiguration provisioningConfigurations) { + this.provisioningConfigurations = provisioningConfigurations; + } + + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApplicationPatchModel applicationPatchModel = (ApplicationPatchModel) o; + return Objects.equals(this.name, applicationPatchModel.name) && + Objects.equals(this.description, applicationPatchModel.description) && + Objects.equals(this.imageUrl, applicationPatchModel.imageUrl) && + Objects.equals(this.accessUrl, applicationPatchModel.accessUrl) && + Objects.equals(this.templateId, applicationPatchModel.templateId) && + Objects.equals(this.claimConfiguration, applicationPatchModel.claimConfiguration) && + Objects.equals(this.authenticationSequence, applicationPatchModel.authenticationSequence) && + Objects.equals(this.advancedConfigurations, applicationPatchModel.advancedConfigurations) && + Objects.equals(this.provisioningConfigurations, applicationPatchModel.provisioningConfigurations); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, imageUrl, accessUrl, templateId, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class ApplicationPatchModel {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n"); + sb.append(" accessUrl: ").append(toIndentedString(accessUrl)).append("\n"); + sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); + sb.append(" claimConfiguration: ").append(toIndentedString(claimConfiguration)).append("\n"); + sb.append(" authenticationSequence: ").append(toIndentedString(authenticationSequence)).append("\n"); + sb.append(" advancedConfigurations: ").append(toIndentedString(advancedConfigurations)).append("\n"); + sb.append(" provisioningConfigurations: ").append(toIndentedString(provisioningConfigurations)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} \ No newline at end of file diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationResponseModel.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationResponseModel.java new file mode 100644 index 0000000000..ea7862fe14 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationResponseModel.java @@ -0,0 +1,445 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Objects; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.xml.bind.annotation.*; + +public class ApplicationResponseModel { + + private String id; + private String name; + private String description; + private String imageUrl; + private String accessUrl; + private String clientId; + private String issuer; + private String templateId; + private Boolean isManagementApp; + private ClaimConfiguration claimConfiguration; + private List inboundProtocols = null; + private AuthenticationSequence authenticationSequence; + private List appRoleConfigurations = null; + private AdvancedApplicationConfiguration advancedConfigurations; + private ProvisioningConfiguration provisioningConfigurations; + + @XmlType(name="AccessEnum") + @XmlEnum() + public enum AccessEnum { + + @XmlEnumValue("READ") READ("READ"), @XmlEnumValue("WRITE") WRITE("WRITE"); + + + private final String value; + + AccessEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ApplicationResponseModel.AccessEnum fromValue(String value) { + for (ApplicationResponseModel.AccessEnum b : ApplicationResponseModel.AccessEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private AccessEnum access = AccessEnum.READ; + + /** + **/ + public ApplicationResponseModel id(String id) { + + this.id = id; + return this; + } + + @ApiModelProperty(example = "394b8adcce24c64a8a09a0d80abf8c337bd253de") + @JsonProperty("id") + @Valid + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + /** + **/ + public ApplicationResponseModel name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "pickup", required = true) + @JsonProperty("name") + @Valid + @NotNull(message = "Property name cannot be null.") + @Pattern(regexp="^[a-zA-Z0-9._-]+(?: [a-zA-Z0-9._-]+)*$") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public ApplicationResponseModel description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "This is the configuration for Pickup application.") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public ApplicationResponseModel imageUrl(String imageUrl) { + + this.imageUrl = imageUrl; + return this; + } + + @ApiModelProperty(example = "https://example.com/logo/my-logo.png") + @JsonProperty("imageUrl") + @Valid + public String getImageUrl() { + return imageUrl; + } + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + /** + **/ + public ApplicationResponseModel accessUrl(String accessUrl) { + + this.accessUrl = accessUrl; + return this; + } + + @ApiModelProperty(example = "https://example.com/login") + @JsonProperty("accessUrl") + @Valid + public String getAccessUrl() { + return accessUrl; + } + public void setAccessUrl(String loginUrl) { + this.accessUrl = loginUrl; + } + + /** + **/ + public ApplicationResponseModel clientId(String clientId) { + + this.clientId = clientId; + return this; + } + + @ApiModelProperty(example = "SmrrDNXRYf1lMmDlnleeHTuXx_Ea") + @JsonProperty("clientId") + @Valid + public String getClientId() { + return clientId; + } + public void setClientId(String clientId) { + this.clientId = clientId; + } + + + /** + **/ + public ApplicationResponseModel issuer(String issuer) { + + this.issuer = issuer; + return this; + } + + @ApiModelProperty(example = "http://idp.example.com/metadata.php") + @JsonProperty("issuer") + @Valid + public String getIssuer() { + return issuer; + } + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + /** + **/ + public ApplicationResponseModel templateId(String templateId) { + + this.templateId = templateId; + return this; + } + + @ApiModelProperty(example = "980b8tester24c64a8a09a0d80abf8c337bd2555") + @JsonProperty("templateId") + @Valid + public String getTemplateId() { + return templateId; + } + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + /** + **/ + public ApplicationResponseModel templateId(Boolean isManagementApp) { + + this.isManagementApp = isManagementApp; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("isManagementApp") + @Valid + public Boolean getIsManagementApp() { + return isManagementApp; + } + public void setIsManagementApp(Boolean isManagementApp) { + this.isManagementApp = isManagementApp; + } + + + /** + **/ + public ApplicationResponseModel claimConfiguration(ClaimConfiguration claimConfiguration) { + + this.claimConfiguration = claimConfiguration; + return this; + } + + @ApiModelProperty() + @JsonProperty("claimConfiguration") + @Valid + public ClaimConfiguration getClaimConfiguration() { + return claimConfiguration; + } + public void setClaimConfiguration(ClaimConfiguration claimConfiguration) { + this.claimConfiguration = claimConfiguration; + } + + /** + **/ + public ApplicationResponseModel inboundProtocols(List inboundProtocols) { + + this.inboundProtocols = inboundProtocols; + return this; + } + + @ApiModelProperty() + @JsonProperty("inboundProtocols") + @Valid + public List getInboundProtocols() { + return inboundProtocols; + } + public void setInboundProtocols(List inboundProtocols) { + this.inboundProtocols = inboundProtocols; + } + + /** + **/ + public ApplicationResponseModel authenticationSequence(AuthenticationSequence authenticationSequence) { + + this.authenticationSequence = authenticationSequence; + return this; + } + + @ApiModelProperty() + @JsonProperty("authenticationSequence") + @Valid + public AuthenticationSequence getAuthenticationSequence() { + return authenticationSequence; + } + public void setAuthenticationSequence(AuthenticationSequence authenticationSequence) { + this.authenticationSequence = authenticationSequence; + } + + /** + **/ + public ApplicationResponseModel appRoleConfigurations(List appRoleConfigurations) { + + this.appRoleConfigurations = appRoleConfigurations; + return this; + } + + @ApiModelProperty() + @JsonProperty("appRoleConfigurations") + @Valid + public List getAppRoleConfigurations() { + return appRoleConfigurations; + } + public void setAppRoleConfigurations(List appRoleConfigurations) { + this.appRoleConfigurations = appRoleConfigurations; + } + + /** + **/ + public ApplicationResponseModel advancedConfigurations(AdvancedApplicationConfiguration advancedConfigurations) { + + this.advancedConfigurations = advancedConfigurations; + return this; + } + + @ApiModelProperty() + @JsonProperty("advancedConfigurations") + @Valid + public AdvancedApplicationConfiguration getAdvancedConfigurations() { + return advancedConfigurations; + } + public void setAdvancedConfigurations(AdvancedApplicationConfiguration advancedConfigurations) { + this.advancedConfigurations = advancedConfigurations; + } + + /** + **/ + public ApplicationResponseModel provisioningConfigurations(ProvisioningConfiguration provisioningConfigurations) { + + this.provisioningConfigurations = provisioningConfigurations; + return this; + } + + @ApiModelProperty() + @JsonProperty("provisioningConfigurations") + @Valid + public ProvisioningConfiguration getProvisioningConfigurations() { + return provisioningConfigurations; + } + public void setProvisioningConfigurations(ProvisioningConfiguration provisioningConfigurations) { + this.provisioningConfigurations = provisioningConfigurations; + } + + /** + **/ + public ApplicationResponseModel access(ApplicationResponseModel.AccessEnum access) { + + this.access = access; + return this; + } + + @ApiModelProperty() + @JsonProperty("access") + @Valid + public ApplicationResponseModel.AccessEnum getAccess() { + return access; + } + public void setAccess(ApplicationResponseModel.AccessEnum access) { + this.access = access; + } + + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApplicationResponseModel applicationResponseModel = (ApplicationResponseModel) o; + return Objects.equals(this.id, applicationResponseModel.id) && + Objects.equals(this.name, applicationResponseModel.name) && + Objects.equals(this.description, applicationResponseModel.description) && + Objects.equals(this.imageUrl, applicationResponseModel.imageUrl) && + Objects.equals(this.accessUrl, applicationResponseModel.accessUrl) && + Objects.equals(this.clientId, applicationResponseModel.clientId) && + Objects.equals(this.issuer, applicationResponseModel.issuer) && + Objects.equals(this.templateId, applicationResponseModel.templateId) && + Objects.equals(this.isManagementApp, applicationResponseModel.isManagementApp) && + Objects.equals(this.claimConfiguration, applicationResponseModel.claimConfiguration) && + Objects.equals(this.inboundProtocols, applicationResponseModel.inboundProtocols) && + Objects.equals(this.authenticationSequence, applicationResponseModel.authenticationSequence) && + Objects.equals(this.appRoleConfigurations, applicationResponseModel.appRoleConfigurations) && + Objects.equals(this.advancedConfigurations, applicationResponseModel.advancedConfigurations) && + Objects.equals(this.provisioningConfigurations, applicationResponseModel.provisioningConfigurations) && + Objects.equals(this.access, applicationResponseModel.access); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, description, imageUrl, accessUrl, clientId, issuer, templateId, isManagementApp, claimConfiguration, inboundProtocols, authenticationSequence, appRoleConfigurations, advancedConfigurations, provisioningConfigurations, access); + } + + @Override + public String toString() { + + return "class ApplicationResponseModel {\n" + + " id: " + toIndentedString(id) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " description: " + toIndentedString(description) + "\n" + + " imageUrl: " + toIndentedString(imageUrl) + "\n" + + " accessUrl: " + toIndentedString(accessUrl) + "\n" + + " clientId: " + toIndentedString(clientId) + "\n" + + " issuer: " + toIndentedString(issuer) + "\n" + + " templateId: " + toIndentedString(templateId) + "\n" + + " isManagementApp: " + toIndentedString(isManagementApp) + "\n" + + " claimConfiguration: " + toIndentedString(claimConfiguration) + "\n" + + " inboundProtocols: " + toIndentedString(inboundProtocols) + "\n" + + " authenticationSequence: " + toIndentedString(authenticationSequence) + "\n" + + " appRoleConfigurations: " + toIndentedString(appRoleConfigurations) + "\n" + + " advancedConfigurations: " + toIndentedString(advancedConfigurations) + "\n" + + " provisioningConfigurations: " + toIndentedString(provisioningConfigurations) + "\n" + + " access: " + toIndentedString(access) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AssertionEncryptionConfiguration.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AssertionEncryptionConfiguration.java new file mode 100644 index 0000000000..081f6c6d59 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/AssertionEncryptionConfiguration.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class AssertionEncryptionConfiguration { + + private Boolean enabled = false; + private String assertionEncryptionAlgorithm = "http://www.w3.org/2001/04/xmlenc#aes256-cbc"; + private String keyEncryptionAlgorithm = "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"; + + /** + * + **/ + public AssertionEncryptionConfiguration enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enabled") + @Valid + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * + **/ + public AssertionEncryptionConfiguration assertionEncryptionAlgorithm(String assertionEncryptionAlgorithm) { + + this.assertionEncryptionAlgorithm = assertionEncryptionAlgorithm; + return this; + } + + @ApiModelProperty() + @JsonProperty("assertionEncryptionAlgorithm") + @Valid + public String getAssertionEncryptionAlgorithm() { + return assertionEncryptionAlgorithm; + } + + public void setAssertionEncryptionAlgorithm(String assertionEncryptionAlgorithm) { + this.assertionEncryptionAlgorithm = assertionEncryptionAlgorithm; + } + + /** + * + **/ + public AssertionEncryptionConfiguration keyEncryptionAlgorithm(String keyEncryptionAlgorithm) { + + this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; + return this; + } + + @ApiModelProperty() + @JsonProperty("keyEncryptionAlgorithm") + @Valid + public String getKeyEncryptionAlgorithm() { + return keyEncryptionAlgorithm; + } + + public void setKeyEncryptionAlgorithm(String keyEncryptionAlgorithm) { + this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AssertionEncryptionConfiguration assertionEncryptionConfiguration = (AssertionEncryptionConfiguration) o; + return Objects.equals(this.enabled, assertionEncryptionConfiguration.enabled) && + Objects.equals(this.assertionEncryptionAlgorithm, + assertionEncryptionConfiguration.assertionEncryptionAlgorithm) && + Objects.equals(this.keyEncryptionAlgorithm, assertionEncryptionConfiguration.keyEncryptionAlgorithm); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, assertionEncryptionAlgorithm, keyEncryptionAlgorithm); + } + + @Override + public String toString() { + + return "class AssertionEncryptionConfiguration {\n" + + " enabled: " + toIndentedString(enabled) + "\n" + + " assertionEncryptionAlgorithm: " + toIndentedString(assertionEncryptionAlgorithm) + "\n" + + " keyEncryptionAlgorithm: " + toIndentedString(keyEncryptionAlgorithm) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } +} \ No newline at end of file diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/Claim.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/Claim.java new file mode 100644 index 0000000000..90026da4be --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/Claim.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; +import javax.validation.Valid; + +public class Claim { + + private String uri; + + /** + **/ + public Claim uri(String uri) { + + this.uri = uri; + return this; + } + + @ApiModelProperty(example = "http://wso2.org/claims/username") + @JsonProperty("uri") + @Valid + public String getUri() { + return uri; + } + public void setUri(String uri) { + this.uri = uri; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Claim claim = (Claim) o; + return Objects.equals(this.uri, claim.uri); + } + + @Override + public int hashCode() { + return Objects.hash(uri); + } + + @Override + public String toString() { + + return "class Claim {\n" + + " uri: " + toIndentedString(uri) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/IdpInitiatedSingleLogout.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/IdpInitiatedSingleLogout.java new file mode 100644 index 0000000000..5dea39d88d --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/IdpInitiatedSingleLogout.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class IdpInitiatedSingleLogout { + + private Boolean enabled = false; + private List returnToUrls; + + /** + * + **/ + public IdpInitiatedSingleLogout enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enabled") + @Valid + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * + **/ + public IdpInitiatedSingleLogout returnToUrls(List returnToUrls) { + + this.returnToUrls = returnToUrls; + return this; + } + + @ApiModelProperty() + @JsonProperty("returnToUrls") + @Valid + public List getReturnToUrls() { + return returnToUrls; + } + + public void setReturnToUrls(List returnToUrls) { + this.returnToUrls = returnToUrls; + } + + public IdpInitiatedSingleLogout addReturnToUrls(String returnToUrl) { + if (this.returnToUrls == null) { + this.returnToUrls = new ArrayList<>(); + } + this.returnToUrls.add(returnToUrl); + return this; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdpInitiatedSingleLogout idpInitiatedSingleLogout = (IdpInitiatedSingleLogout) o; + return Objects.equals(this.enabled, idpInitiatedSingleLogout.enabled) && + Objects.equals(this.returnToUrls, idpInitiatedSingleLogout.returnToUrls); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, returnToUrls); + } + + @Override + public String toString() { + + return "class IdpInitiatedSingleLogout {\n" + + " enabled: " + toIndentedString(enabled) + "\n" + + " returnToUrls: " + toIndentedString(returnToUrls) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java new file mode 100644 index 0000000000..ae570a401a --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolListItem.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; +import javax.validation.Valid; + +public class InboundProtocolListItem { + + private String type; + private String name; + private String self; + + /** + **/ + public InboundProtocolListItem type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "samlsso") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public InboundProtocolListItem name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "SAML2 Inbound") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public InboundProtocolListItem self(String self) { + + this.self = self; + return this; + } + + @ApiModelProperty(example = "/t/carbon.super/api/server/v1/applications/29048810-1447-4ea0-a348-30d15ab65fa3/inbound-protocols/saml") + @JsonProperty("self") + @Valid + public String getSelf() { + return self; + } + public void setSelf(String self) { + this.self = self; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InboundProtocolListItem inboundProtocolItem = (InboundProtocolListItem) o; + return Objects.equals(this.type, inboundProtocolItem.type) && + Objects.equals(this.name, inboundProtocolItem.name) && + Objects.equals(this.self, inboundProtocolItem.self); + } + + @Override + public int hashCode() { + return Objects.hash(type, name, self); + } + + @Override + public String toString() { + + return "class InboundProtocolListItem {\n" + + " type: " + toIndentedString(type) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " self: " + toIndentedString(self) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolsListResponse.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolsListResponse.java new file mode 100644 index 0000000000..0e4e9101bc --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/InboundProtocolsListResponse.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import javax.validation.Valid; + +public class InboundProtocolsListResponse { + + private List inboundProtocols = null; + + /** + **/ + public InboundProtocolsListResponse inboundProtocols(List inboundProtocols) { + + this.inboundProtocols = inboundProtocols; + return this; + } + + @ApiModelProperty() + @JsonProperty("inboundProtocols") + @Valid + public List getInboundProtocols() { + return inboundProtocols; + } + public void setInboundProtocols(List inboundProtocols) { + this.inboundProtocols = inboundProtocols; + } + + public InboundProtocolsListResponse addInboundProtocols(InboundProtocolListItem inboundProtocolItem) { + if (this.inboundProtocols == null) { + this.inboundProtocols = new ArrayList<>(); + } + this.inboundProtocols.add(inboundProtocolItem); + return this; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InboundProtocolsListResponse inboundProtocolListItem = (InboundProtocolsListResponse) o; + return Objects.equals(this.inboundProtocols, inboundProtocolListItem.inboundProtocols); + } + + @Override + public int hashCode() { return Objects.hash(inboundProtocols); } + + @Override + public String toString() { + + return "class InboundProtocolsListResponse {\n" + + " InboundProtocolListItem: " + toIndentedString(inboundProtocols) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/RoleConfig.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/RoleConfig.java index eef9ab436f..de3a5d0953 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/RoleConfig.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/RoleConfig.java @@ -1,18 +1,20 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; @@ -29,7 +31,7 @@ public class RoleConfig { private List mappings = null; private Boolean includeUserDomain; - private String claimId; + private Claim claim; /** **/ @@ -38,7 +40,7 @@ public RoleConfig mappings(List mappings) { this.mappings = mappings; return this; } - + @ApiModelProperty(value = "") @JsonProperty("mappings") @Valid @@ -77,20 +79,20 @@ public void setIncludeUserDomain(Boolean includeUserDomain) { /** **/ - public RoleConfig claimId(String claimId) { + public RoleConfig claim(Claim claim) { - this.claimId = claimId; + this.claim = claim; return this; } @ApiModelProperty(example = "http://wso2.org/claims/groups", value = "") - @JsonProperty("claimId") + @JsonProperty("claim") @Valid - public String getClaimId() { - return claimId; + public Claim getClaim() { + return claim; } - public void setClaimId(String claimId) { - this.claimId = claimId; + public void setClaim(Claim claim) { + this.claim = claim; } @@ -107,12 +109,12 @@ public boolean equals(Object o) { RoleConfig roleConfig = (RoleConfig) o; return Objects.equals(this.mappings, roleConfig.mappings) && Objects.equals(this.includeUserDomain, roleConfig.includeUserDomain) && - Objects.equals(this.claimId, roleConfig.claimId); + Objects.equals(this.claim, roleConfig.claim); } @Override public int hashCode() { - return Objects.hash(mappings, includeUserDomain, claimId); + return Objects.hash(mappings, includeUserDomain, claim); } @Override @@ -123,7 +125,7 @@ public String toString() { sb.append(" mappings: ").append(toIndentedString(mappings)).append("\n"); sb.append(" includeUserDomain: ").append(toIndentedString(includeUserDomain)).append("\n"); - sb.append(" claimId: ").append(toIndentedString(claimId)).append("\n"); + sb.append(" claim: ").append(toIndentedString(claim)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2Configuration.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2Configuration.java index f47d2be972..464c01842b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2Configuration.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2Configuration.java @@ -1,18 +1,20 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; @@ -26,7 +28,7 @@ public class SAML2Configuration { private String metadataFile; private String metadataURL; - private SAML2ServiceProvider serviceProvider; + private SAML2ServiceProvider manualConfiguration; /** **/ @@ -66,20 +68,20 @@ public void setMetadataURL(String metadataURL) { /** **/ - public SAML2Configuration serviceProvider(SAML2ServiceProvider serviceProvider) { + public SAML2Configuration manualConfiguration(SAML2ServiceProvider serviceProvider) { - this.serviceProvider = serviceProvider; + this.manualConfiguration = serviceProvider; return this; } @ApiModelProperty(value = "") @JsonProperty("serviceProvider") @Valid - public SAML2ServiceProvider getServiceProvider() { - return serviceProvider; + public SAML2ServiceProvider getManualConfiguration() { + return manualConfiguration; } - public void setServiceProvider(SAML2ServiceProvider serviceProvider) { - this.serviceProvider = serviceProvider; + public void setManualConfiguration(SAML2ServiceProvider manualConfiguration) { + this.manualConfiguration = manualConfiguration; } @@ -96,12 +98,12 @@ public boolean equals(Object o) { SAML2Configuration saML2Configuration = (SAML2Configuration) o; return Objects.equals(this.metadataFile, saML2Configuration.metadataFile) && Objects.equals(this.metadataURL, saML2Configuration.metadataURL) && - Objects.equals(this.serviceProvider, saML2Configuration.serviceProvider); + Objects.equals(this.manualConfiguration, saML2Configuration.manualConfiguration); } @Override public int hashCode() { - return Objects.hash(metadataFile, metadataURL, serviceProvider); + return Objects.hash(metadataFile, metadataURL, manualConfiguration); } @Override @@ -112,7 +114,7 @@ public String toString() { sb.append(" metadataFile: ").append(toIndentedString(metadataFile)).append("\n"); sb.append(" metadataURL: ").append(toIndentedString(metadataURL)).append("\n"); - sb.append(" serviceProvider: ").append(toIndentedString(serviceProvider)).append("\n"); + sb.append(" serviceProvider: ").append(toIndentedString(manualConfiguration)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2ServiceProvider.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2ServiceProvider.java index 60a9a60efc..167fc509bb 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2ServiceProvider.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAML2ServiceProvider.java @@ -1,18 +1,20 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; @@ -23,77 +25,19 @@ import java.util.List; import java.util.Objects; import javax.validation.Valid; -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; public class SAML2ServiceProvider { private String issuer; private String serviceProviderQualifier; private List assertionConsumerUrls = null; - private String defaultAssertionConsumerUrl; - private Boolean enableRequestSignatureValidation = true; - private Boolean enableAssertionEncryption = false; - private String assertionEncryptionAlgroithm; - private String keyEncryptionAlgorithm; - private String nameIdFormat = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; - private Boolean enableIdpInitiatedSingleSignOn = false; - private Boolean enableResponseSigning = true; - private String requestValidationCertificateAlias; - private String responseSigningAlgorithm; - private String responseDigestAlgorithm; - private Boolean enableSingleLogout = true; - private String singleLogoutResponseUrl; - private String singleLogoutRequestUrl; - -@XmlType(name="SingleLogoutMethodEnum") -@XmlEnum(String.class) -public enum SingleLogoutMethodEnum { - - @XmlEnumValue("backchannel") BACKCHANNEL(String.valueOf("backchannel")), @XmlEnumValue("frontchannel_http_redirect") FRONTCHANNEL_HTTP_REDIRECT(String.valueOf("frontchannel_http_redirect")), @XmlEnumValue("frontchannel_http_post") FRONTCHANNEL_HTTP_POST(String.valueOf("frontchannel_http_post")); - - - private String value; - - SingleLogoutMethodEnum(String v) { - value = v; - } - - public String value() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static SingleLogoutMethodEnum fromValue(String value) { - for (SingleLogoutMethodEnum b : SingleLogoutMethodEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } -} - - private SingleLogoutMethodEnum singleLogoutMethod; - private Boolean enableIdpInitiatedSingleLogOut = false; - private List idpInitiatedLogoutReturnUrls = null; - - private Boolean enableAttributeProfile = false; - private Boolean includedAttributeInResponseAlways = false; - private List audiences = null; - - private List recipients = null; - + private SingleSignOnProfile singleSignOnProfile; + private SAMLAttributeProfile attributeProfile; + private SingleLogoutProfile singleLogoutProfile; + private SAMLRequestValidation requestValidation; + private SAMLResponseSigning responseSigning; private Boolean enableAssertionQueryProfile = false; - private Boolean enableSAML2ArtifactBinding = false; - private Boolean enableSignatureValidationInArtifactBinding = false; - private String idPEntityidAlias; /** **/ @@ -102,8 +46,8 @@ public SAML2ServiceProvider issuer(String issuer) { this.issuer = issuer; return this; } - - @ApiModelProperty(value = "") + + @ApiModelProperty() @JsonProperty("issuer") @Valid public String getIssuer() { @@ -120,8 +64,8 @@ public SAML2ServiceProvider serviceProviderQualifier(String serviceProviderQuali this.serviceProviderQualifier = serviceProviderQualifier; return this; } - - @ApiModelProperty(value = "") + + @ApiModelProperty() @JsonProperty("serviceProviderQualifier") @Valid public String getServiceProviderQualifier() { @@ -138,8 +82,8 @@ public SAML2ServiceProvider assertionConsumerUrls(List assertionConsumer this.assertionConsumerUrls = assertionConsumerUrls; return this; } - - @ApiModelProperty(value = "") + + @ApiModelProperty() @JsonProperty("assertionConsumerUrls") @Valid public List getAssertionConsumerUrls() { @@ -149,11 +93,11 @@ public void setAssertionConsumerUrls(List assertionConsumerUrls) { this.assertionConsumerUrls = assertionConsumerUrls; } - public SAML2ServiceProvider addAssertionConsumerUrlsItem(String assertionConsumerUrlsItem) { + public SAML2ServiceProvider addAssertionConsumerUrl(String assertionConsumerUrl) { if (this.assertionConsumerUrls == null) { this.assertionConsumerUrls = new ArrayList<>(); } - this.assertionConsumerUrls.add(assertionConsumerUrlsItem); + this.assertionConsumerUrls.add(assertionConsumerUrl); return this; } @@ -164,8 +108,8 @@ public SAML2ServiceProvider defaultAssertionConsumerUrl(String defaultAssertionC this.defaultAssertionConsumerUrl = defaultAssertionConsumerUrl; return this; } - - @ApiModelProperty(value = "") + + @ApiModelProperty() @JsonProperty("defaultAssertionConsumerUrl") @Valid public String getDefaultAssertionConsumerUrl() { @@ -177,400 +121,102 @@ public void setDefaultAssertionConsumerUrl(String defaultAssertionConsumerUrl) { /** **/ - public SAML2ServiceProvider enableRequestSignatureValidation(Boolean enableRequestSignatureValidation) { + public SAML2ServiceProvider singleSignOnProfile(SingleSignOnProfile singleSignOnProfile) { - this.enableRequestSignatureValidation = enableRequestSignatureValidation; + this.singleSignOnProfile = singleSignOnProfile; return this; } - - @ApiModelProperty(value = "") - @JsonProperty("enableRequestSignatureValidation") - @Valid - public Boolean getEnableRequestSignatureValidation() { - return enableRequestSignatureValidation; - } - public void setEnableRequestSignatureValidation(Boolean enableRequestSignatureValidation) { - this.enableRequestSignatureValidation = enableRequestSignatureValidation; - } - - /** - **/ - public SAML2ServiceProvider enableAssertionEncryption(Boolean enableAssertionEncryption) { - this.enableAssertionEncryption = enableAssertionEncryption; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableAssertionEncryption") + @ApiModelProperty() + @JsonProperty("singleSignOnProfile") @Valid - public Boolean getEnableAssertionEncryption() { - return enableAssertionEncryption; + public SingleSignOnProfile getSingleSignOnProfile() { + return singleSignOnProfile; } - public void setEnableAssertionEncryption(Boolean enableAssertionEncryption) { - this.enableAssertionEncryption = enableAssertionEncryption; + public void setSingleSignOnProfile(SingleSignOnProfile singleSignOnProfile) { + this.singleSignOnProfile = singleSignOnProfile; } /** **/ - public SAML2ServiceProvider assertionEncryptionAlgroithm(String assertionEncryptionAlgroithm) { + public SAML2ServiceProvider attributeProfile(SAMLAttributeProfile attributeProfile) { - this.assertionEncryptionAlgroithm = assertionEncryptionAlgroithm; + this.attributeProfile = attributeProfile; return this; } - - @ApiModelProperty(value = "") - @JsonProperty("assertionEncryptionAlgroithm") - @Valid - public String getAssertionEncryptionAlgroithm() { - return assertionEncryptionAlgroithm; - } - public void setAssertionEncryptionAlgroithm(String assertionEncryptionAlgroithm) { - this.assertionEncryptionAlgroithm = assertionEncryptionAlgroithm; - } - - /** - **/ - public SAML2ServiceProvider keyEncryptionAlgorithm(String keyEncryptionAlgorithm) { - - this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("keyEncryptionAlgorithm") - @Valid - public String getKeyEncryptionAlgorithm() { - return keyEncryptionAlgorithm; - } - public void setKeyEncryptionAlgorithm(String keyEncryptionAlgorithm) { - this.keyEncryptionAlgorithm = keyEncryptionAlgorithm; - } - - /** - **/ - public SAML2ServiceProvider nameIdFormat(String nameIdFormat) { - - this.nameIdFormat = nameIdFormat; - return this; - } - - @ApiModelProperty(example = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", value = "") - @JsonProperty("nameIdFormat") - @Valid - public String getNameIdFormat() { - return nameIdFormat; - } - public void setNameIdFormat(String nameIdFormat) { - this.nameIdFormat = nameIdFormat; - } - - /** - **/ - public SAML2ServiceProvider enableIdpInitiatedSingleSignOn(Boolean enableIdpInitiatedSingleSignOn) { - - this.enableIdpInitiatedSingleSignOn = enableIdpInitiatedSingleSignOn; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableIdpInitiatedSingleSignOn") - @Valid - public Boolean getEnableIdpInitiatedSingleSignOn() { - return enableIdpInitiatedSingleSignOn; - } - public void setEnableIdpInitiatedSingleSignOn(Boolean enableIdpInitiatedSingleSignOn) { - this.enableIdpInitiatedSingleSignOn = enableIdpInitiatedSingleSignOn; - } - - /** - **/ - public SAML2ServiceProvider enableResponseSigning(Boolean enableResponseSigning) { - - this.enableResponseSigning = enableResponseSigning; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableResponseSigning") - @Valid - public Boolean getEnableResponseSigning() { - return enableResponseSigning; - } - public void setEnableResponseSigning(Boolean enableResponseSigning) { - this.enableResponseSigning = enableResponseSigning; - } - - /** - **/ - public SAML2ServiceProvider requestValidationCertificateAlias(String requestValidationCertificateAlias) { - - this.requestValidationCertificateAlias = requestValidationCertificateAlias; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("requestValidationCertificateAlias") - @Valid - public String getRequestValidationCertificateAlias() { - return requestValidationCertificateAlias; - } - public void setRequestValidationCertificateAlias(String requestValidationCertificateAlias) { - this.requestValidationCertificateAlias = requestValidationCertificateAlias; - } - - /** - **/ - public SAML2ServiceProvider responseSigningAlgorithm(String responseSigningAlgorithm) { - - this.responseSigningAlgorithm = responseSigningAlgorithm; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("responseSigningAlgorithm") - @Valid - public String getResponseSigningAlgorithm() { - return responseSigningAlgorithm; - } - public void setResponseSigningAlgorithm(String responseSigningAlgorithm) { - this.responseSigningAlgorithm = responseSigningAlgorithm; - } - - /** - **/ - public SAML2ServiceProvider responseDigestAlgorithm(String responseDigestAlgorithm) { - - this.responseDigestAlgorithm = responseDigestAlgorithm; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("responseDigestAlgorithm") - @Valid - public String getResponseDigestAlgorithm() { - return responseDigestAlgorithm; - } - public void setResponseDigestAlgorithm(String responseDigestAlgorithm) { - this.responseDigestAlgorithm = responseDigestAlgorithm; - } - /** - **/ - public SAML2ServiceProvider enableSingleLogout(Boolean enableSingleLogout) { - - this.enableSingleLogout = enableSingleLogout; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableSingleLogout") + @ApiModelProperty() + @JsonProperty("attributeProfile") @Valid - public Boolean getEnableSingleLogout() { - return enableSingleLogout; + public SAMLAttributeProfile getAttributeProfile() { + return attributeProfile; } - public void setEnableSingleLogout(Boolean enableSingleLogout) { - this.enableSingleLogout = enableSingleLogout; + public void setAttributeProfile(SAMLAttributeProfile attributeProfile) { + this.attributeProfile = attributeProfile; } /** - * Single logout response accepting endpoint **/ - public SAML2ServiceProvider singleLogoutResponseUrl(String singleLogoutResponseUrl) { + public SAML2ServiceProvider singleLogoutProfile(SingleLogoutProfile singleLogoutProfile) { - this.singleLogoutResponseUrl = singleLogoutResponseUrl; + this.singleLogoutProfile = singleLogoutProfile; return this; } - - @ApiModelProperty(value = "Single logout response accepting endpoint") - @JsonProperty("singleLogoutResponseUrl") - @Valid - public String getSingleLogoutResponseUrl() { - return singleLogoutResponseUrl; - } - public void setSingleLogoutResponseUrl(String singleLogoutResponseUrl) { - this.singleLogoutResponseUrl = singleLogoutResponseUrl; - } - - /** - * Single logout request accepting endpoint - **/ - public SAML2ServiceProvider singleLogoutRequestUrl(String singleLogoutRequestUrl) { - this.singleLogoutRequestUrl = singleLogoutRequestUrl; - return this; - } - - @ApiModelProperty(value = "Single logout request accepting endpoint") - @JsonProperty("singleLogoutRequestUrl") + @ApiModelProperty() + @JsonProperty("singleLogoutProfile") @Valid - public String getSingleLogoutRequestUrl() { - return singleLogoutRequestUrl; + public SingleLogoutProfile getSingleLogoutProfile() { + return singleLogoutProfile; } - public void setSingleLogoutRequestUrl(String singleLogoutRequestUrl) { - this.singleLogoutRequestUrl = singleLogoutRequestUrl; + public void setSingleLogoutProfile(SingleLogoutProfile singleLogoutProfile) { + this.singleLogoutProfile = singleLogoutProfile; } /** **/ - public SAML2ServiceProvider singleLogoutMethod(SingleLogoutMethodEnum singleLogoutMethod) { + public SAML2ServiceProvider requestValidation(SAMLRequestValidation requestValidation) { - this.singleLogoutMethod = singleLogoutMethod; + this.requestValidation = requestValidation; return this; } - - @ApiModelProperty(value = "") - @JsonProperty("singleLogoutMethod") - @Valid - public SingleLogoutMethodEnum getSingleLogoutMethod() { - return singleLogoutMethod; - } - public void setSingleLogoutMethod(SingleLogoutMethodEnum singleLogoutMethod) { - this.singleLogoutMethod = singleLogoutMethod; - } - /** - **/ - public SAML2ServiceProvider enableIdpInitiatedSingleLogOut(Boolean enableIdpInitiatedSingleLogOut) { - - this.enableIdpInitiatedSingleLogOut = enableIdpInitiatedSingleLogOut; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableIdpInitiatedSingleLogOut") + @ApiModelProperty() + @JsonProperty("requestValidation") @Valid - public Boolean getEnableIdpInitiatedSingleLogOut() { - return enableIdpInitiatedSingleLogOut; + public SAMLRequestValidation getRequestValidation() { + return requestValidation; } - public void setEnableIdpInitiatedSingleLogOut(Boolean enableIdpInitiatedSingleLogOut) { - this.enableIdpInitiatedSingleLogOut = enableIdpInitiatedSingleLogOut; + public void setRequestValidation(SAMLRequestValidation requestValidation) { + this.requestValidation = requestValidation; } /** **/ - public SAML2ServiceProvider idpInitiatedLogoutReturnUrls(List idpInitiatedLogoutReturnUrls) { + public SAML2ServiceProvider responseSigning(SAMLResponseSigning responseSigning) { - this.idpInitiatedLogoutReturnUrls = idpInitiatedLogoutReturnUrls; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("idpInitiatedLogoutReturnUrls") - @Valid - public List getIdpInitiatedLogoutReturnUrls() { - return idpInitiatedLogoutReturnUrls; - } - public void setIdpInitiatedLogoutReturnUrls(List idpInitiatedLogoutReturnUrls) { - this.idpInitiatedLogoutReturnUrls = idpInitiatedLogoutReturnUrls; - } - - public SAML2ServiceProvider addIdpInitiatedLogoutReturnUrlsItem(String idpInitiatedLogoutReturnUrlsItem) { - if (this.idpInitiatedLogoutReturnUrls == null) { - this.idpInitiatedLogoutReturnUrls = new ArrayList<>(); - } - this.idpInitiatedLogoutReturnUrls.add(idpInitiatedLogoutReturnUrlsItem); + this.responseSigning = responseSigning; return this; } - /** - **/ - public SAML2ServiceProvider enableAttributeProfile(Boolean enableAttributeProfile) { - - this.enableAttributeProfile = enableAttributeProfile; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableAttributeProfile") + @ApiModelProperty() + @JsonProperty("responseSigning") @Valid - public Boolean getEnableAttributeProfile() { - return enableAttributeProfile; + public SAMLResponseSigning getResponseSigning() { + return responseSigning; } - public void setEnableAttributeProfile(Boolean enableAttributeProfile) { - this.enableAttributeProfile = enableAttributeProfile; + public void setResponseSigning(SAMLResponseSigning responseSigning) { + this.responseSigning = responseSigning; } /** **/ - public SAML2ServiceProvider includedAttributeInResponseAlways(Boolean includedAttributeInResponseAlways) { - - this.includedAttributeInResponseAlways = includedAttributeInResponseAlways; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("includedAttributeInResponseAlways") - @Valid - public Boolean getIncludedAttributeInResponseAlways() { - return includedAttributeInResponseAlways; - } - public void setIncludedAttributeInResponseAlways(Boolean includedAttributeInResponseAlways) { - this.includedAttributeInResponseAlways = includedAttributeInResponseAlways; - } - - /** - * Additional audience values to be added to the SAML Assertions - **/ - public SAML2ServiceProvider audiences(List audiences) { - - this.audiences = audiences; - return this; - } - - @ApiModelProperty(example = "[\"https://app.example.com/saml\"]", value = "Additional audience values to be added to the SAML Assertions") - @JsonProperty("audiences") - @Valid - public List getAudiences() { - return audiences; - } - public void setAudiences(List audiences) { - this.audiences = audiences; - } - - public SAML2ServiceProvider addAudiencesItem(String audiencesItem) { - if (this.audiences == null) { - this.audiences = new ArrayList<>(); - } - this.audiences.add(audiencesItem); - return this; - } - - /** - * Additional recipient values to be added to the SAML Assertions - **/ - public SAML2ServiceProvider recipients(List recipients) { - - this.recipients = recipients; - return this; - } - - @ApiModelProperty(example = "[\"https://app.example.com/saml\"]", value = "Additional recipient values to be added to the SAML Assertions") - @JsonProperty("recipients") - @Valid - public List getRecipients() { - return recipients; - } - public void setRecipients(List recipients) { - this.recipients = recipients; - } - - public SAML2ServiceProvider addRecipientsItem(String recipientsItem) { - if (this.recipients == null) { - this.recipients = new ArrayList<>(); - } - this.recipients.add(recipientsItem); - return this; - } - - /** - **/ public SAML2ServiceProvider enableAssertionQueryProfile(Boolean enableAssertionQueryProfile) { this.enableAssertionQueryProfile = enableAssertionQueryProfile; return this; } - + @ApiModelProperty(value = "") @JsonProperty("enableAssertionQueryProfile") @Valid @@ -581,63 +227,6 @@ public void setEnableAssertionQueryProfile(Boolean enableAssertionQueryProfile) this.enableAssertionQueryProfile = enableAssertionQueryProfile; } - /** - **/ - public SAML2ServiceProvider enableSAML2ArtifactBinding(Boolean enableSAML2ArtifactBinding) { - - this.enableSAML2ArtifactBinding = enableSAML2ArtifactBinding; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableSAML2ArtifactBinding") - @Valid - public Boolean getEnableSAML2ArtifactBinding() { - return enableSAML2ArtifactBinding; - } - public void setEnableSAML2ArtifactBinding(Boolean enableSAML2ArtifactBinding) { - this.enableSAML2ArtifactBinding = enableSAML2ArtifactBinding; - } - - /** - **/ - public SAML2ServiceProvider enableSignatureValidationInArtifactBinding(Boolean enableSignatureValidationInArtifactBinding) { - - this.enableSignatureValidationInArtifactBinding = enableSignatureValidationInArtifactBinding; - return this; - } - - @ApiModelProperty(value = "") - @JsonProperty("enableSignatureValidationInArtifactBinding") - @Valid - public Boolean getEnableSignatureValidationInArtifactBinding() { - return enableSignatureValidationInArtifactBinding; - } - public void setEnableSignatureValidationInArtifactBinding(Boolean enableSignatureValidationInArtifactBinding) { - this.enableSignatureValidationInArtifactBinding = enableSignatureValidationInArtifactBinding; - } - - /** - * Default value is the IdP Entity ID value specified in Resident IdP - **/ - public SAML2ServiceProvider idPEntityidAlias(String idPEntityidAlias) { - - this.idPEntityidAlias = idPEntityidAlias; - return this; - } - - @ApiModelProperty(value = "Default value is the IdP Entity ID value specified in Resident IdP") - @JsonProperty("idPEntityidAlias") - @Valid - public String getIdPEntityidAlias() { - return idPEntityidAlias; - } - public void setIdPEntityidAlias(String idPEntityidAlias) { - this.idPEntityidAlias = idPEntityidAlias; - } - - - @Override public boolean equals(Object o) { @@ -652,73 +241,36 @@ public boolean equals(Object o) { Objects.equals(this.serviceProviderQualifier, saML2ServiceProvider.serviceProviderQualifier) && Objects.equals(this.assertionConsumerUrls, saML2ServiceProvider.assertionConsumerUrls) && Objects.equals(this.defaultAssertionConsumerUrl, saML2ServiceProvider.defaultAssertionConsumerUrl) && - Objects.equals(this.enableRequestSignatureValidation, saML2ServiceProvider.enableRequestSignatureValidation) && - Objects.equals(this.enableAssertionEncryption, saML2ServiceProvider.enableAssertionEncryption) && - Objects.equals(this.assertionEncryptionAlgroithm, saML2ServiceProvider.assertionEncryptionAlgroithm) && - Objects.equals(this.keyEncryptionAlgorithm, saML2ServiceProvider.keyEncryptionAlgorithm) && - Objects.equals(this.nameIdFormat, saML2ServiceProvider.nameIdFormat) && - Objects.equals(this.enableIdpInitiatedSingleSignOn, saML2ServiceProvider.enableIdpInitiatedSingleSignOn) && - Objects.equals(this.enableResponseSigning, saML2ServiceProvider.enableResponseSigning) && - Objects.equals(this.requestValidationCertificateAlias, saML2ServiceProvider.requestValidationCertificateAlias) && - Objects.equals(this.responseSigningAlgorithm, saML2ServiceProvider.responseSigningAlgorithm) && - Objects.equals(this.responseDigestAlgorithm, saML2ServiceProvider.responseDigestAlgorithm) && - Objects.equals(this.enableSingleLogout, saML2ServiceProvider.enableSingleLogout) && - Objects.equals(this.singleLogoutResponseUrl, saML2ServiceProvider.singleLogoutResponseUrl) && - Objects.equals(this.singleLogoutRequestUrl, saML2ServiceProvider.singleLogoutRequestUrl) && - Objects.equals(this.singleLogoutMethod, saML2ServiceProvider.singleLogoutMethod) && - Objects.equals(this.enableIdpInitiatedSingleLogOut, saML2ServiceProvider.enableIdpInitiatedSingleLogOut) && - Objects.equals(this.idpInitiatedLogoutReturnUrls, saML2ServiceProvider.idpInitiatedLogoutReturnUrls) && - Objects.equals(this.enableAttributeProfile, saML2ServiceProvider.enableAttributeProfile) && - Objects.equals(this.includedAttributeInResponseAlways, saML2ServiceProvider.includedAttributeInResponseAlways) && - Objects.equals(this.audiences, saML2ServiceProvider.audiences) && - Objects.equals(this.recipients, saML2ServiceProvider.recipients) && - Objects.equals(this.enableAssertionQueryProfile, saML2ServiceProvider.enableAssertionQueryProfile) && - Objects.equals(this.enableSAML2ArtifactBinding, saML2ServiceProvider.enableSAML2ArtifactBinding) && - Objects.equals(this.enableSignatureValidationInArtifactBinding, saML2ServiceProvider.enableSignatureValidationInArtifactBinding) && - Objects.equals(this.idPEntityidAlias, saML2ServiceProvider.idPEntityidAlias); + Objects.equals(this.singleSignOnProfile, saML2ServiceProvider.singleSignOnProfile) && + Objects.equals(this.attributeProfile, saML2ServiceProvider.attributeProfile) && + Objects.equals(this.singleLogoutProfile, saML2ServiceProvider.singleLogoutProfile) && + Objects.equals(this.requestValidation, saML2ServiceProvider.requestValidation) && + Objects.equals(this.responseSigning, saML2ServiceProvider.responseSigning) && + Objects.equals(this.enableAssertionQueryProfile, saML2ServiceProvider.enableAssertionQueryProfile); } @Override public int hashCode() { - return Objects.hash(issuer, serviceProviderQualifier, assertionConsumerUrls, defaultAssertionConsumerUrl, enableRequestSignatureValidation, enableAssertionEncryption, assertionEncryptionAlgroithm, keyEncryptionAlgorithm, nameIdFormat, enableIdpInitiatedSingleSignOn, enableResponseSigning, requestValidationCertificateAlias, responseSigningAlgorithm, responseDigestAlgorithm, enableSingleLogout, singleLogoutResponseUrl, singleLogoutRequestUrl, singleLogoutMethod, enableIdpInitiatedSingleLogOut, idpInitiatedLogoutReturnUrls, enableAttributeProfile, includedAttributeInResponseAlways, audiences, recipients, enableAssertionQueryProfile, enableSAML2ArtifactBinding, enableSignatureValidationInArtifactBinding, idPEntityidAlias); + return Objects.hash(issuer, serviceProviderQualifier, assertionConsumerUrls, defaultAssertionConsumerUrl, + singleSignOnProfile, attributeProfile, singleLogoutProfile, requestValidation, responseSigning, + enableAssertionQueryProfile); } @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SAML2ServiceProvider {\n"); - - sb.append(" issuer: ").append(toIndentedString(issuer)).append("\n"); - sb.append(" serviceProviderQualifier: ").append(toIndentedString(serviceProviderQualifier)).append("\n"); - sb.append(" assertionConsumerUrls: ").append(toIndentedString(assertionConsumerUrls)).append("\n"); - sb.append(" defaultAssertionConsumerUrl: ").append(toIndentedString(defaultAssertionConsumerUrl)).append("\n"); - sb.append(" enableRequestSignatureValidation: ").append(toIndentedString(enableRequestSignatureValidation)).append("\n"); - sb.append(" enableAssertionEncryption: ").append(toIndentedString(enableAssertionEncryption)).append("\n"); - sb.append(" assertionEncryptionAlgroithm: ").append(toIndentedString(assertionEncryptionAlgroithm)).append("\n"); - sb.append(" keyEncryptionAlgorithm: ").append(toIndentedString(keyEncryptionAlgorithm)).append("\n"); - sb.append(" nameIdFormat: ").append(toIndentedString(nameIdFormat)).append("\n"); - sb.append(" enableIdpInitiatedSingleSignOn: ").append(toIndentedString(enableIdpInitiatedSingleSignOn)).append("\n"); - sb.append(" enableResponseSigning: ").append(toIndentedString(enableResponseSigning)).append("\n"); - sb.append(" requestValidationCertificateAlias: ").append(toIndentedString(requestValidationCertificateAlias)).append("\n"); - sb.append(" responseSigningAlgorithm: ").append(toIndentedString(responseSigningAlgorithm)).append("\n"); - sb.append(" responseDigestAlgorithm: ").append(toIndentedString(responseDigestAlgorithm)).append("\n"); - sb.append(" enableSingleLogout: ").append(toIndentedString(enableSingleLogout)).append("\n"); - sb.append(" singleLogoutResponseUrl: ").append(toIndentedString(singleLogoutResponseUrl)).append("\n"); - sb.append(" singleLogoutRequestUrl: ").append(toIndentedString(singleLogoutRequestUrl)).append("\n"); - sb.append(" singleLogoutMethod: ").append(toIndentedString(singleLogoutMethod)).append("\n"); - sb.append(" enableIdpInitiatedSingleLogOut: ").append(toIndentedString(enableIdpInitiatedSingleLogOut)).append("\n"); - sb.append(" idpInitiatedLogoutReturnUrls: ").append(toIndentedString(idpInitiatedLogoutReturnUrls)).append("\n"); - sb.append(" enableAttributeProfile: ").append(toIndentedString(enableAttributeProfile)).append("\n"); - sb.append(" includedAttributeInResponseAlways: ").append(toIndentedString(includedAttributeInResponseAlways)).append("\n"); - sb.append(" audiences: ").append(toIndentedString(audiences)).append("\n"); - sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n"); - sb.append(" enableAssertionQueryProfile: ").append(toIndentedString(enableAssertionQueryProfile)).append("\n"); - sb.append(" enableSAML2ArtifactBinding: ").append(toIndentedString(enableSAML2ArtifactBinding)).append("\n"); - sb.append(" enableSignatureValidationInArtifactBinding: ").append(toIndentedString(enableSignatureValidationInArtifactBinding)).append("\n"); - sb.append(" idPEntityidAlias: ").append(toIndentedString(idPEntityidAlias)).append("\n"); - sb.append("}"); - return sb.toString(); + return "class SAML2ServiceProvider {\n" + + " issuer: " + toIndentedString(issuer) + "\n" + + " serviceProviderQualifier: " + toIndentedString(serviceProviderQualifier) + "\n" + + " assertionConsumerUrls: " + toIndentedString(assertionConsumerUrls) + "\n" + + " defaultAssertionConsumerUrl: " + toIndentedString(defaultAssertionConsumerUrl) + "\n" + + " singleSignOnProfile: " + toIndentedString(singleSignOnProfile) + "\n" + + " attributeProfile: " + toIndentedString(attributeProfile) + "\n" + + " singleLogoutProfile: " + toIndentedString(singleLogoutProfile) + "\n" + + " requestValidation: " + toIndentedString(requestValidation) + "\n" + + " responseSigning: " + toIndentedString(responseSigning) + "\n" + + " enableAssertionQueryProfile: " + toIndentedString(enableAssertionQueryProfile) + "\n" + + "}"; } /** @@ -730,7 +282,7 @@ private String toIndentedString(Object o) { if (o == null) { return "null"; } - return o.toString().replace("\n", "\n"); + return o.toString(); } } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLAssertionConfiguration.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLAssertionConfiguration.java new file mode 100644 index 0000000000..ce9f25734a --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLAssertionConfiguration.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class SAMLAssertionConfiguration { + + private String nameIdFormat = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"; + private List audiences = null; + private List recipients = null; + private String digestAlgorithm; + private AssertionEncryptionConfiguration encryption; + + /** + * + **/ + public SAMLAssertionConfiguration nameIdFormat(String nameIdFormat) { + + this.nameIdFormat = nameIdFormat; + return this; + } + + @ApiModelProperty() + @JsonProperty("nameIdFormat") + @Valid + public String getNameIdFormat() { + return nameIdFormat; + } + + public void setNameIdFormat(String nameIdFormat) { + this.nameIdFormat = nameIdFormat; + } + + /** + **/ + public SAMLAssertionConfiguration audiences(List audiences) { + + this.audiences = audiences; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("audiences") + @Valid + public List getAudiences() { + return audiences; + } + public void setAudiences(List audiences) { + this.audiences = audiences; + } + + public SAMLAssertionConfiguration addAudiencesItem(String audiencesItem) { + if (this.audiences == null) { + this.audiences = new ArrayList<>(); + } + this.audiences.add(audiencesItem); + return this; + } + + /** + **/ + public SAMLAssertionConfiguration recipients(List recipients) { + + this.recipients = recipients; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("recipients") + @Valid + public List getRecipients() { + return recipients; + } + public void setRecipients(List recipients) { + this.recipients = recipients; + } + + public SAMLAssertionConfiguration addRecipientsItem(String recipientsItem) { + if (this.recipients == null) { + this.recipients = new ArrayList<>(); + } + this.recipients.add(recipientsItem); + return this; + } + + /** + * + **/ + public SAMLAssertionConfiguration digestAlgorithm(String digestAlgorithm) { + + this.digestAlgorithm = digestAlgorithm; + return this; + } + + @ApiModelProperty() + @JsonProperty("digestAlgorithm") + @Valid + public String getDigestAlgorithm() { + return digestAlgorithm; + } + + public void setDigestAlgorithm(String digestAlgorithm) { + this.digestAlgorithm = digestAlgorithm; + } + + /** + * + **/ + public SAMLAssertionConfiguration encryption(AssertionEncryptionConfiguration encryption) { + + this.encryption = encryption; + return this; + } + + @ApiModelProperty() + @JsonProperty("encryption") + @Valid + public AssertionEncryptionConfiguration getEncryption() { + return encryption; + } + + public void setEncryption(AssertionEncryptionConfiguration encryption) { + this.encryption = encryption; + } + + @Override + public int hashCode() { + return Objects.hash(encryption, nameIdFormat, digestAlgorithm); + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SAMLAssertionConfiguration SAMLAssertionConfiguration = (SAMLAssertionConfiguration) o; + return Objects.equals(this.nameIdFormat, SAMLAssertionConfiguration.nameIdFormat) && + Objects.equals(this.audiences, SAMLAssertionConfiguration.audiences) && + Objects.equals(this.recipients, SAMLAssertionConfiguration.recipients) && + Objects.equals(this.digestAlgorithm, SAMLAssertionConfiguration.digestAlgorithm) && + Objects.equals(this.encryption, SAMLAssertionConfiguration.encryption); + } + + @Override + public String toString() { + + return "class SAMLAssertionConfiguration {\n" + + " nameIdFormat: " + toIndentedString(nameIdFormat) + "\n" + + " audiences: " + toIndentedString(audiences) + "\n" + + " recipients: " + toIndentedString(recipients) + "\n" + + " digestAlgorithm: " + toIndentedString(digestAlgorithm) + "\n" + + " encryption: " + toIndentedString(encryption) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLAttributeProfile.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLAttributeProfile.java new file mode 100644 index 0000000000..7bfbb4eef0 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLAttributeProfile.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class SAMLAttributeProfile { + + private Boolean enabled = false; + private Boolean alwaysIncludeAttributesInResponse = false; + + /** + * + **/ + public SAMLAttributeProfile enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enabled") + @Valid + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * + **/ + public SAMLAttributeProfile alwaysIncludeAttributesInResponse(Boolean alwaysIncludeAttributesInResponse) { + + this.alwaysIncludeAttributesInResponse = alwaysIncludeAttributesInResponse; + return this; + } + + @ApiModelProperty() + @JsonProperty("alwaysIncludeAttributesInResponse") + @Valid + public Boolean getAlwaysIncludeAttributesInResponse() { + return alwaysIncludeAttributesInResponse; + } + + public void setAlwaysIncludeAttributesInResponse(Boolean alwaysIncludeAttributesInResponse) { + this.alwaysIncludeAttributesInResponse = alwaysIncludeAttributesInResponse; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SAMLAttributeProfile samlAttributeProfile = (SAMLAttributeProfile) o; + return Objects.equals(this.enabled, samlAttributeProfile.enabled) && + Objects.equals(this.alwaysIncludeAttributesInResponse, + samlAttributeProfile.alwaysIncludeAttributesInResponse); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, alwaysIncludeAttributesInResponse); + } + + @Override + public String toString() { + + return "class SAMLAttributeProfile {\n" + + " enabled: " + toIndentedString(enabled) + "\n" + + " alwaysIncludeAttributesInResponse: " + toIndentedString(alwaysIncludeAttributesInResponse) + "\n" + + "}"; + } + + /** + * Convert the given object to String with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLRequestValidation.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLRequestValidation.java new file mode 100644 index 0000000000..f01f4b3c8e --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLRequestValidation.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class SAMLRequestValidation { + private Boolean enableSignatureValidation = true; + private String signatureValidationCertAlias; + + /** + * + **/ + public SAMLRequestValidation enableSignatureValidation(Boolean enableSignatureValidation) { + + this.enableSignatureValidation = enableSignatureValidation; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enableSignatureValidation") + @Valid + public Boolean getEnableSignatureValidation() { + return enableSignatureValidation; + } + + public void setEnableSignatureValidation(Boolean enableSignatureValidation) { + this.enableSignatureValidation = enableSignatureValidation; + } + + /** + * + **/ + public SAMLRequestValidation signatureValidationCertAlias(String signatureValidationCertAlias) { + + this.signatureValidationCertAlias = signatureValidationCertAlias; + return this; + } + + @ApiModelProperty() + @JsonProperty("signatureValidationCertAlias") + @Valid + public String getSignatureValidationCertAlias() { + return signatureValidationCertAlias; + } + + public void setSignatureValidationCertAlias(String signatureValidationCertAlias) { + this.signatureValidationCertAlias = signatureValidationCertAlias; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SAMLRequestValidation samlRequestValidation = (SAMLRequestValidation) o; + return Objects.equals(this.enableSignatureValidation, samlRequestValidation.enableSignatureValidation) && + Objects.equals(this.signatureValidationCertAlias, samlRequestValidation.signatureValidationCertAlias); + } + + @Override + public int hashCode() { + return Objects.hash(enableSignatureValidation, signatureValidationCertAlias); + } + + @Override + public String toString() { + + return "class SAMLRequestValidation {\n" + + " enableSignatureValidation: " + toIndentedString(enableSignatureValidation) + "\n" + + " signatureValidationCertAlias: " + toIndentedString(signatureValidationCertAlias) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLResponseSigning.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLResponseSigning.java new file mode 100644 index 0000000000..2184eb5b5e --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SAMLResponseSigning.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class SAMLResponseSigning { + private Boolean enabled = true; + private String signingAlgorithm; + + /** + * + **/ + public SAMLResponseSigning enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enabled") + @Valid + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * + **/ + public SAMLResponseSigning signingAlgorithm(String signingAlgorithm) { + + this.signingAlgorithm = signingAlgorithm; + return this; + } + + @ApiModelProperty() + @JsonProperty("signingAlgorithm") + @Valid + public String getSigningAlgorithm() { + return signingAlgorithm; + } + + public void setSigningAlgorithm(String signingAlgorithm) { + this.signingAlgorithm = signingAlgorithm; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SAMLResponseSigning samlResponseSigning = (SAMLResponseSigning) o; + return Objects.equals(this.enabled, samlResponseSigning.enabled) && + Objects.equals(this.signingAlgorithm, samlResponseSigning.signingAlgorithm); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, signingAlgorithm); + } + + @Override + public String toString() { + + return "class SAMLResponseSigning {\n" + + " enabled: " + toIndentedString(enabled) + "\n" + + " signingAlgorithm: " + toIndentedString(signingAlgorithm) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SingleLogoutProfile.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SingleLogoutProfile.java new file mode 100644 index 0000000000..40b6bfaa9c --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SingleLogoutProfile.java @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; +import java.util.Objects; + +public class SingleLogoutProfile { + + private Boolean enabled; + private String logoutRequestUrl; + private String logoutResponseUrl; + + @XmlType(name="LOGOUTMETHODEnum") + @XmlEnum() + public enum LOGOUTMETHODEnum { + + @XmlEnumValue("BACKCHANNEL") BACKCHANNEL("BACKCHANNEL"), + @XmlEnumValue("FRONTCHANNEL_HTTP_REDIRECT") FRONTCHANNEL_HTTP_REDIRECT("FRONTCHANNEL_HTTP_REDIRECT"), + @XmlEnumValue("FRONTCHANNEL_HTTP_POST") FRONTCHANNEL_HTTP_POST("FRONTCHANNEL_HTTP_POST"); + + private final String value; + + LOGOUTMETHODEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LOGOUTMETHODEnum fromValue(String value) { + for (LOGOUTMETHODEnum b : LOGOUTMETHODEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private LOGOUTMETHODEnum logoutMethod; + private IdpInitiatedSingleLogout idpInitiatedSingleLogout; + + /** + * + **/ + public SingleLogoutProfile enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enabled") + @Valid + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + /** + * + **/ + public SingleLogoutProfile logoutRequestUrl(String logoutRequestUrl) { + + this.logoutRequestUrl = logoutRequestUrl; + return this; + } + + @ApiModelProperty() + @JsonProperty("logoutRequestUrl") + @Valid + public String getLogoutRequestUrl() { + return logoutRequestUrl; + } + + public void setLogoutRequestUrl(String logoutRequestUrl) { + this.logoutRequestUrl = logoutRequestUrl; + } + + /** + * + **/ + public SingleLogoutProfile logoutResponseUrl(String logoutResponseUrl) { + + this.logoutResponseUrl = logoutResponseUrl; + return this; + } + + @ApiModelProperty() + @JsonProperty("logoutResponseUrl") + @Valid + public String getLogoutResponseUrl() { + return logoutResponseUrl; + } + + public void setLogoutResponseUrl(String logoutResponseUrl) { + this.logoutResponseUrl = logoutResponseUrl; + } + + /** + * + **/ + public SingleLogoutProfile logoutMethod(LOGOUTMETHODEnum logoutMethod) { + + this.logoutMethod = logoutMethod; + return this; + } + + @ApiModelProperty() + @JsonProperty("logoutMethod") + @Valid + public LOGOUTMETHODEnum getLogoutMethod() { + return logoutMethod; + } + + public void setLogoutMethod(LOGOUTMETHODEnum logoutMethod) { + this.logoutMethod = logoutMethod; + } + + /** + * + **/ + public SingleLogoutProfile idpInitiatedSingleLogout(IdpInitiatedSingleLogout idpInitiatedSingleLogout) { + + this.idpInitiatedSingleLogout = idpInitiatedSingleLogout; + return this; + } + + @ApiModelProperty() + @JsonProperty("idpInitiatedSingleLogout") + @Valid + public IdpInitiatedSingleLogout getIdpInitiatedSingleLogout() { + return idpInitiatedSingleLogout; + } + + public void setIdpInitiatedSingleLogout(IdpInitiatedSingleLogout idpInitiatedSingleLogout) { + this.idpInitiatedSingleLogout = idpInitiatedSingleLogout; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SingleLogoutProfile singleLogoutProfile = (SingleLogoutProfile) o; + return Objects.equals(this.enabled, singleLogoutProfile.enabled) && + Objects.equals(this.logoutRequestUrl, singleLogoutProfile.logoutRequestUrl) && + Objects.equals(this.logoutResponseUrl, singleLogoutProfile.logoutResponseUrl) && + Objects.equals(this.logoutMethod, singleLogoutProfile.logoutMethod) && + Objects.equals(this.idpInitiatedSingleLogout, singleLogoutProfile.idpInitiatedSingleLogout); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, logoutRequestUrl, logoutResponseUrl, logoutMethod, idpInitiatedSingleLogout); + } + + @Override + public String toString() { + + return "class SingleLogoutProfile {\n" + + " enabled: " + toIndentedString(enabled) + "\n" + + " logoutRequestUrl: " + toIndentedString(logoutRequestUrl) + "\n" + + " logoutResponseUrl: " + toIndentedString(logoutResponseUrl) + "\n" + + " logoutMethod: " + toIndentedString(logoutMethod) + "\n" + + " idpInitiatedSingleLogout: " + toIndentedString(idpInitiatedSingleLogout) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SingleSignOnProfile.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SingleSignOnProfile.java new file mode 100644 index 0000000000..d8751c921e --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SingleSignOnProfile.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class SingleSignOnProfile { + + @XmlType(name="BINDINGSEnum") + @XmlEnum() + public enum BINDINGSEnum { + + @XmlEnumValue("HTTP_POST") HTTP_POST("HTTP_POST"), + @XmlEnumValue("HTTP_REDIRECT") HTTP_REDIRECT("HTTP_REDIRECT"), + @XmlEnumValue("ARTIFACT") ARTIFACT("ARTIFACT"); + + private final String value; + + BINDINGSEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static BINDINGSEnum fromValue(String value) { + for (BINDINGSEnum b : BINDINGSEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private List bindings; + private Boolean enableSignatureValidationForArtifactBinding = false; + private String attributeConsumingServiceIndex; + private Boolean enableIdpInitiatedSingleSignOn = false; + private SAMLAssertionConfiguration assertion; + + /** + **/ + public SingleSignOnProfile bindings(List bindings) { + + this.bindings = bindings; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("bindings") + @Valid + public List getBindings() { + return bindings; + } + public void setBindings(List bindings) { + this.bindings = bindings; + } + + public SingleSignOnProfile addBindingsItem(BINDINGSEnum bindingsItem) { + if (this.bindings == null) { + this.bindings = new ArrayList<>(); + } + this.bindings.add(bindingsItem); + return this; + } + + /** + * + **/ + public SingleSignOnProfile enableSignatureValidationForArtifactBinding(Boolean + enableSignatureValidationForArtifactBinding) { + + this.enableSignatureValidationForArtifactBinding = enableSignatureValidationForArtifactBinding; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enableSignatureValidationForArtifactBinding") + @Valid + public Boolean getEnableSignatureValidationForArtifactBinding() { + return enableSignatureValidationForArtifactBinding; + } + + public void setEnableSignatureValidationForArtifactBinding(Boolean enableSignatureValidationForArtifactBinding) { + this.enableSignatureValidationForArtifactBinding = enableSignatureValidationForArtifactBinding; + } + + /** + * + **/ + public SingleSignOnProfile attributeConsumingServiceIndex(String attributeConsumingServiceIndex) { + + this.attributeConsumingServiceIndex = attributeConsumingServiceIndex; + return this; + } + + @ApiModelProperty() + @JsonProperty("attributeConsumingServiceIndex") + @Valid + public String getAttributeConsumingServiceIndex() { + return attributeConsumingServiceIndex; + } + + public void setAttributeConsumingServiceIndex(String attributeConsumingServiceIndex) { + this.attributeConsumingServiceIndex = attributeConsumingServiceIndex; + } + + /** + * + **/ + public SingleSignOnProfile enableIdpInitiatedSingleSignOn(Boolean enableIdpInitiatedSingleSignOn) { + + this.enableIdpInitiatedSingleSignOn = enableIdpInitiatedSingleSignOn; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("enableIdpInitiatedSingleSignOn") + @Valid + public Boolean getEnableIdpInitiatedSingleSignOn() { + return enableIdpInitiatedSingleSignOn; + } + + public void setEnableIdpInitiatedSingleSignOn(Boolean enableIdpInitiatedSingleSignOn) { + this.enableIdpInitiatedSingleSignOn = enableIdpInitiatedSingleSignOn; + } + + + /** + * + **/ + public SingleSignOnProfile assertion(SAMLAssertionConfiguration assertion) { + + this.assertion = assertion; + return this; + } + + @ApiModelProperty() + @JsonProperty("assertion") + @Valid + public SAMLAssertionConfiguration getAssertion() { + return assertion; + } + + public void setAssertion(SAMLAssertionConfiguration assertion) { + this.assertion = assertion; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SingleSignOnProfile singleSignOnProfile = (SingleSignOnProfile) o; + return Objects.equals(this.bindings, singleSignOnProfile.bindings) && + Objects.equals(this.enableSignatureValidationForArtifactBinding, + singleSignOnProfile.enableSignatureValidationForArtifactBinding) && + Objects.equals(this.attributeConsumingServiceIndex, + singleSignOnProfile.attributeConsumingServiceIndex) && + Objects.equals(this.enableIdpInitiatedSingleSignOn, + singleSignOnProfile.enableIdpInitiatedSingleSignOn) && + Objects.equals(this.assertion, singleSignOnProfile.assertion); + } + + @Override + public int hashCode() { + return Objects.hash(bindings, enableSignatureValidationForArtifactBinding, attributeConsumingServiceIndex, + enableIdpInitiatedSingleSignOn, assertion); + } + + @Override + public String toString() { + + return "class SingleSignOnProfile {\n" + + " bindings: " + toIndentedString(bindings) + "\n" + + " enableSignatureValidationForArtifactBinding: " + + toIndentedString(enableSignatureValidationForArtifactBinding) + "\n" + + " attributeConsumingServiceIndex: " + toIndentedString(attributeConsumingServiceIndex) + "\n" + + " enableIdpInitiatedSingleSignOn: " + toIndentedString(enableIdpInitiatedSingleSignOn) + "\n" + + " assertion: " + toIndentedString(assertion) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SubjectConfig.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SubjectConfig.java index da9483f905..6fb7dfd182 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SubjectConfig.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/SubjectConfig.java @@ -1,18 +1,20 @@ /* -* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2019, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.wso2.identity.integration.test.rest.api.server.application.management.v1.model; @@ -24,27 +26,27 @@ public class SubjectConfig { - private String claimId; + private Claim claim; private Boolean includeUserDomain; private Boolean includeTenantDomain; private Boolean useMappedLocalSubject; /** **/ - public SubjectConfig claimId(String claimId) { + public SubjectConfig claim(Claim claim) { - this.claimId = claimId; + this.claim = claim; return this; } @ApiModelProperty(example = "http://wso2.org/claims/emailaddress", value = "") - @JsonProperty("claimId") + @JsonProperty("claim") @Valid - public String getClaimId() { - return claimId; + public Claim getClaim() { + return claim; } - public void setClaimId(String claimId) { - this.claimId = claimId; + public void setClaim(Claim claim) { + this.claim = claim; } /** @@ -113,7 +115,7 @@ public boolean equals(Object o) { return false; } SubjectConfig subjectConfig = (SubjectConfig) o; - return Objects.equals(this.claimId, subjectConfig.claimId) && + return Objects.equals(this.claim, subjectConfig.claim) && Objects.equals(this.includeUserDomain, subjectConfig.includeUserDomain) && Objects.equals(this.includeTenantDomain, subjectConfig.includeTenantDomain) && Objects.equals(this.useMappedLocalSubject, subjectConfig.useMappedLocalSubject); @@ -121,7 +123,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(claimId, includeUserDomain, includeTenantDomain, useMappedLocalSubject); + return Objects.hash(claim, includeUserDomain, includeTenantDomain, useMappedLocalSubject); } @Override @@ -130,7 +132,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class SubjectConfig {\n"); - sb.append(" claimId: ").append(toIndentedString(claimId)).append("\n"); + sb.append(" claimId: ").append(toIndentedString(claim)).append("\n"); sb.append(" includeUserDomain: ").append(toIndentedString(includeUserDomain)).append("\n"); sb.append(" includeTenantDomain: ").append(toIndentedString(includeTenantDomain)).append("\n"); sb.append(" useMappedLocalSubject: ").append(toIndentedString(useMappedLocalSubject)).append("\n"); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/AuthenticationRequest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/AuthenticationRequest.java new file mode 100644 index 0000000000..cf0291c7fa --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/AuthenticationRequest.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class AuthenticationRequest { + + private String username; + private String password; + + /** + * + **/ + public AuthenticationRequest username(String username) { + + this.username = username; + return this; + } + + @ApiModelProperty(example = "Ashan") + @JsonProperty("username") + @Valid + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + /** + * + **/ + public AuthenticationRequest password(String password) { + + this.password = password; + return this; + } + + @ApiModelProperty(example = "Zoyza") + @JsonProperty("password") + @Valid + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthenticationRequest AuthenticationRequest = (AuthenticationRequest) o; + return Objects.equals(this.username, AuthenticationRequest.username) && + Objects.equals(this.password, AuthenticationRequest.password); + } + + @Override + public int hashCode() { + return Objects.hash(username, password); + } + + @Override + public String toString() { + + return "class AuthenticationRequest {\n" + + " username: " + toIndentedString(username) + "\n" + + " password: " + toIndentedString(password) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Email.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Email.java new file mode 100644 index 0000000000..1e042c5c83 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Email.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class Email { + + private String type; + private String value; + private Boolean primary; + + /** + * + **/ + public Email type(String type) { + + this.type = type; + return this; + } + + @ApiModelProperty(example = "work") + @JsonProperty("type") + @Valid + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * + **/ + public Email value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "abc@wso2.com") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + /** + * + **/ + public Email primary(Boolean primary) { + + this.primary = primary; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("primary") + @Valid + public Boolean getPrimary() { + return primary; + } + + public void setPrimary(Boolean primary) { + this.primary = primary; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Email email = (Email) o; + return Objects.equals(this.type, email.type) && + Objects.equals(this.value, email.value) && + Objects.equals(this.primary, email.primary); + } + + @Override + public int hashCode() { + return Objects.hash(type, value, primary); + } + + @Override + public String toString() { + + return "class Email {\n" + + " type: " + toIndentedString(type) + "\n" + + " value: " + toIndentedString(value) + "\n" + + " primary: " + toIndentedString(primary) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/ListObject.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/ListObject.java new file mode 100644 index 0000000000..ebcced2f4f --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/ListObject.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class ListObject { + + private String display; + private String value; + private String $ref; + + /** + * + **/ + public ListObject display(String display) { + + this.display = display; + return this; + } + + @ApiModelProperty(example = "abc") + @JsonProperty("display") + @Valid + public String getDisplay() { + return display; + } + + public void setDisplay(String display) { + this.display = display; + } + + /** + * + **/ + public ListObject value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "csdhfkjcdoqfo[adpscbdsjk]") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + /** + * + **/ + public ListObject $ref(String $ref) { + + this.$ref = $ref; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("$ref") + @Valid + public String getRef() { + return $ref; + } + + public void setRef(String $ref) { + this.$ref = $ref; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListObject listObj = (ListObject) o; + return Objects.equals(this.display, listObj.display) && + Objects.equals(this.value, listObj.value) && + Objects.equals(this.$ref, listObj.$ref); + } + + @Override + public int hashCode() { + return Objects.hash(display, value, $ref); + } + + @Override + public String toString() { + + return "class ListObject {\n" + + " display: " + toIndentedString(display) + "\n" + + " value: " + toIndentedString(value) + "\n" + + " $ref: " + toIndentedString($ref) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Manager.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Manager.java new file mode 100644 index 0000000000..c67d90c770 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Manager.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class Manager { + + private String value; + + /** + * + **/ + public Manager value(String value) { + + this.value = value; + return this; + } + + @ApiModelProperty(example = "abc@wso2.com") + @JsonProperty("value") + @Valid + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Manager manager = (Manager) o; + return Objects.equals(this.value, manager.value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + + return "class Manager {\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Name.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Name.java new file mode 100644 index 0000000000..148ec32dd3 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/Name.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class Name { + + private String givenName; + private String familyName; + + /** + * + **/ + public Name givenName(String givenName) { + + this.givenName = givenName; + return this; + } + + @ApiModelProperty(example = "Ashan") + @JsonProperty("givenName") + @Valid + public String getGivenName() { + return givenName; + } + + public void setGivenName(String givenName) { + this.givenName = givenName; + } + + /** + * + **/ + public Name familyName(String familyName) { + + this.familyName = familyName; + return this; + } + + @ApiModelProperty(example = "Zoyza") + @JsonProperty("familyName") + @Valid + public String getFamilyName() { + return familyName; + } + + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(this.givenName, name.givenName) && + Objects.equals(this.familyName, name.familyName); + } + + @Override + public int hashCode() { + return Objects.hash(givenName, familyName); + } + + @Override + public String toString() { + + return "class Name {\n" + + " givenName: " + toIndentedString(givenName) + "\n" + + " familyName: " + toIndentedString(familyName) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} \ No newline at end of file diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/PatchOperationRequestObject.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/PatchOperationRequestObject.java new file mode 100644 index 0000000000..5c8bb5a959 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/PatchOperationRequestObject.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import javax.validation.Valid; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +public class PatchOperationRequestObject { + + private List schemas = null; + private List Operations = null; + + /** + * + **/ + public PatchOperationRequestObject schemas(List schemas) { + + this.schemas = schemas; + return this; + } + + @ApiModelProperty() + @JsonProperty("schemas") + @Valid + public List getSchemas() { + return schemas; + } + + public void setSchemas(List schemas) { + this.schemas = schemas; + } + + /** + * + **/ + public PatchOperationRequestObject Operations(List Operations) { + + this.Operations = Operations; + return this; + } + + @ApiModelProperty() + @JsonProperty("Operations") + @Valid + public List getOperations() { + return Operations; + } + + public void setOperations(List Operations) { + this.Operations = Operations; + } + + public PatchOperationRequestObject addOperations(Object Operation) { + if (this.Operations == null) { + this.Operations = new ArrayList<>(); + } + this.Operations.add(Operation); + return this; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatchOperationRequestObject user = (PatchOperationRequestObject) o; + return Objects.equals(this.schemas, user.schemas) && + Objects.equals(this.Operations, user.Operations); + + } + + @Override + public int hashCode() { + return Objects.hash(schemas, Operations); + } + + @Override + public String toString() { + + return "class PatchRoleOperationRequestObject {\n" + + " schemas: " + toIndentedString(schemas) + "\n" + + " Operations: " + toIndentedString(Operations) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleItemAddGroupobj.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleItemAddGroupobj.java new file mode 100644 index 0000000000..c6e7f068c9 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleItemAddGroupobj.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class RoleItemAddGroupobj { + + + @XmlType(name="OpEnum") + @XmlEnum() + public enum OpEnum { + + @XmlEnumValue("add") ADD("add"), @XmlEnumValue("remove") REMOVE("remove"), @XmlEnumValue("replace") REPLACE("replace"); + + + private String value; + + OpEnum(String val) { + value = val; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RoleItemAddGroupobj.OpEnum fromValue(String value) { + for (RoleItemAddGroupobj.OpEnum op : RoleItemAddGroupobj.OpEnum.values()) { + if (op.value.equals(value)) { + return op; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private OpEnum op = null; + private String path; + private List value = null; + + /** + **/ + public RoleItemAddGroupobj op(RoleItemAddGroupobj.OpEnum op) { + + this.op = op; + return this; + } + + @ApiModelProperty() + @JsonProperty("op") + @Valid + public RoleItemAddGroupobj.OpEnum getOp() { + return op; + } + public void setOp(RoleItemAddGroupobj.OpEnum op) { + this.op = op; + } + + /** + * + **/ + public RoleItemAddGroupobj path(String path) { + + this.path = path; + return this; + } + + @ApiModelProperty(example = "users") + @JsonProperty("path") + @Valid + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + /** + * + **/ + public RoleItemAddGroupobj value(List value) { + + this.value = value; + return this; + } + + @ApiModelProperty() + @JsonProperty("value") + @Valid + public List getValue() { + return value; + } + + public void setValue(List value) { + this.value = value; + } + + public RoleItemAddGroupobj addValue(ListObject value) { + if (this.value == null) { + this.value = new ArrayList<>(); + } + this.value.add(value); + return this; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleItemAddGroupobj roleItemAddGroupobj = (RoleItemAddGroupobj) o; + return Objects.equals(this.op, roleItemAddGroupobj.op) && + Objects.equals(this.path, roleItemAddGroupobj.path) && + Objects.equals(this.value, roleItemAddGroupobj.value); + } + + @Override + public int hashCode() { + return Objects.hash(op, path, value); + } + + @Override + public String toString() { + + return "class RoleItemAddGroupobj {\n" + + " op: " + toIndentedString(op) + "\n" + + " path: " + toIndentedString(path) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleRequestObject.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleRequestObject.java new file mode 100644 index 0000000000..619149828d --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleRequestObject.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class RoleRequestObject { + + private List schemas = null; + private String displayName; + private List users = null; + private List groups = null; + private List permissions = null; + + /** + * + **/ + public RoleRequestObject schemas(List schemas) { + + this.schemas = schemas; + return this; + } + + @ApiModelProperty() + @JsonProperty("schemas") + @Valid + public List getSchemas() { + return schemas; + } + + public void setSchemas(List schemas) { + this.schemas = schemas; + } + + public RoleRequestObject addSchemas(String schema) { + if (this.schemas == null) { + this.schemas = new ArrayList<>(); + } + this.schemas.add(schema); + return this; + } + + /** + * + **/ + public RoleRequestObject displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "abc") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * + **/ + public RoleRequestObject users(List users) { + + this.users = users; + return this; + } + + @ApiModelProperty() + @JsonProperty("users") + @Valid + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + + public RoleRequestObject addUsers(ListObject user) { + if (this.users == null) { + this.users = new ArrayList<>(); + } + this.users.add(user); + return this; + } + + /** + * + **/ + public RoleRequestObject groups(List groups) { + + this.groups = groups; + return this; + } + + @ApiModelProperty() + @JsonProperty("groups") + @Valid + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public RoleRequestObject addGroups(ListObject group) { + if (this.groups == null) { + this.groups = new ArrayList<>(); + } + this.groups.add(group); + return this; + } + + /** + * + **/ + public RoleRequestObject permissions(List permissions) { + + this.permissions = permissions; + return this; + } + + @ApiModelProperty() + @JsonProperty("permissions") + @Valid + public List getPermissions() { + return permissions; + } + + public void setPermissions(List permissions) { + this.permissions = permissions; + } + + public RoleRequestObject addPermissions(String permission) { + if (this.permissions == null) { + this.permissions = new ArrayList<>(); + } + this.permissions.add(permission); + return this; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleRequestObject roleRequestObject = (RoleRequestObject) o; + return Objects.equals(this.schemas, roleRequestObject.schemas) && + Objects.equals(this.displayName, roleRequestObject.displayName) && + Objects.equals(this.users, roleRequestObject.users) && + Objects.equals(this.groups, roleRequestObject.groups) && + Objects.equals(this.permissions, roleRequestObject.permissions); + } + + @Override + public int hashCode() { + return Objects.hash(schemas, displayName, users, groups, permissions); + } + + @Override + public String toString() { + + return "class RoleRequestObject {\n" + + " schemas: " + toIndentedString(schemas) + "\n" + + " displayName: " + toIndentedString(displayName) + "\n" + + " users: " + toIndentedString(users) + "\n" + + " groups: " + toIndentedString(groups) + "\n" + + " permissions: " + toIndentedString(permissions) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleSearchRequestObject.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleSearchRequestObject.java new file mode 100644 index 0000000000..1d3a9280f1 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/RoleSearchRequestObject.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class RoleSearchRequestObject { + + private List schemas = null; + + private Integer startIndex; + private Integer count; + private String filter; + + /** + * + **/ + public RoleSearchRequestObject schemas(List schemas) { + + this.schemas = schemas; + return this; + } + + @ApiModelProperty() + @JsonProperty("schemas") + @Valid + public List getSchemas() { + return schemas; + } + + public void setSchemas(List schemas) { + this.schemas = schemas; + } + + public RoleSearchRequestObject addSchemas(String schema) { + if (this.schemas == null) { + this.schemas = new ArrayList<>(); + } + this.schemas.add(schema); + return this; + } + + /** + * + **/ + public RoleSearchRequestObject startIndex(Integer startIndex) { + + this.startIndex = startIndex; + return this; + } + + @ApiModelProperty() + @JsonProperty("startIndex") + @Valid + public Integer getStartIndex() { + return startIndex; + } + + public void setStartIndex(Integer startIndex) { + this.startIndex = startIndex; + } + + /** + * + **/ + public RoleSearchRequestObject count(Integer count) { + + this.count = count; + return this; + } + + @ApiModelProperty() + @JsonProperty("count") + @Valid + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + /** + * + **/ + public RoleSearchRequestObject filter(String filter) { + + this.filter = filter; + return this; + } + + @ApiModelProperty(example = "abc") + @JsonProperty("filter") + @Valid + public String getFilter() { + return filter; + } + + public void setFilter(String filter) { + this.filter = filter; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoleSearchRequestObject RoleSearchRequestObject = (RoleSearchRequestObject) o; + return Objects.equals(this.schemas, RoleSearchRequestObject.schemas) && + Objects.equals(this.filter, RoleSearchRequestObject.filter) && + Objects.equals(this.startIndex, RoleSearchRequestObject.startIndex) && + Objects.equals(this.count, RoleSearchRequestObject.count); + } + + @Override + public int hashCode() { + return Objects.hash(schemas, startIndex, count, filter); + } + + @Override + public String toString() { + + return "class RoleSearchRequestObject {\n" + + " schemas: " + toIndentedString(schemas) + "\n" + + " startIndex: " + toIndentedString(startIndex) + "\n" + + " count: " + toIndentedString(count) + "\n" + + " filter: " + toIndentedString(filter) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/ScimSchemaExtensionEnterprise.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/ScimSchemaExtensionEnterprise.java new file mode 100644 index 0000000000..de44c56dc1 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/ScimSchemaExtensionEnterprise.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.Objects; + +public class ScimSchemaExtensionEnterprise { + private Manager manager; + private String employeeNumber; + private Boolean accountLocked; + + /** + * + **/ + public ScimSchemaExtensionEnterprise manager(Manager manager) { + + this.manager = manager; + return this; + } + + @ApiModelProperty() + @JsonProperty("manager") + @Valid + public Manager getManager() { + return manager; + } + + public void setManager(Manager manager) { + this.manager = manager; + } + + /** + * + **/ + public ScimSchemaExtensionEnterprise employeeNumber(String employeeNumber) { + + this.employeeNumber = employeeNumber; + return this; + } + + @ApiModelProperty(example = "1234A") + @JsonProperty("employeeNumber") + @Valid + public String getEmployeeNumber() { + return employeeNumber; + } + + public void setEmployeeNumber(String employeeNumber) { + this.employeeNumber = employeeNumber; + } + + /** + * + **/ + public ScimSchemaExtensionEnterprise accountLocked(Boolean accountLocked) { + + this.accountLocked = accountLocked; + return this; + } + + @ApiModelProperty(example = "false") + @JsonProperty("accountLocked") + @Valid + public Boolean accountLocked() { + return accountLocked; + } + + public void setAccountLocked(Boolean accountLocked) { + this.accountLocked = accountLocked; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScimSchemaExtensionEnterprise scimSchemaExtensionEnterprise = (ScimSchemaExtensionEnterprise) o; + return Objects.equals(this.manager, scimSchemaExtensionEnterprise.manager) && + Objects.equals(this.employeeNumber, scimSchemaExtensionEnterprise.employeeNumber) && + Objects.equals(this.accountLocked, scimSchemaExtensionEnterprise.accountLocked); + } + + @Override + public int hashCode() { + return Objects.hash(manager, employeeNumber, accountLocked); + } + + @Override + public String toString() { + + return "class ScimSchemaExtensionEnterprise {\n" + + " manager: " + toIndentedString(manager) + "\n" + + " employeeNumber: " + toIndentedString(employeeNumber) + "\n" + + " accountLocked: " + toIndentedString(accountLocked) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/UserItemAddGroupobj.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/UserItemAddGroupobj.java new file mode 100644 index 0000000000..0e908e43d7 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/UserItemAddGroupobj.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; +import java.util.Objects; + +public class UserItemAddGroupobj { + + + @XmlType(name="OpEnum") + @XmlEnum() + public enum OpEnum { + + @XmlEnumValue("add") ADD("add"), @XmlEnumValue("remove") REMOVE("remove"), @XmlEnumValue("replace") REPLACE("replace"); + + + private String value; + + OpEnum(String val) { + value = val; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OpEnum fromValue(String value) { + for (OpEnum op : OpEnum.values()) { + if (op.value.equals(value)) { + return op; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private OpEnum op = null; + private String path; + private Boolean value = null; + + /** + **/ + public UserItemAddGroupobj op(OpEnum op) { + + this.op = op; + return this; + } + + @ApiModelProperty() + @JsonProperty("op") + @Valid + public OpEnum getOp() { + return op; + } + public void setOp(OpEnum op) { + this.op = op; + } + + /** + * + **/ + public UserItemAddGroupobj path(String path) { + + this.path = path; + return this; + } + + @ApiModelProperty(example = "users") + @JsonProperty("path") + @Valid + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + /** + * + **/ + public UserItemAddGroupobj value(Boolean value) { + + this.value = value; + return this; + } + + @ApiModelProperty() + @JsonProperty("value") + @Valid + public Boolean getValue() { + return value; + } + + public void setValue(Boolean value) { + this.value = value; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserItemAddGroupobj roleItemAddGroupobj = (UserItemAddGroupobj) o; + return Objects.equals(this.op, roleItemAddGroupobj.op) && + Objects.equals(this.path, roleItemAddGroupobj.path) && + Objects.equals(this.value, roleItemAddGroupobj.value); + } + + @Override + public int hashCode() { + return Objects.hash(op, path, value); + } + + @Override + public String toString() { + + return "class RoleItemAddGroupobj {\n" + + " op: " + toIndentedString(op) + "\n" + + " path: " + toIndentedString(path) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/UserObject.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/UserObject.java new file mode 100644 index 0000000000..843e136e13 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/common/model/UserObject.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.rest.api.user.common.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class UserObject { + + private List schemas = null; + private Name name; + private String userName; + private String password; + private List emails = null; + private String locale; + private ScimSchemaExtensionEnterprise scimSchemaExtensionEnterprise; + + /** + * + **/ + public UserObject schemas(List schemas) { + + this.schemas = schemas; + return this; + } + + @ApiModelProperty() + @JsonProperty("schemas") + @Valid + public List getSchemas() { + return schemas; + } + + public void setSchemas(List schemas) { + this.schemas = schemas; + } + + /** + * + **/ + public UserObject name(Name name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "ashan") + @JsonProperty("name") + @Valid + public Name getName() { + return name; + } + + public void setName(Name name) { + this.name = name; + } + + /** + * + **/ + public UserObject userName(String userName) { + + this.userName = userName; + return this; + } + + @ApiModelProperty(example = "abc@wso2.com") + @JsonProperty("userName") + @Valid + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * + **/ + public UserObject password(String password) { + + this.password = password; + return this; + } + + @ApiModelProperty(example = "abc123") + @JsonProperty("password") + @Valid + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + /** + * + **/ + public UserObject emails(List emails) { + + this.emails = emails; + return this; + } + + @ApiModelProperty() + @JsonProperty("emails") + @Valid + public List getEmails() { + return emails; + } + + public void setEmails(List emails) { + this.emails = emails; + } + + public UserObject addEmail(Email email) { + if (this.emails == null) { + this.emails = new ArrayList<>(); + } + this.emails.add(email); + return this; + } + + /** + * + **/ + public UserObject locale(String locale) { + + this.locale = locale; + return this; + } + + @ApiModelProperty(example = "en_US") + @JsonProperty("locale") + @Valid + public String getLocale() { + return locale; + } + + public void setLocale(String locale) { + this.locale = locale; + } + + /** + * + **/ + public UserObject scimSchemaExtensionEnterprise(ScimSchemaExtensionEnterprise scimSchemaExtensionEnterprise) { + + this.scimSchemaExtensionEnterprise = scimSchemaExtensionEnterprise; + return this; + } + + @ApiModelProperty() + @JsonProperty("urn:ietf:params:scim:schemas:extension:enterprise:2.0:User") + @Valid + public ScimSchemaExtensionEnterprise getScimSchemaExtensionEnterprise() { + return scimSchemaExtensionEnterprise; + } + + public void setScimSchemaExtensionEnterprise(ScimSchemaExtensionEnterprise scimSchemaExtensionEnterprise) { + this.scimSchemaExtensionEnterprise = scimSchemaExtensionEnterprise; + } + + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserObject user = (UserObject) o; + return Objects.equals(this.schemas, user.schemas) && + Objects.equals(this.name, user.name) && + Objects.equals(this.userName, user.userName) && + Objects.equals(this.password, user.password) && + Objects.equals(this.emails, user.emails) && + Objects.equals(this.locale, user.locale) && + Objects.equals(this.scimSchemaExtensionEnterprise, user.scimSchemaExtensionEnterprise); + + } + + @Override + public int hashCode() { + return Objects.hash(schemas, name, userName, password, emails, locale, scimSchemaExtensionEnterprise); + } + + @Override + public String toString() { + + return "class UserObject {\n" + + " schemas: " + toIndentedString(schemas) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " userName: " + toIndentedString(userName) + "\n" + + " password: " + toIndentedString(password) + "\n" + + " emails: " + toIndentedString(emails) + "\n" + + " locale: " + toIndentedString(locale) + "\n" + + " urn:ietf:params:scim:schemas:extension:enterprise:2.0:User: " + toIndentedString(scimSchemaExtensionEnterprise) + "\n" + + "}"; + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/AuthenticatorRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/AuthenticatorRestClient.java new file mode 100644 index 0000000000..8ac55223c0 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/AuthenticatorRestClient.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.identity.integration.test.restclients; + +import io.restassured.http.ContentType; +import org.apache.http.Header; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.message.BasicHeader; +import org.apache.http.util.EntityUtils; +import org.json.simple.JSONObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.AuthenticationRequest; + +import java.io.IOException; + +public class AuthenticatorRestClient extends RestBaseClient { + + private final String serverUrl; + private final String AUTHENTICATION_BASE_PATH = "api/identity/auth/v1.1/authenticate"; + + public AuthenticatorRestClient(String serverUrl) { + + this.serverUrl = serverUrl; + } + + /** + * Login operation + * + * @param username username. + * @param password password. + * @return JSONObject with login details. + */ + public JSONObject login(String username, String password) throws Exception { + + AuthenticationRequest loginRequest = new AuthenticationRequest(); + loginRequest.setUsername(username); + loginRequest.setPassword(password); + + String jsonRequest = toJSONString(loginRequest); + String endPointUrl = serverUrl + AUTHENTICATION_BASE_PATH; + + try (CloseableHttpResponse response = getResponseOfHttpPost(endPointUrl, jsonRequest, getHeaders())) { + return getJSONObject(EntityUtils.toString(response.getEntity())); + } + } + + private Header[] getHeaders() { + return new Header[]{new BasicHeader(CONTENT_TYPE_ATTRIBUTE, String.valueOf(ContentType.JSON))}; + } + + /** + * Close the HTTP client. + * + */ + public void closeHttpClient() throws IOException { + client.close(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/EmailTemplatesRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/EmailTemplatesRestClient.java index b62416ac8a..0aed93b7d6 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/EmailTemplatesRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/EmailTemplatesRestClient.java @@ -31,17 +31,13 @@ import org.wso2.carbon.automation.engine.context.beans.Tenant; import java.io.IOException; -public class EmailTemplatesRestClient { +public class EmailTemplatesRestClient extends RestBaseClient { private static final String TENANT_PATH = "t/%s"; private static final String API_SERVER_BASE_PATH = "/api/server/v1"; private static final String EMAIL_TEMPLATES_EMAIL_BASE_PATH = "/email"; private static final String EMAIL_TEMPLATE_TYPES_PATH = "/template-types"; private static final String EMAIL_TEMPLATES_PATH = "/templates"; - private static final String PATH_SEPARATOR = "/"; - public static final String BASIC_AUTHORIZATION_ATTRIBUTE = "Basic "; - public static final String CONTENT_TYPE_ATTRIBUTE = "Content-Type"; - public static final String AUTHORIZATION_ATTRIBUTE = "Authorization"; private final String emailTemplateApiBasePath; private final CloseableHttpClient client; private final String username; @@ -59,23 +55,21 @@ public EmailTemplatesRestClient(String backendURL, Tenant tenantInfo) { EMAIL_TEMPLATES_EMAIL_BASE_PATH + EMAIL_TEMPLATE_TYPES_PATH; } + /** + * Get Email template + * + * @param templateTypeId Template type id. + * @param templateId Template id. + * @return JSONObject with email template details. + */ public JSONObject getEmailTemplate(String templateTypeId, String templateId) throws Exception { String endPointUrl = emailTemplateApiBasePath + PATH_SEPARATOR + getEncodedEmailTemplateTypeId(templateTypeId) + EMAIL_TEMPLATES_PATH + PATH_SEPARATOR + templateId; - CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl); - - String responseBody = EntityUtils.toString(response.getEntity()); - response.close(); - - return getJSONObject(responseBody); - } - - private CloseableHttpResponse getResponseOfHttpGet(String endPointUrl) throws IOException { - HttpGet request = new HttpGet(endPointUrl); - request.setHeaders(getHeaders()); - - return client.execute(request); + try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { + String responseBody = EntityUtils.toString(response.getEntity()); + return getJSONObject(responseBody); + } } private Header[] getHeaders() { @@ -91,17 +85,10 @@ private String getEncodedEmailTemplateTypeId(String emailTemplateTypeId) { return Base64.encodeBase64String(emailTemplateTypeId.getBytes()); } - private JSONObject getJSONObject(String responseString) throws Exception { - JSONParser parser = new JSONParser(); - JSONObject json = (JSONObject) parser.parse(responseString); - if (json == null) { - throw new Exception( - "Error occurred while getting the response"); - } - - return json; - } - + /** + * Close the HTTP client. + * + */ public void closeHttpClient() throws IOException { client.close(); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdentityGovernanceRestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdentityGovernanceRestClient.java index 63a21a7fac..5fb80aad37 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdentityGovernanceRestClient.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/IdentityGovernanceRestClient.java @@ -35,16 +35,12 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; -public class IdentityGovernanceRestClient { +public class IdentityGovernanceRestClient extends RestBaseClient { private static final String TENANT_PATH = "t/%s"; private static final String API_SERVER_BASE_PATH = "/api/server/v1"; private static final String IDENTITY_GOVERNANCE_BASE_PATH = "/identity-governance"; private static final String CONNECTORS_BASE_PATH = "/connectors"; - private static final String PATH_SEPARATOR = "/"; - private static final String BASIC_AUTHORIZATION_ATTRIBUTE = "Basic "; - private static final String CONTENT_TYPE_ATTRIBUTE = "Content-Type"; - private static final String AUTHORIZATION_ATTRIBUTE = "Authorization"; private final String identityGovernanceApiBasePath; private final CloseableHttpClient client; private final String username; @@ -62,32 +58,23 @@ public IdentityGovernanceRestClient(String backendURL, Tenant tenantInfo) { IDENTITY_GOVERNANCE_BASE_PATH; } + /** + * Update connector properties + * + * @param categoryId Connector category id. + * @param connectorId Connector id. + * @param connectorPatch Connector patch request object. + */ public void updateConnectors(String categoryId, String connectorId, ConnectorsPatchReq connectorPatch) throws IOException { String jsonRequest = toJSONString(connectorPatch); String endPointUrl = identityGovernanceApiBasePath + PATH_SEPARATOR + categoryId + CONNECTORS_BASE_PATH + PATH_SEPARATOR + connectorId; - CloseableHttpResponse response = getResponseOfHttpPatch(endPointUrl, jsonRequest); - - Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, - "Connector update failed"); - response.close(); - } - - private String toJSONString(java.lang.Object object) { - - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - return gson.toJson(object); - } - - private CloseableHttpResponse getResponseOfHttpPatch(String endPointUrl, String jsonRequest) throws IOException { - - HttpPatch request = new HttpPatch(endPointUrl); - request.setHeaders(getHeaders()); - request.setEntity(new StringEntity(jsonRequest)); - - return client.execute(request); + try (CloseableHttpResponse response = getResponseOfHttpPatch(endPointUrl, jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + "Connector update failed"); + } } private Header[] getHeaders() { @@ -100,6 +87,10 @@ private Header[] getHeaders() { return headerList; } + /** + * Close the HTTP client. + * + */ public void closeHttpClient() throws IOException { client.close(); } diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java new file mode 100644 index 0000000000..759b9857e9 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/OAuth2RestClient.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.identity.integration.test.restclients; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.restassured.http.ContentType; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.Header; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.message.BasicHeader; +import org.apache.http.util.EntityUtils; +import org.json.JSONException; +import org.testng.Assert; +import org.wso2.carbon.automation.engine.context.beans.Tenant; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationListResponse; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationPatchModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.SAML2ServiceProvider; +import org.wso2.identity.integration.test.utils.OAuth2Constant; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class OAuth2RestClient extends RestBaseClient { + + private static final String API_SERVER_BASE_PATH = "api/server/v1"; + private static final String APPLICATION_MANAGEMENT_PATH = "/applications"; + private static final String INBOUND_PROTOCOLS_BASE_PATH = "/inbound-protocols"; + private final String applicationManagementApiBasePath; + private final String username; + private final String password; + + public OAuth2RestClient(String backendUrl, Tenant tenantInfo) { + this.username = tenantInfo.getContextUser().getUserName(); + this.password = tenantInfo.getContextUser().getPassword(); + + String tenantDomain = tenantInfo.getContextUser().getUserDomain(); + applicationManagementApiBasePath = getApplicationsPath(backendUrl, tenantDomain); + } + + /** + * Create an Application + * + * @param application Application Model with application creation details. + * @return Id of the created application. + */ + public String createApplication(ApplicationModel application) throws IOException, JSONException { + String jsonRequest = toJSONString(application); + + try (CloseableHttpResponse response = getResponseOfHttpPost(applicationManagementApiBasePath, jsonRequest, + getHeaders())) { + String[] locationElements = response.getHeaders(LOCATION_HEADER)[0].toString().split(PATH_SEPARATOR); + return locationElements[locationElements.length - 1]; + } + } + + /** + * Get Application details + * + * @param appId Application id. + * @return ApplicationResponseModel object. + */ + public ApplicationResponseModel getApplication(String appId) throws IOException { + String endPointUrl = applicationManagementApiBasePath + PATH_SEPARATOR + appId; + + try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { + String responseBody = EntityUtils.toString(response.getEntity()); + + ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory()); + return jsonWriter.readValue(responseBody, ApplicationResponseModel.class); + } + } + + /** + * Update an existing application + * + * @param appId Application id. + * @param application Updated application patch object. + */ + public void updateApplication(String appId, ApplicationPatchModel application) throws IOException { + String jsonRequest = toJSONString(application); + String endPointUrl = applicationManagementApiBasePath + PATH_SEPARATOR + appId; + + try (CloseableHttpResponse response = getResponseOfHttpPatch(endPointUrl, jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + "Application update failed"); + } + } + + /** + * Get all applications + * + * @return ApplicationListResponse object. + */ + public ApplicationListResponse getAllApplications() throws IOException { + try (CloseableHttpResponse response = getResponseOfHttpGet(applicationManagementApiBasePath, getHeaders())) { + String responseBody = EntityUtils.toString(response.getEntity()); + + ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory()); + return jsonWriter.readValue(responseBody, ApplicationListResponse.class); + } + } + + /** + * Delete an application + * + * @param appId Application id. + */ + public void deleteApplication(String appId) throws IOException { + String endpointUrl = applicationManagementApiBasePath + PATH_SEPARATOR + appId; + + try (CloseableHttpResponse response = getResponseOfHttpDelete(endpointUrl, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_NO_CONTENT, + "Application deletion failed"); + } + } + + /** + * Get OIDC inbound configuration details of an application + * + * @param appId Application id. + * @return OpenIDConnectConfiguration object with oidc configuration details. + */ + public OpenIDConnectConfiguration getOIDCInboundDetails(String appId) throws Exception { + String responseBody = getConfig(appId, OIDC); + ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory()); + return jsonWriter.readValue(responseBody, OpenIDConnectConfiguration.class); + } + + /** + * Get SAML inbound configuration details of an application + * + * @param appId Application id. + * @return SAML2ServiceProvider object with saml configuration details. + */ + public SAML2ServiceProvider getSAMLInboundDetails(String appId) throws Exception { + String responseBody = getConfig(appId, SAML); + ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory()); + + return jsonWriter.readValue(responseBody, SAML2ServiceProvider.class); + } + + private String getConfig(String appId, String inboundType) throws Exception { + String endPointUrl = applicationManagementApiBasePath + PATH_SEPARATOR + appId + INBOUND_PROTOCOLS_BASE_PATH + + PATH_SEPARATOR + inboundType; + + try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { + return EntityUtils.toString(response.getEntity()); + } + } + + /** + * Update inbound configuration details of an application + * + * @param appId Application id. + * @param inboundConfig inbound configuration object to be updated. + * @param inboundType Type of the inbound configuration. + */ + public void updateInboundDetailsOfApplication(String appId, Object inboundConfig, String inboundType) + throws IOException { + String jsonRequest = toJSONString(inboundConfig); + String endPointUrl = applicationManagementApiBasePath + PATH_SEPARATOR + appId + INBOUND_PROTOCOLS_BASE_PATH + + PATH_SEPARATOR + inboundType; + + try (CloseableHttpResponse response = getResponseOfHttpPut(endPointUrl, jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + String.format("Application %s inbound config update failed", inboundType)); + } + } + + private String getApplicationsPath(String serverUrl, String tenantDomain) { + if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + return serverUrl + API_SERVER_BASE_PATH + APPLICATION_MANAGEMENT_PATH; + } else { + return serverUrl + TENANT_PATH + tenantDomain + PATH_SEPARATOR + API_SERVER_BASE_PATH + APPLICATION_MANAGEMENT_PATH; + } + } + + private Header[] getHeaders() { + Header[] headerList = new Header[3]; + headerList[0] = new BasicHeader(USER_AGENT_ATTRIBUTE, OAuth2Constant.USER_AGENT); + headerList[1] = new BasicHeader(AUTHORIZATION_ATTRIBUTE, BASIC_AUTHORIZATION_ATTRIBUTE + + Base64.encodeBase64String((username + ":" + password).getBytes()).trim()); + headerList[2] = new BasicHeader(CONTENT_TYPE_ATTRIBUTE, String.valueOf(ContentType.JSON)); + + return headerList; + } + + /** + * Close the HTTP client + * + */ + public void closeHttpClient() throws IOException { + client.close(); + } +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/RestBaseClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/RestBaseClient.java new file mode 100644 index 0000000000..2b8fc7e982 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/RestBaseClient.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.identity.integration.test.restclients; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.apache.http.Header; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPatch; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import java.io.IOException; + +public class RestBaseClient { + + public static final String LOCATION_HEADER = "Location"; + public static final String BASIC_AUTHORIZATION_ATTRIBUTE = "Basic "; + public static final String CONTENT_TYPE_ATTRIBUTE = "Content-Type"; + public static final String AUTHORIZATION_ATTRIBUTE = "Authorization"; + public static final String USER_AGENT_ATTRIBUTE = "User-Agent"; + public static final String TENANT_PATH = "t/"; + public static final String PATH_SEPARATOR = "/"; + public static final String OIDC = "oidc"; + public static final String SAML = "saml"; + public final CloseableHttpClient client; + + public RestBaseClient() { + client = HttpClients.createDefault(); + } + + /** + * To convert object to a json string. + * + * @param object Respective java object. + * @return Relevant json string. + */ + public String toJSONString(java.lang.Object object) { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + return gson.toJson(object); + } + + /** + * To convert a string from a Http response to a json object. + * + * @param responseString Respective Http response. + * @return Relevant json object. + */ + public JSONObject getJSONObject(String responseString) throws Exception { + JSONParser parser = new JSONParser(); + JSONObject json = (JSONObject) parser.parse(responseString); + if (json == null) { + throw new Exception("Error occurred while getting the response"); + } + + return json; + } + + /** + * Execute and get the response of HTTP POST + * + * @param endPointUrl REST endpoint. + * @param jsonRequest json body. + * @param headers header list of the request. + * @return Response of the Http request. + */ + public CloseableHttpResponse getResponseOfHttpPost(String endPointUrl, String jsonRequest, Header[] headers) + throws IOException { + HttpPost request = new HttpPost(endPointUrl); + request.setHeaders(headers); + request.setEntity(new StringEntity(jsonRequest)); + + return client.execute(request); + } + + /** + * Execute and get the response of HTTP GET + * + * @param endPointUrl REST endpoint. + * @param headers header list of the request. + * @return Response of the Http request. + */ + public CloseableHttpResponse getResponseOfHttpGet(String endPointUrl, Header[] headers) + throws IOException { + HttpGet request = new HttpGet(endPointUrl); + request.setHeaders(headers); + + return client.execute(request); + } + + /** + * Execute and get the response of HTTP PATCH + * + * @param endPointUrl REST endpoint. + * @param jsonRequest json body. + * @param headers header list of the request. + * @return Response of the Http request. + */ + public CloseableHttpResponse getResponseOfHttpPatch(String endPointUrl, String jsonRequest, Header[] headers) throws IOException { + HttpPatch request = new HttpPatch(endPointUrl); + request.setHeaders(headers); + request.setEntity(new StringEntity(jsonRequest)); + + return client.execute(request); + } + + /** + * Execute and get the response of HTTP DELETE + * + * @param endPointUrl REST endpoint. + * @param headers header list of the request. + * @return Response of the Http request. + */ + public CloseableHttpResponse getResponseOfHttpDelete(String endPointUrl, Header[] headers) throws IOException { + HttpDelete request = new HttpDelete(endPointUrl); + request.setHeaders(headers); + + return client.execute(request); + } + + /** + * Execute and get the response of HTTP PUT + * + * @param endPointUrl REST endpoint. + * @param jsonRequest json body. + * @param headers header list of the request. + * @return Response of the Http request. + */ + public CloseableHttpResponse getResponseOfHttpPut(String endPointUrl, String jsonRequest, Header[] headers) + throws IOException { + HttpPut request = new HttpPut(endPointUrl); + request.setHeaders(headers); + request.setEntity(new StringEntity(jsonRequest)); + + return client.execute(request); + } + +} diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/SCIM2RestClient.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/SCIM2RestClient.java new file mode 100644 index 0000000000..e93469d902 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/restclients/SCIM2RestClient.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.identity.integration.test.restclients; + +import org.apache.commons.codec.binary.Base64; +import org.apache.http.Header; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.message.BasicHeader; +import org.apache.http.util.EntityUtils; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.testng.Assert; +import org.wso2.carbon.automation.engine.context.beans.Tenant; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import org.wso2.identity.integration.test.rest.api.user.common.model.PatchOperationRequestObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.RoleRequestObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.RoleSearchRequestObject; +import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject; +import org.wso2.identity.integration.test.utils.OAuth2Constant; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class SCIM2RestClient extends RestBaseClient { + + private static final String SCIM2_USERS_ENDPOINT = "scim2/Users"; + private static final String SCIM2_ROLES_ENDPOINT = "scim2/Roles"; + private static final String SCIM2_ROLE_SEARCH_PATH = "/.search"; + private static final String SCIM_JSON_CONTENT_TYPE = "application/scim+json"; + private static final String ROLE_SEARCH_SCHEMA = "urn:ietf:params:scim:api:messages:2.0:SearchRequest"; + private static final String DISPLAY_NAME_ATTRIBUTE = "displayName"; + private static final String EQ_OP = "eq"; + private final String serverUrl; + private final String tenantDomain; + private final String username; + private final String password; + + public SCIM2RestClient(String serverUrl, Tenant tenantInfo){ + this.serverUrl = serverUrl; + this.tenantDomain = tenantInfo.getContextUser().getUserDomain(); + this.username = tenantInfo.getContextUser().getUserName(); + this.password = tenantInfo.getContextUser().getPassword(); + } + + /** + * Create a user + * + * @param userInfo object with user creation details. + * @return Id of the created user. + */ + public String createUser(UserObject userInfo) throws Exception { + String jsonRequest = toJSONString(userInfo); + if (userInfo.getScimSchemaExtensionEnterprise() != null) { + jsonRequest = jsonRequest.replace("scimSchemaExtensionEnterprise", + "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"); + } + + try (CloseableHttpResponse response = getResponseOfHttpPost(getUsersPath(), jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_CREATED, + "User creation failed"); + JSONObject jsonResponse = getJSONObject(EntityUtils.toString(response.getEntity())); + return jsonResponse.get("id").toString(); + } + } + + /** + * Get the details of a user + * + * @param userId id of the user. + * @return JSONObject of the HTTP response. + */ + public JSONObject getUser(String userId) throws Exception { + String endPointUrl = getUsersPath() + PATH_SEPARATOR + userId; + + try (CloseableHttpResponse response = getResponseOfHttpGet(endPointUrl, getHeaders())) { + return getJSONObject(EntityUtils.toString(response.getEntity())); + } + } + + /** + * Update the details of an existing user + * + * @param patchUserInfo user patch request object. + * @param userId id of the user. + */ + public void updateUser(PatchOperationRequestObject patchUserInfo, String userId) throws IOException { + String jsonRequest = toJSONString(patchUserInfo); + String endPointUrl = getUsersPath() + PATH_SEPARATOR + userId; + + try (CloseableHttpResponse response = getResponseOfHttpPatch(endPointUrl, jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + "Role update failed"); + } + } + + /** + * Delete an existing user + * + * @param userId id of the user. + */ + public void deleteUser(String userId) throws IOException { + String endPointUrl = getUsersPath() + PATH_SEPARATOR + userId; + + try (CloseableHttpResponse response = getResponseOfHttpDelete(endPointUrl, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_NO_CONTENT, + "User deletion failed"); + } + } + + /** + * Add a new role + * + * @param roleInfo Role request object. + * @return Role id. + */ + public String addRole(RoleRequestObject roleInfo) throws Exception { + String jsonRequest = toJSONString(roleInfo); + + try (CloseableHttpResponse response = getResponseOfHttpPost(getRolesPath(), jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_CREATED, + "Role creation failed"); + JSONObject jsonResponse = getJSONObject(EntityUtils.toString(response.getEntity())); + return jsonResponse.get("id").toString(); + } + } + + /** + * Update an existing role + * + * @param patchRoleInfo Role patch request object. + * @param roleId Role id. + */ + public void updateUserRole(PatchOperationRequestObject patchRoleInfo, String roleId) throws IOException { + String jsonRequest = toJSONString(patchRoleInfo); + String endPointUrl = getRolesPath() + PATH_SEPARATOR + roleId; + + try (CloseableHttpResponse response = getResponseOfHttpPatch(endPointUrl, jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + "Role update failed"); + } + } + + /** + * Search and get the id of a role by the name + * + * @param roleName Role name. + * @return Role id. + */ + public String getRoleIdByName(String roleName) throws Exception { + + RoleSearchRequestObject roleSearchObj = new RoleSearchRequestObject(); + roleSearchObj.addSchemas(ROLE_SEARCH_SCHEMA); + + String filterString = DISPLAY_NAME_ATTRIBUTE + " " + EQ_OP + " " + roleName; + roleSearchObj.setFilter(filterString); + + String jsonRequest = toJSONString(roleSearchObj); + + try (CloseableHttpResponse response = getResponseOfHttpPost(getRolesPath() + SCIM2_ROLE_SEARCH_PATH, + jsonRequest, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, + "Role search failed"); + JSONObject jsonResponse = getJSONObject(EntityUtils.toString(response.getEntity())); + JSONObject searchResult = (JSONObject) ((JSONArray) jsonResponse.get("Resources")).get(0); + + return searchResult.get("id").toString(); + } + } + + /** + * Delete an existing role + * + * @param roleId Role id. + */ + public void deleteRole(String roleId) throws IOException { + String endPointUrl = getRolesPath() + PATH_SEPARATOR + roleId; + + try (CloseableHttpResponse response = getResponseOfHttpDelete(endPointUrl, getHeaders())) { + Assert.assertEquals(response.getStatusLine().getStatusCode(), HttpServletResponse.SC_NO_CONTENT, + "Role deletion failed"); + } + } + + private Header[] getHeaders() { + + Header[] headerList = new Header[3]; + headerList[0] = new BasicHeader(USER_AGENT_ATTRIBUTE, OAuth2Constant.USER_AGENT); + headerList[1] = new BasicHeader(AUTHORIZATION_ATTRIBUTE, BASIC_AUTHORIZATION_ATTRIBUTE + + Base64.encodeBase64String((username + ":" + password).getBytes()).trim()); + headerList[2] = new BasicHeader(CONTENT_TYPE_ATTRIBUTE, SCIM_JSON_CONTENT_TYPE); + + return headerList; + } + + private String getUsersPath() { + if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + return serverUrl + SCIM2_USERS_ENDPOINT; + } else { + return serverUrl + TENANT_PATH + tenantDomain + PATH_SEPARATOR + SCIM2_USERS_ENDPOINT; + } + } + + private String getRolesPath() { + if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + return serverUrl + SCIM2_ROLES_ENDPOINT; + } else { + return serverUrl + TENANT_PATH + tenantDomain + PATH_SEPARATOR + SCIM2_ROLES_ENDPOINT; + } + } + + /** + * Close the HTTP client. + * + */ + public void closeHttpClient() throws IOException { + client.close(); + } +}