mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 17:04:54 +00:00
This commit is contained in:
parent
535f4b4f4f
commit
f463cf48c0
@ -50,8 +50,8 @@ import org.openmetadata.catalog.util.JsonUtils;
|
||||
|
||||
@Slf4j
|
||||
public class TeamRepository extends EntityRepository<Team> {
|
||||
static final String TEAM_UPDATE_FIELDS = "owner,profile,users,defaultRoles,parents,children,policies";
|
||||
static final String TEAM_PATCH_FIELDS = "owner,profile,users,defaultRoles,parents,children,policies";
|
||||
static final String TEAM_UPDATE_FIELDS = "owner,profile,users,defaultRoles,parents,children,policies,teamType";
|
||||
static final String TEAM_PATCH_FIELDS = "owner,profile,users,defaultRoles,parents,children,policies,teamType";
|
||||
private Team organization = null;
|
||||
|
||||
public TeamRepository(CollectionDAO dao) {
|
||||
@ -365,6 +365,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
||||
public void entitySpecificUpdate() throws IOException {
|
||||
recordChange("profile", original.getProfile(), updated.getProfile());
|
||||
recordChange("isJoinable", original.getIsJoinable(), updated.getIsJoinable());
|
||||
recordChange("teamType", original.getTeamType(), updated.getTeamType());
|
||||
updateUsers(original, updated);
|
||||
updateDefaultRoles(original, updated);
|
||||
updateParents(original, updated);
|
||||
|
@ -219,9 +219,9 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
||||
|
||||
@Test
|
||||
void patch_teamAttributes_as_non_admin_403(TestInfo test) throws HttpResponseException, JsonProcessingException {
|
||||
// Create table without any attributes
|
||||
// Create team without any attributes
|
||||
Team team = createEntity(createRequest(test), ADMIN_AUTH_HEADERS);
|
||||
// Patching as a non-admin should is disallowed
|
||||
// Patching as a non-admin should be disallowed
|
||||
String originalJson = JsonUtils.pojoToJson(team);
|
||||
team.setDisplayName("newDisplayName");
|
||||
assertResponse(
|
||||
@ -230,6 +230,20 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
||||
permissionNotAllowed(TEST_USER_NAME, List.of(MetadataOperation.EDIT_DISPLAY_NAME)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void patch_teamType_as_user_with_UpdateTeam_permission(TestInfo test) throws IOException {
|
||||
Team team = createEntity(createRequest(test).withTeamType(BUSINESS_UNIT), ADMIN_AUTH_HEADERS);
|
||||
String originalJson = JsonUtils.pojoToJson(team);
|
||||
team.setTeamType(DIVISION);
|
||||
|
||||
ChangeDescription change = getChangeDescription(team.getVersion());
|
||||
fieldUpdated(change, "teamType", BUSINESS_UNIT.toString(), DIVISION.toString());
|
||||
patchEntityAndCheck(team, originalJson, ADMIN_AUTH_HEADERS, MINOR_UPDATE, change);
|
||||
|
||||
team = getEntity(team.getId(), ADMIN_AUTH_HEADERS);
|
||||
assertEquals(DIVISION, team.getTeamType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void patch_teamUsers_as_user_with_UpdateTeam_permission(TestInfo test) throws IOException {
|
||||
UserResourceTest userResourceTest = new UserResourceTest();
|
||||
@ -623,7 +637,7 @@ public class TeamResourceTest extends EntityResourceTest<Team, CreateTeam> {
|
||||
|
||||
@Override
|
||||
public CreateTeam createRequest(String name) {
|
||||
return new CreateTeam().withName(name).withProfile(PROFILE);
|
||||
return new CreateTeam().withName(name).withProfile(PROFILE).withTeamType(GROUP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user