Skip to content

Commit

Permalink
Merge pull request #20628 from HasiniSama/integration_test_org_get
Browse files Browse the repository at this point in the history
Integration tests for Organization GET API for metadata filtering
  • Loading branch information
AnuradhaSK authored Jul 5, 2024
2 parents fd09d55 + c5f2d73 commit 067bde2
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ public void testSelfOnboardOrganization(String requestBodyPath) throws Exception
}

@Test(dependsOnMethods = "testSelfOnboardOrganization")
public void testGetOrganizationsWithInvalidOperator() {

String filterQuery = "?filter=name ca G&limit=10&recursive=false";
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60059");
}

@Test(dependsOnMethods = "testGetOrganizationsWithInvalidOperator")
public void testGetOrganizationsWithUnsupportedAttribute() {

String filterQuery = "?filter=attribute.Country co S&limit=10&recursive=false";
String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
validateErrorResponseWithoutTraceId(response, HttpStatus.SC_BAD_REQUEST, "ORG-60023");
}

@Test(dependsOnMethods = "testGetOrganizationsWithUnsupportedAttribute")
public void testGetDiscoveryConfigWithoutAddingConfig() {

String endpointURL = ORGANIZATION_CONFIGS_API_BASE_PATH + ORGANIZATION_DISCOVERY_API_PATH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,6 @@ public static Object[][] restAPIUserConfigProvider() {
};
}

@DataProvider(name = "checkDiscoveryAttributes")
public Object[][] checkDiscoveryAttributeFilePaths() {

return new Object[][]{
{"check-discovery-attributes-available-request-body.json", true},
{"check-discovery-attributes-unavailable-request-body.json", false}
};
}

@Test
public void createApplicationForSelfOrganizationOnboardService() throws IOException, JSONException {

Expand Down Expand Up @@ -258,7 +249,46 @@ public void testGetOrganization() {
.body("id", equalTo(organizationID));
}

@Test(dependsOnMethods = "testGetOrganization")
@DataProvider(name = "dataProviderForFilterOrganizations")
public Object[][] dataProviderForFilterOrganizations() {

return new Object[][] {
{"?filter=name co G&limit=10&recursive=false", false, false},
{"?filter=attributes.Country co S&limit=10&recursive=false", true, false},
{"?filter=attributes.Country eq Sri Lanka&limit=10&recursive=false", true, false},
{"?filter=attributes.Country eq Sri Lanka and name co Greater&limit=10&recursive=false", true, false},
{"?filter=attributes.Country eq USA&limit=10&recursive=false", false, true}
};
}

@Test(dependsOnMethods = "testGetOrganization", dataProvider = "dataProviderForFilterOrganizations")
public void testFilterOrganizations(String filterQuery, boolean expectAttributes, boolean expectEmptyList) {

String endpointURL = ORGANIZATION_MANAGEMENT_API_BASE_PATH + filterQuery;
Response response = getResponseOfGetWithOAuth2(endpointURL, m2mToken);
Assert.assertNotNull(response.asString());
response.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK);

if (expectEmptyList) {
response.then()
.assertThat().body(equalTo("{}"));
} else {
response.then()
.body("organizations.size()", equalTo(1))
.body("organizations[0].id", equalTo(organizationID));
if (expectAttributes) {
response.then()
.body("organizations[0].attributes.size()", equalTo(2))
.body("organizations[0].attributes[0].key", equalTo("Country"))
.body("organizations[0].attributes[0].value", equalTo("Sri Lanka"));
}
}
}

@Test(dependsOnMethods = "testFilterOrganizations")
public void switchM2MToken() throws IOException, ParseException, InterruptedException {

ApplicationSharePOSTRequest applicationSharePOSTRequest = new ApplicationSharePOSTRequest();
Expand Down Expand Up @@ -434,6 +464,15 @@ public void testUpdateDiscoveryAttributesOfOrganization() throws IOException {
.body("attributes[0].values", containsInAnyOrder("xyz.com", "example.com"));
}

@DataProvider(name = "checkDiscoveryAttributes")
public Object[][] checkDiscoveryAttributeFilePaths() {

return new Object[][]{
{"check-discovery-attributes-available-request-body.json", true},
{"check-discovery-attributes-unavailable-request-body.json", false}
};
}

@Test(dependsOnMethods = "testUpdateDiscoveryAttributesOfOrganization", dataProvider = "checkDiscoveryAttributes")
public void testCheckDiscoveryAttributeExists(String requestBodyFileName, boolean expectedAvailability)
throws IOException {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@
<authenticator.auth.otp.commons.version>1.0.7</authenticator.auth.otp.commons.version>

<identity.org.mgt.version>1.4.42</identity.org.mgt.version>
<identity.org.mgt.core.version>1.1.9</identity.org.mgt.core.version>
<identity.org.mgt.core.version>1.1.10</identity.org.mgt.core.version>
<identity.organization.login.version>1.1.33</identity.organization.login.version>
<identity.oauth2.grant.organizationswitch.version>1.1.25</identity.oauth2.grant.organizationswitch.version>

Expand All @@ -2375,7 +2375,7 @@
<!-- Identity REST API feature -->
<identity.api.dispatcher.version>2.0.17</identity.api.dispatcher.version>
<identity.user.api.version>1.3.38</identity.user.api.version>
<identity.server.api.version>1.2.202</identity.server.api.version>
<identity.server.api.version>1.2.203</identity.server.api.version>

<identity.agent.sso.version>5.5.9</identity.agent.sso.version>
<identity.tool.samlsso.validator.version>5.5.8</identity.tool.samlsso.validator.version>
Expand Down

0 comments on commit 067bde2

Please sign in to comment.