1. Fixed the bug where policies are being set to empty during organization update (#415)

1. Fixed the bug where policies are being set to empty during organization update.
2. Added email field in organization.

* Updated the test case for update organization to assert the organization policies being present post the update.
This commit is contained in:
Trisha Anand 2020-08-25 08:13:37 +05:30 committed by GitHub
parent ce41fec346
commit c253b7430b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,8 @@ public class Organization extends BaseDomain {
private String website;
private String email;
private List<OrganizationSetting> organizationSettings;
private List<OrganizationPlugin> plugins;

View File

@ -119,6 +119,9 @@ public abstract class BaseAppsmithRepositoryImpl<T extends BaseDomain> {
Query query = new Query(Criteria.where("id").is(id));
query.addCriteria(new Criteria().andOperator(notDeleted(), userAcl(user, permission)));
// Set policies to null in the update object
resource.setPolicies(null);
DBObject update = getDbObject(resource);
Update updateObj = new Update();
Map<String, Object> updateMap = update.toMap();

View File

@ -179,6 +179,14 @@ public class OrganizationServiceTest {
@Test
@WithUserDetails(value = "api_user")
public void validUpdateOrganization() {
Policy manageOrgAppPolicy = Policy.builder().permission(ORGANIZATION_MANAGE_APPLICATIONS.getValue())
.users(Set.of("api_user"))
.build();
Policy manageOrgPolicy = Policy.builder().permission(MANAGE_ORGANIZATIONS.getValue())
.users(Set.of("api_user"))
.build();
Organization organization = new Organization();
organization.setName("Test Update Name");
organization.setDomain("example.com");
@ -200,6 +208,7 @@ public class OrganizationServiceTest {
assertThat(t.getName()).isEqualTo(organization.getName());
assertThat(t.getId()).isEqualTo(organization.getId());
assertThat(t.getDomain()).isEqualTo("abc.com");
assertThat(t.getPolicies()).contains(manageOrgAppPolicy, manageOrgPolicy);
})
.verifyComplete();
}