diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationManagementSuccessTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationManagementSuccessTest.java index 4e9c6e330b..66aee6d25d 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationManagementSuccessTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationManagementSuccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019-2024, WSO2 LLC. (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. @@ -19,6 +19,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.nimbusds.oauth2.sdk.util.URLUtils; import io.restassured.response.Response; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; import org.apache.commons.lang.StringUtils; import org.apache.http.HttpHeaders; import org.apache.http.HttpStatus; @@ -28,6 +31,7 @@ import org.wso2.carbon.automation.engine.context.TestUserMode; import org.wso2.carbon.identity.application.mgt.ApplicationConstants; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; +import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationListItem; import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationListResponse; import java.io.IOException; @@ -38,6 +42,7 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.wso2.identity.integration.test.rest.api.server.application.management.v1.Utils.assertNotBlank; import static org.wso2.identity.integration.test.rest.api.server.application.management.v1.Utils.extractApplicationIdFromLocationHeader; @@ -49,6 +54,8 @@ public class ApplicationManagementSuccessTest extends ApplicationManagementBaseT private static final String MY_ACCOUNT = "My Account"; private static final String CREATED_APP_NAME = "My SAMPLE APP"; + private static final String CREATED_APP_TEMPLATE_ID = "Test_template_1"; + private static final String CREATED_APP_TEMPLATE_VERSION = "v1.0.0"; private String createdAppId; @Factory(dataProvider = "restAPIUserConfigProvider") @@ -111,6 +118,30 @@ public void createApplication() throws Exception { assertNotBlank(createdAppId); } + @Test(dependsOnMethods = {"createApplication"}) + public void testGetAllApplicationsWithParams() throws IOException { + + Map params = new HashMap<>(); + params.put("attributes", "templateId,templateVersion"); + Response response = getResponseOfGet(APPLICATION_MANAGEMENT_API_BASE_PATH, params); + response.then() + .log().ifValidationFails() + .assertThat() + .statusCode(HttpStatus.SC_OK); + ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory()); + ApplicationListResponse listResponse = jsonWriter.readValue(response.asString(), ApplicationListResponse.class); + + assertNotNull(listResponse); + + // Verify that the newly created app exists and has the required properties. + Optional newlyCreatedAppData = listResponse.getApplications().stream() + .filter(appBasicInfo -> appBasicInfo.getName().equals(CREATED_APP_NAME)).findFirst(); + Assert.assertTrue(newlyCreatedAppData.isPresent(), + "Newly Created application '" + CREATED_APP_NAME + "' is not listed by the API."); + Assert.assertEquals(newlyCreatedAppData.get().getTemplateId(), CREATED_APP_TEMPLATE_ID); + Assert.assertEquals(newlyCreatedAppData.get().getTemplateVersion(), CREATED_APP_TEMPLATE_VERSION); + } + @Test(dependsOnMethods = {"createApplication"}) public void testGetApplicationById() throws Exception { @@ -119,7 +150,9 @@ public void testGetApplicationById() throws Exception { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_OK) - .body("name", equalTo(CREATED_APP_NAME)); + .body("name", equalTo(CREATED_APP_NAME)) + .body("templateId", equalTo(CREATED_APP_TEMPLATE_ID)) + .body("templateVersion", equalTo(CREATED_APP_TEMPLATE_VERSION)); } @Test(dependsOnMethods = {"createApplication"}) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationPatchTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationPatchTest.java index 63f33a30b9..fa7384ed48 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationPatchTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/ApplicationPatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2019-2024, 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. @@ -37,6 +37,8 @@ public class ApplicationPatchTest extends ApplicationManagementBaseTest { private static final String APP_NAME = "testPatchApplication"; public static final String UPDATED_APP_NAME = "testUpdateNameApplication"; + private static final String APP_TEMPLATE_ID = "Test_template_1"; + private static final String APP_TEMPLATE_VERSION = "v1.0.0"; public static final String SUBJECT_CLAIM_URI = "http://wso2.org/claims/username"; private String appId; @@ -51,6 +53,8 @@ public void testCreateApplication() throws Exception { JSONObject createRequest = new JSONObject(); createRequest.put("name", APP_NAME); + createRequest.put("templateId", APP_TEMPLATE_ID); + createRequest.put("templateVersion", APP_TEMPLATE_VERSION); String payload = createRequest.toString(); Response responseOfPost = getResponseOfPost(APPLICATION_MANAGEMENT_API_BASE_PATH, payload); @@ -69,7 +73,9 @@ public void testCreateApplication() throws Exception { .log().ifValidationFails() .assertThat() .statusCode(HttpStatus.SC_OK) - .body("name", equalTo(APP_NAME)); + .body("name", equalTo(APP_NAME)) + .body("templateId", equalTo(APP_TEMPLATE_ID)) + .body("templateVersion", equalTo(APP_TEMPLATE_VERSION)); } @Test(dependsOnMethods = "testCreateApplication") @@ -93,11 +99,15 @@ public void testUpdateBasicInformation() throws Exception { String description = "This is my application."; String imageUrl = "https://localhost/image.png"; String accessUrl = "https://app.test.com/login"; + String templateId = "Test_template_2"; + String templateVersion = "v1.0.1"; JSONObject patchRequest = new JSONObject(); patchRequest.put("description", description); patchRequest.put("imageUrl", imageUrl); patchRequest.put("accessUrl", accessUrl); + patchRequest.put("templateId", templateId); + patchRequest.put("templateVersion", templateVersion); String path = APPLICATION_MANAGEMENT_API_BASE_PATH + "/" + appId; getResponseOfPatch(path, patchRequest.toString()).then() @@ -107,7 +117,9 @@ public void testUpdateBasicInformation() throws Exception { getApplication(appId).then() .body("description", equalTo(description)) .body("imageUrl", equalTo(imageUrl)) - .body("accessUrl", equalTo(accessUrl)); + .body("accessUrl", equalTo(accessUrl)) + .body("templateId", equalTo(templateId)) + .body("templateVersion", equalTo(templateVersion)); } @Test(dependsOnMethods = "testUpdateBasicInformation") diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationListItem.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationListItem.java index 699f7fb824..d3789d684e 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationListItem.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/server/application/management/v1/model/ApplicationListItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2019-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 @@ -72,6 +72,7 @@ public static AccessEnum fromValue(String value) { private String self; private AdvancedApplicationConfiguration advancedConfigurations; private String templateId; + private String templateVersion; private AssociatedRolesConfig associatedRoles; /** @@ -290,6 +291,25 @@ public void setTemplateId(String templateId) { this.templateId = templateId; } + /** + * Version of the template used to create the application. + **/ + public ApplicationListItem templateVersion(String templateVersion) { + + this.templateVersion = templateVersion; + return this; + } + + @ApiModelProperty(example = "v1.0.0", value = "Version of the template used to create the application.") + @JsonProperty("templateVersion") + @Valid + public String getTemplateVersion() { + return templateVersion; + } + public void setTemplateVersion(String templateVersion) { + this.templateVersion = templateVersion; + } + /** **/ public ApplicationListItem associatedRoles(AssociatedRolesConfig associatedRoles) { @@ -330,12 +350,13 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.self, applicationListItem.self) && Objects.equals(this.advancedConfigurations, applicationListItem.advancedConfigurations) && Objects.equals(this.templateId, applicationListItem.templateId) && + Objects.equals(this.templateVersion, applicationListItem.templateVersion) && Objects.equals(this.associatedRoles, applicationListItem.associatedRoles); } @Override public int hashCode() { - return Objects.hash(id, name, description, image, accessUrl, clientId, issuer, realm, access, self, advancedConfigurations, templateId, associatedRoles); + return Objects.hash(id, name, description, image, accessUrl, clientId, issuer, realm, access, self, advancedConfigurations, templateId, templateVersion, associatedRoles); } @Override @@ -356,6 +377,7 @@ public String toString() { sb.append(" self: ").append(toIndentedString(self)).append("\n"); sb.append(" advancedConfigurations: ").append(toIndentedString(advancedConfigurations)).append("\n"); sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); + sb.append(" templateVersion: ").append(toIndentedString(templateVersion)).append("\n"); sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).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 index 0f4185d739..fef0a9cab2 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-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 @@ -33,6 +33,7 @@ public class ApplicationPatchModel { private String imageUrl; private String accessUrl; private String templateId; + private String templateVersion; private AssociatedRolesConfig associatedRoles; private ClaimConfiguration claimConfiguration; private AuthenticationSequence authenticationSequence; @@ -129,6 +130,25 @@ public void setTemplateId(String templateId) { this.templateId = templateId; } + /** + * Version of the template used to create the application. + **/ + public ApplicationPatchModel templateVersion(String templateVersion) { + + this.templateVersion = templateVersion; + return this; + } + + @ApiModelProperty(example = "v1.0.0", value = "Version of the template used to create the application.") + @JsonProperty("templateVersion") + @Valid + public String getTemplateVersion() { + return templateVersion; + } + public void setTemplateVersion(String templateVersion) { + this.templateVersion = templateVersion; + } + /** **/ public ApplicationPatchModel associatedRoles(AssociatedRolesConfig associatedRoles) { @@ -236,6 +256,7 @@ public boolean equals(java.lang.Object o) { Objects.equals(this.imageUrl, applicationPatchModel.imageUrl) && Objects.equals(this.accessUrl, applicationPatchModel.accessUrl) && Objects.equals(this.templateId, applicationPatchModel.templateId) && + Objects.equals(this.templateVersion, applicationPatchModel.templateVersion) && Objects.equals(this.associatedRoles, applicationPatchModel.associatedRoles) && Objects.equals(this.claimConfiguration, applicationPatchModel.claimConfiguration) && Objects.equals(this.authenticationSequence, applicationPatchModel.authenticationSequence) && @@ -245,7 +266,7 @@ public boolean equals(java.lang.Object o) { @Override public int hashCode() { - return Objects.hash(name, description, imageUrl, accessUrl, templateId, associatedRoles, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations); + return Objects.hash(name, description, imageUrl, accessUrl, templateId, templateVersion, associatedRoles, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations); } @Override @@ -259,6 +280,7 @@ public String toString() { 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(" templateVersion: ").append(toIndentedString(templateVersion)).append("\n"); sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).append("\n"); sb.append(" claimConfiguration: ").append(toIndentedString(claimConfiguration)).append("\n"); sb.append(" authenticationSequence: ").append(toIndentedString(authenticationSequence)).append("\n"); 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 index 507eb19d84..e0e7f1fb2c 100644 --- 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com). + * Copyright (c) 2023-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 @@ -39,6 +39,7 @@ public class ApplicationResponseModel { private String issuer; private String realm; private String templateId; + private String templateVersion; private Boolean isManagementApp; private Boolean isB2BSelfServiceApp; private Boolean applicationEnabled; @@ -265,6 +266,25 @@ public void setTemplateId(String templateId) { this.templateId = templateId; } + /** + * Version of the template used to create the application. + **/ + public ApplicationResponseModel templateVersion(String templateVersion) { + + this.templateVersion = templateVersion; + return this; + } + + @ApiModelProperty(example = "v1.0.0", value = "Version of the template used to create the application.") + @JsonProperty("templateVersion") + @Valid + public String getTemplateVersion() { + return templateVersion; + } + public void setTemplateVersion(String templateVersion) { + this.templateVersion = templateVersion; + } + /** * Decides whether the application used to access System APIs **/ @@ -470,6 +490,7 @@ public boolean equals(Object o) { Objects.equals(this.issuer, applicationResponseModel.issuer) && Objects.equals(this.realm, applicationResponseModel.realm) && Objects.equals(this.templateId, applicationResponseModel.templateId) && + Objects.equals(this.templateVersion, applicationResponseModel.templateVersion) && Objects.equals(this.isManagementApp, applicationResponseModel.isManagementApp) && Objects.equals(this.isB2BSelfServiceApp, applicationResponseModel.isB2BSelfServiceApp) && Objects.equals(this.applicationEnabled, applicationResponseModel.applicationEnabled) && @@ -484,7 +505,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(id, name, description, imageUrl, accessUrl, logoutReturnUrl, clientId, issuer, realm, templateId, isManagementApp, isB2BSelfServiceApp, applicationEnabled, associatedRoles, claimConfiguration, inboundProtocols, authenticationSequence, advancedConfigurations, provisioningConfigurations, access); + return Objects.hash(id, name, description, imageUrl, accessUrl, logoutReturnUrl, clientId, issuer, realm, templateId, templateVersion, isManagementApp, isB2BSelfServiceApp, applicationEnabled, associatedRoles, claimConfiguration, inboundProtocols, authenticationSequence, advancedConfigurations, provisioningConfigurations, access); } @Override @@ -502,6 +523,7 @@ public String toString() { sb.append(" issuer: ").append(toIndentedString(issuer)).append("\n"); sb.append(" realm: ").append(toIndentedString(realm)).append("\n"); sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); + sb.append(" templateVersion: ").append(toIndentedString(templateVersion)).append("\n"); sb.append(" isManagementApp: ").append(toIndentedString(isManagementApp)).append("\n"); sb.append(" isB2BSelfServiceApp: ").append(toIndentedString(isB2BSelfServiceApp)).append("\n"); sb.append(" applicationEnabled: ").append(toIndentedString(applicationEnabled)).append("\n"); diff --git a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/application/management/v1/create-basic-application.json b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/application/management/v1/create-basic-application.json index 16df776394..276fb9533f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/application/management/v1/create-basic-application.json +++ b/modules/integration/tests-integration/tests-backend/src/test/resources/org/wso2/identity/integration/test/rest/api/server/application/management/v1/create-basic-application.json @@ -2,5 +2,7 @@ "name": "My SAMPLE APP", "description": "my application 2", "imageUrl": "https://localhost/image", - "accessUrl": "https://localhost/accessUrl" + "accessUrl": "https://localhost/accessUrl", + "templateId": "Test_template_1", + "templateVersion": "v1.0.0" } diff --git a/pom.xml b/pom.xml index 0092846c9f..db2c03ccea 100755 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - 7.3.56 + 7.3.57 [5.14.67, 8.0.0) @@ -2385,7 +2385,7 @@ 2.0.17 1.3.38 - 1.2.212 + 1.2.213 5.5.9 5.5.8