use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.
the class FormConfig method fullRepresentation.
/**
* Return the full representation of the configuration with the configured form fields and meta data.
*/
public FormConfigFullRepresentation fullRepresentation(MetaStorage storage, Subject requestingUser) {
String ownerName = Optional.ofNullable(owner).map(User::getLabel).orElse(null);
/* Calculate which groups can see this query.
* This is usually not done very often and should be reasonable fast, so don't cache this.
*/
List<GroupId> permittedGroups = new ArrayList<>();
for (Group group : storage.getAllGroups()) {
for (Permission perm : group.getPermissions()) {
if (perm.implies(createPermission(Ability.READ.asSet()))) {
permittedGroups.add(group.getId());
continue;
}
}
}
return FormConfigFullRepresentation.builder().id(getId()).formType(formType).label(label).tags(tags).ownerName(ownerName).own(requestingUser.isOwner(this)).createdAt(getCreationTime().atZone(ZoneId.systemDefault())).shared(shared).groups(permittedGroups).values(values).build();
}
use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.
the class ManagedExecution method setAdditionalFieldsForStatusWithGroups.
private void setAdditionalFieldsForStatusWithGroups(@NonNull MetaStorage storage, FullExecutionStatus status) {
/* Calculate which groups can see this query.
* This usually is usually not done very often and should be reasonable fast, so don't cache this.
*/
List<GroupId> permittedGroups = new ArrayList<>();
for (Group group : storage.getAllGroups()) {
for (Permission perm : group.getPermissions()) {
if (perm.implies(createPermission(Ability.READ.asSet()))) {
permittedGroups.add(group.getId());
continue;
}
}
}
status.setGroups(permittedGroups);
}
use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.
the class IntrospectionDelegatingRealmTest method tokenIntrospectionGroupedUser.
@Test
public void tokenIntrospectionGroupedUser() {
STORAGE.addUser(USER_2);
AuthenticationInfo info = REALM.doGetAuthenticationInfo(USER_2_TOKEN_WRAPPED);
final ConqueryAuthenticationInfo expected = new ConqueryAuthenticationInfo(USER_2, USER_2_TOKEN_WRAPPED, REALM, true);
assertThat(info).usingRecursiveComparison().isEqualTo(expected);
assertThat(STORAGE.getAllUsers()).containsOnly(USER_2);
// Pre-existing group and a second group that has been added in the process
assertThat(STORAGE.getAllGroups()).hasSize(2);
assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_1)).getMembers()).contains(new UserId(USER_2_NAME));
assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_2)).getMembers()).contains(new UserId(USER_2_NAME));
}
use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.
the class SerializationTests method meInformation.
@Test
public void meInformation() throws IOException, JSONException {
User user = new User("name", "labe", STORAGE);
MeProcessor.FEMeInformation info = MeProcessor.FEMeInformation.builder().userName(user.getLabel()).hideLogoutButton(false).groups(List.of(new IdLabel<>(new GroupId("test_group"), "test_group_label"))).datasetAbilities(Map.of(new DatasetId("testdataset"), new MeProcessor.FEDatasetAbility(true))).build();
SerializationTestUtil.forType(MeProcessor.FEMeInformation.class).test(info);
}
use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.
the class IntrospectionDelegatingRealmTest method tokenIntrospectionGroupedUserRemoveGroupMapping.
@Test
public void tokenIntrospectionGroupedUserRemoveGroupMapping() {
STORAGE.addUser(USER_3);
GROUP_1_EXISTING.addMember(USER_3);
assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_1)).getMembers()).contains(new UserId(USER_3_NAME));
AuthenticationInfo info = REALM.doGetAuthenticationInfo(USER_3_TOKEN_WRAPPED);
assertThat(info).usingRecursiveComparison().ignoringFields(ConqueryAuthenticationInfo.Fields.credentials).isEqualTo(new ConqueryAuthenticationInfo(USER_3, USER_3_TOKEN_WRAPPED, REALM, true));
assertThat(STORAGE.getAllUsers()).containsOnly(USER_3);
// Pre-existing group
assertThat(STORAGE.getAllGroups()).hasSize(1);
assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_1)).getMembers()).doesNotContain(new UserId(USER_3_NAME));
}
Aggregations