diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java index decb9719a9..a4d53c4f15 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationServiceCEImpl.java @@ -281,6 +281,7 @@ public class ApplicationServiceCEImpl extends BaseService this.setTransientFields(application1)) .flatMap(application1 -> { final Map eventData = Map.of( FieldName.APP_MODE, ApplicationMode.EDIT.toString(), diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java index 8d59745fe4..10793194f7 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java @@ -3298,4 +3298,92 @@ public class ApplicationServiceCETest { .verifyComplete(); } + + + /** + * Test case which proves the non-dependency of isPublic Field in Update Application API Response + * on the deprecated Application collection isPublic field for a public application + * The following steps are followed: + * 1. Create a new app + * 2. Invoke the changeViewAccess method to set the App "Public" + * 3. Invoke the update method and assert the "isPublic" field in the response + */ + @Test + @WithUserDetails(value = "api_user") + public void validPublicAppUpdateApplication() { + Application application = new Application(); + application.setName("validPublicAppUpdateApplication-Test"); + + Application createdApplication = applicationPageService.createApplication(application, workspaceId).block(); + + /** + * Making the App public using changeViewAccess method which changes the permission groups of the app to allow public access + */ + ApplicationAccessDTO applicationAccessDTO = new ApplicationAccessDTO(); + applicationAccessDTO.setPublicAccess(true); + Application publicAccessApplication = applicationService.changeViewAccess(createdApplication.getId(), applicationAccessDTO).block(); + + /** + * setIsPublic to False, purposely set to prove non-dependency on this field of the output + */ + publicAccessApplication.setIsPublic(false); + + /** + * Using the Update App method and asserting the response to verify the isPublic field in the response is True + * which proves it's non-dependency on the deprecated Application collection isPublic field + * and shows it dependency on the actual app permissions and state of the app which has been set public in this case + **/ + Mono updatedApplication = applicationService.update(createdApplication.getId(), publicAccessApplication); + StepVerifier.create(updatedApplication) + .assertNext(t -> { + assertThat(t).isNotNull(); + assertThat(t.getId()).isNotNull(); + assertThat(t.getIsPublic()).isTrue(); + }) + .verifyComplete(); + } + + /** + * Test case which proves the non-dependency of isPublic Field in Update Application API Response + * on the deprecated Application collection isPublic field for a public application + * The following steps are followed: + * 1. Create a new app + * 2. Invoke the changeViewAccess method to set the App "Public" + * 3. Invoke the update method and assert the "isPublic" field in the response + */ + @Test + @WithUserDetails(value = "api_user") + public void validPrivateAppUpdateApplication() { + Application application = new Application(); + application.setName("validPrivateAppUpdateApplication-Test"); + + Application createdApplication = applicationPageService.createApplication(application, workspaceId).block(); + + /** + * Making the App private using changeViewAccess method which changes the permission groups of the app to restrict public access + */ + ApplicationAccessDTO applicationAccessDTO = new ApplicationAccessDTO(); + applicationAccessDTO.setPublicAccess(false); + + Application privateAccessApplication = applicationService.changeViewAccess(createdApplication.getId(), applicationAccessDTO).block(); + + /** + * setIsPublic to True, purposely set to prove non-dependency on this field of the output + */ + privateAccessApplication.setIsPublic(true); + + /** + * Using the Update App method and asserting the response to verify the isPublic field in the response is False + * which proves it's non-dependency on the deprecated Application collection isPublic field + * and shows it dependency on the actual app permissions and state of the app which has been set private in this case + **/ + Mono updatedApplication = applicationService.update(createdApplication.getId(), privateAccessApplication); + StepVerifier.create(updatedApplication) + .assertNext(t -> { + assertThat(t).isNotNull(); + assertThat(t.getId()).isNotNull(); + assertThat(t.getIsPublic()).isFalse(); + }) + .verifyComplete(); + } }