use of com.bakdata.conquery.models.identifiable.ids.specific.DatasetId 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.DatasetId in project conquery by bakdata.
the class InstancePermissionImplificationTest method testDivergingPrincipals.
@Test
public void testDivergingPrincipals() {
// Test different user principals
Permission pStored = DatasetPermission.onInstance(Ability.READ.asSet(), new DatasetId(DATASET1));
Permission pRequested = DatasetPermission.onInstance(Ability.READ.asSet(), new DatasetId(DATASET1));
assert pStored.implies(pRequested);
}
use of com.bakdata.conquery.models.identifiable.ids.specific.DatasetId in project conquery by bakdata.
the class RoleHandlingOnGroupTest method execute.
@Override
public void execute(StandaloneSupport conquery) throws Exception {
Dataset dataset1 = new Dataset();
dataset1.setLabel("dataset1");
MetaStorage storage = conquery.getMetaStorage();
Group group1 = new Group("company", "company", storage);
Role role = new Role("role1", "role1", storage);
TestUser user1 = new TestUser(storage);
try {
storage.addRole(role);
storage.addUser(user1);
storage.addGroup(group1);
role.addPermission(new DatasetPermission().instancePermission(Ability.READ, new DatasetId("testDataset")));
// // Add user to group
group1.addMember(user1);
assertThat(user1.isPermitted(new DatasetPermission().instancePermission(Ability.READ, new DatasetId("testDataset")))).isFalse();
// // Add role to group
group1.addRole(role);
assertThat(group1.getRoles()).containsExactlyInAnyOrder(role.getId());
assertThat(user1.isPermitted(new DatasetPermission().instancePermission(Ability.READ, new DatasetId("testDataset")))).isTrue();
// // Remove role from group
group1.removeRole(role);
assertThat(group1.getRoles()).isEmpty();
assertThat(user1.isPermitted(new DatasetPermission().instancePermission(Ability.READ, new DatasetId("testDataset")))).isFalse();
} finally {
storage.removeGroup(group1.getId());
storage.removeUser(user1.getId());
storage.removeRole(role.getId());
}
}
use of com.bakdata.conquery.models.identifiable.ids.specific.DatasetId in project conquery by bakdata.
the class PermissionCreationTest method createPermissionIllegalAbility.
@Test
public void createPermissionIllegalAbility() {
Permission perm = null;
try {
// This should fail because the ability is not allowed for a DatasetPermission
perm = DatasetPermission.onInstance(Ability.SHARE.asSet(), new DatasetId("test"));
} catch (Exception e) {
assertThat(e).isInstanceOf(IllegalArgumentException.class);
}
// Should not be reached
assertThat(perm).isNull();
}
use of com.bakdata.conquery.models.identifiable.ids.specific.DatasetId in project conquery by bakdata.
the class IdMapTest method generalTest.
@Test
public void generalTest() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException, JSONException {
Dataset d1 = new Dataset();
d1.setName("d1");
Dataset d2 = new Dataset();
d2.setName("d2");
IdMap<DatasetId, Dataset> idMap = new IdMap<DatasetId, Dataset>();
idMap.add(d1);
idMap.add(d2);
ContainingDataset containedDataset = new ContainingDataset(idMap);
JsonNode json = Jackson.MAPPER.valueToTree(containedDataset);
/*assertThat(json.isArray()).isTrue();
assertThat(json.get(0)).isEqualTo(Jackson.MAPPER.valueToTree(d1));*/
ContainingDataset constructed = Jackson.MAPPER.treeToValue(json, ContainingDataset.class);
assertThat(constructed.idMap.entrySet()).isEqualTo(containedDataset.idMap.entrySet());
}
Aggregations