mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-01 05:03:10 +00:00
parent
1e31245bbe
commit
16e8778993
@ -286,6 +286,11 @@ public class UserRepository extends EntityRepository<User> {
|
|||||||
}
|
}
|
||||||
addRelationship(team.getId(), user.getId(), Entity.TEAM, Entity.USER, Relationship.HAS);
|
addRelationship(team.getId(), user.getId(), Entity.TEAM, Entity.USER, Relationship.HAS);
|
||||||
}
|
}
|
||||||
|
if (teams.size() > 1) {
|
||||||
|
// Remove organization team from the response
|
||||||
|
teams = teams.stream().filter(t -> !t.getId().equals(organization.getId())).collect(Collectors.toList());
|
||||||
|
user.setTeams(teams);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handles entity updated from PUT and POST operation. */
|
/** Handles entity updated from PUT and POST operation. */
|
||||||
|
@ -64,6 +64,7 @@ import java.util.Map;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.client.HttpResponseException;
|
import org.apache.http.client.HttpResponseException;
|
||||||
@ -519,6 +520,28 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
|||||||
assertEquals(newDisplayName, user.getDisplayName());
|
assertEquals(newDisplayName, user.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void patch_teamAddition_200_ok(TestInfo test) throws HttpResponseException, JsonProcessingException {
|
||||||
|
TeamResourceTest teamResourceTest = new TeamResourceTest();
|
||||||
|
EntityReference team1 =
|
||||||
|
teamResourceTest.createEntity(teamResourceTest.createRequest(test, 1), ADMIN_AUTH_HEADERS).getEntityReference();
|
||||||
|
User user =
|
||||||
|
createEntity(
|
||||||
|
createRequest(test, 10)
|
||||||
|
.withName("testUser1")
|
||||||
|
.withDisplayName("displayName")
|
||||||
|
.withEmail("testUser1@email.com"),
|
||||||
|
authHeaders("test1@email.com"));
|
||||||
|
String userJson = JsonUtils.pojoToJson(user);
|
||||||
|
List<EntityReference> teams = user.getTeams();
|
||||||
|
teams.add(team1);
|
||||||
|
user.setTeams(teams); // Update the teams
|
||||||
|
user = patchEntity(user.getId(), userJson, user, ADMIN_AUTH_HEADERS); // Patch the user
|
||||||
|
// Ensure default "Organization" team is not part of the patch response
|
||||||
|
assertEquals(1, user.getTeams().size());
|
||||||
|
assertEquals(team1.getId(), user.getTeams().get(0).getId());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void patch_userAttributes_as_admin_200_ok(TestInfo test) throws IOException {
|
void patch_userAttributes_as_admin_200_ok(TestInfo test) throws IOException {
|
||||||
// Create user without any attributes - ***Note*** isAdmin by default is false.
|
// Create user without any attributes - ***Note*** isAdmin by default is false.
|
||||||
@ -793,6 +816,10 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
|||||||
}
|
}
|
||||||
if (expectedTeams.isEmpty()) {
|
if (expectedTeams.isEmpty()) {
|
||||||
expectedTeams = new ArrayList<>(List.of(ORG_TEAM.getEntityReference())); // Organization is default team
|
expectedTeams = new ArrayList<>(List.of(ORG_TEAM.getEntityReference())); // Organization is default team
|
||||||
|
} else {
|
||||||
|
// Remove ORG_TEAM from the expected teams
|
||||||
|
expectedTeams =
|
||||||
|
expectedTeams.stream().filter(t -> !t.getId().equals(ORG_TEAM.getId())).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
assertEntityReferences(expectedTeams, user.getTeams());
|
assertEntityReferences(expectedTeams, user.getTeams());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user