Skip to content

Commit

Permalink
Merge pull request #16496 from Lakshan-Banneheke/integration-tests-la…
Browse files Browse the repository at this point in the history
…kshan

Add integration tests for updating multiple governance connectors
  • Loading branch information
Kanapriya committed Aug 31, 2023
2 parents 7b5473b + af8b342 commit 61c3925
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
*/
public class IdentityGovernanceFailureTest extends IdentityGovernanceTestBase {

private static final String CATEGORY_PASSWORD_POLICIES = "UGFzc3dvcmQgUG9saWNpZXM";
private static final String INCORRECT_CATEGORY_PASSWORD_POLICIES = "YWNjb3VudC5sb2mhhbmRsZXI";
private static final String CATEGORY_ACCOUNT_MANAGEMENT_PROPERTIES = "QWNjb3VudCBNYW5hZ2VtZW50";

@Factory(dataProvider = "restAPIUserConfigProvider")
public IdentityGovernanceFailureTest(TestUserMode userMode) throws Exception {

Expand Down Expand Up @@ -110,4 +114,31 @@ public void testSearchInvalidGovernanceConnectorProperties() throws IOException
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "IDG-50012",
"SelfRegistration.Enble");
}

@Test
public void testUpdateGovernanceConnectorsIncorrectCategoryID() throws IOException {

String body = readResource("update-multiple-connector-properties.json");
Response response = getResponseOfPatch(IDENTITY_GOVERNANCE_ENDPOINT_URI +
"/" + INCORRECT_CATEGORY_PASSWORD_POLICIES + "/connectors/", body);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "IDG-50008");
}

@Test
public void testUpdateGovernanceConnectorsIncorrectConnectorID() throws IOException {

String body = readResource("update-multiple-connector-properties-incorrect.json");
Response response = getResponseOfPatch(IDENTITY_GOVERNANCE_ENDPOINT_URI +
"/" + CATEGORY_PASSWORD_POLICIES + "/connectors/", body);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "IDG-50009");
}

@Test
public void testUpdateGovernanceConnectorsMismatch() throws IOException {

String body = readResource("update-multiple-connector-properties.json");
Response response = getResponseOfPatch(IDENTITY_GOVERNANCE_ENDPOINT_URI +
"/" + CATEGORY_ACCOUNT_MANAGEMENT_PROPERTIES + "/connectors/", body);
validateErrorResponse(response, HttpStatus.SC_NOT_FOUND, "IDG-50009");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class IdentityGovernanceSuccessTest extends IdentityGovernanceTestBase {

private static final String CATEGORY_ACCOUNT_MANAGEMENT_PROPERTIES = "QWNjb3VudCBNYW5hZ2VtZW50";
private static final String CONNECTOR_LOCK_IDLE_ACCOUNTS = "c3VzcGVuc2lvbi5ub3RpZmljYXRpb24";
private static final String CATEGORY_PASSWORD_POLICIES = "UGFzc3dvcmQgUG9saWNpZXM";
private static final String CONNECTOR_PASSWORD_EXPIRY = "cGFzc3dvcmRFeHBpcnlWMg";
private static final String CONNECTOR_PASSWORD_HISTORY = "cGFzc3dvcmRIaXN0b3J5";
private Map<String, CategoriesRes> categories;
private static List<PreferenceResp> connectors;
private static List<PreferenceResp> connectorsWithAllProperties;
Expand Down Expand Up @@ -254,6 +257,41 @@ public void testUpdateGovernanceConnector() throws IOException {
equalTo("91"));
}

@Test
public void testUpdateGovernanceConnectors() throws IOException {

String body = readResource("update-multiple-connector-properties.json");
Response response =
getResponseOfPatch(IDENTITY_GOVERNANCE_ENDPOINT_URI +
"/" + CATEGORY_PASSWORD_POLICIES + "/connectors/", body);
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK);

Response getResponsePasswordExpiry =
getResponseOfGet(IDENTITY_GOVERNANCE_ENDPOINT_URI +
"/" + CATEGORY_PASSWORD_POLICIES + "/connectors/" + CONNECTOR_PASSWORD_EXPIRY);

getResponsePasswordExpiry.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("properties.find{it.name == 'passwordExpiry.enablePasswordExpiry' }.value",
equalTo("true"));

Response getResponsePasswordHistory =
getResponseOfGet(IDENTITY_GOVERNANCE_ENDPOINT_URI +
"/" + CATEGORY_PASSWORD_POLICIES + "/connectors/" + CONNECTOR_PASSWORD_HISTORY);

getResponsePasswordHistory.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("properties.find{it.name == 'passwordHistory.enable' }.value",
equalTo("true"));
}

@Test
public void testRestGovernanceConnector() throws IOException {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"operation": "UPDATE",
"connectors": [
{
"id": "cGFzc3dvcmRIaXN0b3J5",
"properties":[
{"name":"passwordHistory.count","value":"10"},{"name":"passwordHistory.enable","value":"true"}
]
},
{
"id": "YWNjb3VudC5sb2mhhbmRsZXI",
"properties":[
{"name":"passwordExpiry.enablePasswordExpiry","value":"true"},
{"name":"passwordExpiry.passwordExpiryInDays","value":"20"}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"operation": "UPDATE",
"connectors": [
{
"id": "cGFzc3dvcmRIaXN0b3J5",
"properties":[
{"name":"passwordHistory.count","value":"10"},{"name":"passwordHistory.enable","value":"true"}
]
},
{
"id": "cGFzc3dvcmRFeHBpcnlWMg",
"properties":[
{"name":"passwordExpiry.enablePasswordExpiry","value":"true"},
{"name":"passwordExpiry.passwordExpiryInDays","value":"20"}
]
}
]
}

0 comments on commit 61c3925

Please sign in to comment.