-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into idp-integration-test-improve
- Loading branch information
Showing
11 changed files
with
674 additions
and
3 deletions.
There are no files selected for viewing
429 changes: 429 additions & 0 deletions
429
...g/wso2/identity/integration/test/organizationDiscovery/OrganizationDiscoveryTestCase.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...est/java/org/wso2/identity/integration/test/restclients/OrgDiscoveryConfigRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright (c) 2024, 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.commons.codec.binary.Base64; | ||
import org.apache.http.Header; | ||
import org.apache.http.client.methods.CloseableHttpResponse; | ||
import org.apache.http.message.BasicHeader; | ||
import org.testng.Assert; | ||
import org.wso2.carbon.automation.engine.context.beans.Tenant; | ||
import org.wso2.identity.integration.common.utils.ISIntegrationTest; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* Rest client for organization discovery configuration management API. | ||
*/ | ||
public class OrgDiscoveryConfigRestClient extends RestBaseClient { | ||
|
||
private static final String API_BASE_PATH = "api/server/v1"; | ||
private static final String ORGANIZATION_CONFIG_PATH = "/organization-configs"; | ||
private static final String ORGANIZATIONS_PATH = "/organizations"; | ||
private static final String DISCOVERY_PATH = "/discovery"; | ||
|
||
private final String username; | ||
private final String password; | ||
private final String serverBasePath; | ||
|
||
public OrgDiscoveryConfigRestClient(String backendURL, Tenant tenantInfo) { | ||
|
||
this.username = tenantInfo.getContextUser().getUserName(); | ||
this.password = tenantInfo.getContextUser().getPassword(); | ||
|
||
String tenantDomain = tenantInfo.getContextUser().getUserDomain(); | ||
this.serverBasePath = backendURL + ISIntegrationTest.getTenantedRelativePath(API_BASE_PATH, tenantDomain); | ||
} | ||
|
||
/** | ||
* Add organization discovery config to the root organization. | ||
* | ||
* @param requestBody Request body. | ||
*/ | ||
public void addOrganizationDiscoveryConfig(String requestBody) { | ||
|
||
try (CloseableHttpResponse httpResponse = getResponseOfHttpPost( | ||
serverBasePath + ORGANIZATION_CONFIG_PATH + DISCOVERY_PATH, requestBody, getHeaders())) { | ||
Assert.assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpServletResponse.SC_CREATED, | ||
"Failed to add organization discovery config."); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error occurred while adding organization discovery config.", e); | ||
} | ||
} | ||
|
||
/** | ||
* Delete organization discovery config of the root organization. | ||
*/ | ||
public void deleteOrganizationDiscoveryConfig() { | ||
|
||
try (CloseableHttpResponse httpResponse = getResponseOfHttpDelete( | ||
serverBasePath + ORGANIZATION_CONFIG_PATH + DISCOVERY_PATH, getHeaders())) { | ||
Assert.assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpServletResponse.SC_NO_CONTENT, | ||
"Failed to delete organization discovery config."); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error occurred while deleting organization discovery config.", e); | ||
} | ||
} | ||
|
||
/** | ||
* Map discovery attributes to an organization. | ||
* | ||
* @param orgId Organization ID. | ||
* @param requestBody Request body. | ||
*/ | ||
public void mapDiscoveryAttributes(String orgId, String requestBody) { | ||
|
||
String endpointUrl = serverBasePath + ORGANIZATIONS_PATH + PATH_SEPARATOR + orgId + DISCOVERY_PATH; | ||
try (CloseableHttpResponse httpResponse = getResponseOfHttpPut(endpointUrl, requestBody, getHeaders())) { | ||
Assert.assertEquals(httpResponse.getStatusLine().getStatusCode(), HttpServletResponse.SC_OK, | ||
"Failed to map discovery attributes."); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error occurred while mapping discovery attributes.", e); | ||
} | ||
} | ||
|
||
public void closeHttpClient() throws IOException { | ||
|
||
client.close(); | ||
} | ||
|
||
private Header[] getHeaders() { | ||
|
||
return new Header[]{ | ||
new BasicHeader(CONTENT_TYPE_ATTRIBUTE, String.valueOf(ContentType.JSON)), | ||
new BasicHeader(AUTHORIZATION_ATTRIBUTE, BASIC_AUTHORIZATION_ATTRIBUTE + | ||
Base64.encodeBase64String((username + ":" + password).getBytes()).trim()) | ||
}; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ests-backend/src/test/resources/artifacts/IS/organizationDiscovery/email_as_username.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[server] | ||
hostname = "localhost" | ||
node_ip = "127.0.0.1" | ||
base_path = "https://$ref{server.hostname}:${carbon.management.port}" | ||
|
||
[super_admin] | ||
username = "admin" | ||
password = "admin" | ||
create_admin_account = true | ||
|
||
[user_store] | ||
type = "database_unique_id" | ||
|
||
[database.identity_db] | ||
type = "h2" | ||
url = "jdbc:h2:./repository/database/WSO2IDENTITY_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000" | ||
username = "wso2carbon" | ||
password = "wso2carbon" | ||
|
||
[database.shared_db] | ||
type = "h2" | ||
url = "jdbc:h2:./repository/database/WSO2SHARED_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000" | ||
username = "wso2carbon" | ||
password = "wso2carbon" | ||
|
||
[keystore.primary] | ||
file_name = "wso2carbon.p12" | ||
password = "wso2carbon" | ||
type="PKCS12" | ||
|
||
[truststore] | ||
file_name="client-truststore.p12" | ||
password="wso2carbon" | ||
type="PKCS12" | ||
|
||
[account_recovery.endpoint.auth] | ||
hash= "66cd9688a2ae068244ea01e70f0e230f5623b7fa4cdecb65070a09ec06452262" | ||
|
||
[identity.auth_framework.endpoint] | ||
app_password= "dashboard" | ||
|
||
[tenant_mgt] | ||
enable_email_domain= true | ||
|
||
[identity_mgt.user_self_registration] | ||
allow_self_registration = true |
15 changes: 15 additions & 0 deletions
15
...s/org/wso2/identity/integration/test/organizationDiscovery/email_as_username_request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"claimURI": "http://wso2.org/claims/username", | ||
"description": "Username", | ||
"displayOrder": 0, | ||
"displayName": "Username", | ||
"readOnly": false, | ||
"required": false, | ||
"supportedByDefault": false, | ||
"attributeMapping": [ | ||
{ | ||
"mappedAttribute": "mail", | ||
"userstore": "PRIMARY" | ||
} | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
...o2/identity/integration/test/organizationDiscovery/enable_email_domain_org_discovery.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"properties": [ | ||
{ | ||
"key": "emailDomain.enable", | ||
"value": "true" | ||
}, | ||
{ | ||
"key": "emailDomainBasedSelfSignup.enable", | ||
"value": "true" | ||
} | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
...org/wso2/identity/integration/test/organizationDiscovery/map_email_domain_to_sub_org.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"attributes": [ | ||
{ | ||
"type": "emailDomain", | ||
"values": [ | ||
"wso2.com" | ||
] | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
...rg/wso2/identity/integration/test/organizationDiscovery/organization-onboarding-apis.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"/api/server/v1/organizations": [ | ||
"internal_organization_view", | ||
"internal_organization_create", | ||
"internal_organization_delete" | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
...so2/identity/integration/test/organizationDiscovery/revert_email_as_username_request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"claimURI": "http://wso2.org/claims/username", | ||
"description": "Username", | ||
"displayOrder": 0, | ||
"displayName": "Username", | ||
"readOnly": false, | ||
"required": false, | ||
"supportedByDefault": false, | ||
"attributeMapping": [ | ||
{ | ||
"mappedAttribute": "uid", | ||
"userstore": "PRIMARY" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters