Search in sources :

Example 21 with DatasetId

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);
}
Also used : IdLabel(com.bakdata.conquery.apiv1.IdLabel) User(com.bakdata.conquery.models.auth.entities.User) MeProcessor(com.bakdata.conquery.apiv1.MeProcessor) GroupId(com.bakdata.conquery.models.identifiable.ids.specific.GroupId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 22 with DatasetId

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);
}
Also used : SuperPermission(com.bakdata.conquery.models.auth.permissions.SuperPermission) DatasetPermission(com.bakdata.conquery.models.auth.permissions.DatasetPermission) ExecutionPermission(com.bakdata.conquery.models.auth.permissions.ExecutionPermission) Permission(org.apache.shiro.authz.Permission) AdminPermission(com.bakdata.conquery.models.auth.permissions.AdminPermission) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test)

Example 23 with DatasetId

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());
    }
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) Group(com.bakdata.conquery.models.auth.entities.Group) DatasetPermission(com.bakdata.conquery.models.auth.permissions.DatasetPermission) Dataset(com.bakdata.conquery.models.datasets.Dataset) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)

Example 24 with DatasetId

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();
}
Also used : DatasetPermission(com.bakdata.conquery.models.auth.permissions.DatasetPermission) Permission(org.apache.shiro.authz.Permission) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test)

Example 25 with DatasetId

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());
}
Also used : Dataset(com.bakdata.conquery.models.datasets.Dataset) JsonNode(com.fasterxml.jackson.databind.JsonNode) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test)

Aggregations

DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)31 Test (org.junit.jupiter.api.Test)18 DatasetPermission (com.bakdata.conquery.models.auth.permissions.DatasetPermission)9 Permission (org.apache.shiro.authz.Permission)8 User (com.bakdata.conquery.models.auth.entities.User)7 AdminPermission (com.bakdata.conquery.models.auth.permissions.AdminPermission)7 ExecutionPermission (com.bakdata.conquery.models.auth.permissions.ExecutionPermission)7 SuperPermission (com.bakdata.conquery.models.auth.permissions.SuperPermission)7 ConqueryTestSpec (com.bakdata.conquery.integration.json.ConqueryTestSpec)6 Role (com.bakdata.conquery.models.auth.entities.Role)6 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)5 Dataset (com.bakdata.conquery.models.datasets.Dataset)5 Group (com.bakdata.conquery.models.auth.entities.Group)4 ConceptId (com.bakdata.conquery.models.identifiable.ids.specific.ConceptId)4 ConceptTreeChildId (com.bakdata.conquery.models.identifiable.ids.specific.ConceptTreeChildId)4 DatasetRegistry (com.bakdata.conquery.models.worker.DatasetRegistry)4 ConceptsProcessor (com.bakdata.conquery.resources.api.ConceptsProcessor)4 ResolvedConceptsResult (com.bakdata.conquery.resources.api.ConceptsProcessor.ResolvedConceptsResult)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 FilterTemplate (com.bakdata.conquery.apiv1.FilterTemplate)3