From 33d2e49679e7a4367f39c9267928757402c65e7b Mon Sep 17 00:00:00 2001
From: Udara Pathum <46132469+hwupathum@users.noreply.github.com>
Date: Wed, 23 Oct 2024 18:33:10 +0530
Subject: [PATCH 1/2] Update integration tests for tenant API
---
.../management/v1/TenantFailureTest.java | 28 +++++++++++++
.../management/v1/TenantSuccessTest.java | 40 ++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantFailureTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantFailureTest.java
index 469907f7f8e..a6e90374a44 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantFailureTest.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantFailureTest.java
@@ -30,6 +30,7 @@
import java.io.IOException;
+import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;
/**
@@ -148,5 +149,32 @@ public void updateTenantOwnerWithInvalidOwnerId() throws IOException {
validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "TM-60020", tenantId);
}
+ @Test
+ public void testGetTenantsInvalidFilterFormat() {
+
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=invalid format");
+ validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "TM-60022");
+ }
+
+ @Test
+ public void testGetTenantsUnsupportedFilterAttribute() {
+
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=username eq mail.com");
+ validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "TM-60023", "username");
+ }
+
+ @Test
+ public void testGetTenantsInvalidFilterOperation() {
+
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=domainName invalid_op abc.com");
+ validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "TM-60024", "domainName");
+ }
+
+ @Test
+ public void testGetTenantsFilterIllegalDomain() {
+
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=domainName eq abc*");
+ validateErrorResponse(response, HttpStatus.SC_BAD_REQUEST, "TM-60007");
+ }
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantSuccessTest.java
index b259d5c38a7..72a5093b8a4 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantSuccessTest.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/tenant/management/v1/TenantSuccessTest.java
@@ -119,7 +119,7 @@ public void testGetTenant() throws IOException {
.assertThat()
.statusCode(HttpStatus.SC_OK)
.body("id", equalTo(tenantId))
- .body("domain", equalTo("abc1.com"))
+ .body("domain", equalTo(TENANT_DOMAIN_NAME))
.body(baseIdentifier, notNullValue());
TenantResponseModel tenantResponseModel = response.getBody().as(TenantResponseModel.class);
userId = tenantResponseModel.getOwners().get(0).getId();
@@ -183,4 +183,42 @@ public void testGetOwner() {
.body( "lastname", equalTo("lee"))
.body(claimsIdentifier + ".value", equalTo("+94 77 123 4568"));
}
+
+ @Test(dependsOnMethods = {"testGetTenant"})
+ public void testGetFilteredTenantsEqual() {
+
+ String baseIdentifier = "tenants.find{ it.id == '" + tenantId + "' }.";
+ String activeStatusIdentifier = "owners.find{ it.id == '" + userId + "' }.";
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=domainName eq "
+ + TENANT_DOMAIN_NAME);
+ response.then()
+ .log().ifValidationFails()
+ .assertThat()
+ .statusCode(HttpStatus.SC_OK)
+ .body("totalResults", equalTo(1))
+ .body(baseIdentifier + "domain", equalTo("abc1.com"))
+ .body(baseIdentifier + activeStatusIdentifier + "username", equalTo("kim"));
+ }
+
+ @Test(dependsOnMethods = {"testAddTenant"})
+ public void testGetFilteredTenantsContains() {
+
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=domainName co abc1");
+ response.then()
+ .log().ifValidationFails()
+ .assertThat()
+ .statusCode(HttpStatus.SC_OK)
+ .body("totalResults", equalTo(1));
+ }
+
+ @Test
+ public void testGetFilteredTenantsNotAvailable() {
+
+ Response response = getResponseOfGet(TENANT_API_BASE_PATH + "?filter=domainName eq abc99.com");
+ response.then()
+ .log().ifValidationFails()
+ .assertThat()
+ .statusCode(HttpStatus.SC_OK)
+ .body("totalResults", equalTo(0));
+ }
}
From d7a90e5b62acdcce5aa192e1d65f1b0b5c77b989 Mon Sep 17 00:00:00 2001
From: Udara Pathum <46132469+hwupathum@users.noreply.github.com>
Date: Fri, 25 Oct 2024 10:56:17 +0530
Subject: [PATCH 2/2] Bump API server version
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index e7b66eb6135..e2e98c363ea 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2478,7 +2478,7 @@
2.0.17
- 1.2.241
+ 1.2.243
1.3.43
5.5.9