fix: Updated isPublic field to fetch from Permission groups (#19132)
## Description
> Fixes the `isPublic` field in the update application API
`/applications/{applicationId} (PUT)` response.
Fixes #19131
### Media
https://user-images.githubusercontent.com/25542733/209096894-2d88d20d-6636-4d8a-9bf0-7a04a95f75dd.mov
## Type of change
- Bug fix (non-breaking change which fixes an issue)
## How Has This Been Tested?
- Manual
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
This commit is contained in:
parent
b2f9e35122
commit
f70987c52f
|
|
@ -281,6 +281,7 @@ public class ApplicationServiceCEImpl extends BaseService<ApplicationRepository,
|
|||
}
|
||||
return Mono.error(error);
|
||||
})
|
||||
.flatMap(application1 -> this.setTransientFields(application1))
|
||||
.flatMap(application1 -> {
|
||||
final Map<String, Object> eventData = Map.of(
|
||||
FieldName.APP_MODE, ApplicationMode.EDIT.toString(),
|
||||
|
|
|
|||
|
|
@ -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<Application> 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<Application> updatedApplication = applicationService.update(createdApplication.getId(), privateAccessApplication);
|
||||
StepVerifier.create(updatedApplication)
|
||||
.assertNext(t -> {
|
||||
assertThat(t).isNotNull();
|
||||
assertThat(t.getId()).isNotNull();
|
||||
assertThat(t.getIsPublic()).isFalse();
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user