Search in sources :

Example 11 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedStoreTest method shouldAddGraphIdWithAuths.

@Test
public void shouldAddGraphIdWithAuths() throws Exception {
    // Given
    final Graph fedGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId(FEDERATED_STORE_ID).library(library).build()).addStoreProperties(federatedProperties).build();
    addGraphWithIds(ACC_ID_2, ID_PROPS_ACC_2, ID_SCHEMA_ENTITY);
    library.add(ACC_ID_2, getSchemaFromPath(PATH_BASIC_ENTITY_SCHEMA_JSON), PROPERTIES_ALT);
    // When
    int before = 0;
    for (String ignore : fedGraph.execute(new GetAllGraphIds(), blankUser)) {
        before++;
    }
    fedGraph.execute(new AddGraph.Builder().graphAuths("auth").graphId(ACC_ID_2).build(), blankUser);
    int after = 0;
    for (String ignore : fedGraph.execute(new GetAllGraphIds(), blankUser)) {
        after++;
    }
    fedGraph.execute(new AddElements.Builder().input(new Entity.Builder().group("BasicEntity").vertex("v1").build()).build(), blankUser);
    final CloseableIterable<? extends Element> elements = fedGraph.execute(new GetAllElements(), new User.Builder().userId(TEST_USER_ID + "Other").opAuth("auth").build());
    final CloseableIterable<? extends Element> elements2 = fedGraph.execute(new GetAllElements(), new User.Builder().userId(TEST_USER_ID + "Other").opAuths("x").build());
    assertEquals(0, Iterables.size(elements2));
    // Then
    assertEquals(0, before);
    assertEquals(1, after);
    assertNotNull(elements);
    assertTrue(elements.iterator().hasNext());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Builder(uk.gov.gchq.gaffer.store.schema.Schema.Builder) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) FederatedGetTraitsHandlerTest(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest) Test(org.junit.jupiter.api.Test)

Example 12 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldNotChangeGraphUserFromSomeoneElseToReplacementUserAsAdminWhenNotRequestingAdminAccess.

@Test
public void shouldNotChangeGraphUserFromSomeoneElseToReplacementUserAsAdminWhenNotRequestingAdminAccess() throws Exception {
    // given
    final String graphA = "graphA";
    final User replacementUser = new User("replacement");
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("Auths1").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), replacementUser))).doesNotContain(graphA);
    // when
    final Boolean changed = graph.execute(new ChangeGraphAccess.Builder().graphId(graphA).ownerUserId(replacementUser.getUserId()).build(), ADMIN_USER);
    // then
    assertThat(changed).isFalse();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), replacementUser))).doesNotContain(graphA);
}
Also used : User(uk.gov.gchq.gaffer.user.User) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Example 13 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldNotChangeGraphIdForNonOwnedGraphAsNonAdminWhenRequestingAdminAccess.

@Test
public void shouldNotChangeGraphIdForNonOwnedGraphAsNonAdminWhenRequestingAdminAccess() throws Exception {
    // given
    final String graphA = "graphA";
    final String graphB = "graphB";
    final User otherUser = new User("other");
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("Auths1").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), otherUser))).doesNotContain(graphA);
    // when
    final Boolean changed = graph.execute(new ChangeGraphId.Builder().graphId(graphA).newGraphId(graphB).option(FederatedStoreConstants.KEY_FEDERATION_ADMIN, "true").build(), otherUser);
    // then
    assertThat(changed).isFalse();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA).doesNotContain(graphB);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), otherUser))).doesNotContain(graphA, graphB);
}
Also used : ChangeGraphId(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId) User(uk.gov.gchq.gaffer.user.User) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Example 14 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldNotChangeGraphUserFromSomeoneElseToReplacementUserAsNonAdminWhenRequestingAdminAccess.

@Test
public void shouldNotChangeGraphUserFromSomeoneElseToReplacementUserAsNonAdminWhenRequestingAdminAccess() throws Exception {
    // given
    final String graphA = "graphA";
    final User replacementUser = new User("replacement");
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("Auths1").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), replacementUser))).doesNotContain(graphA);
    // when
    final Boolean changed = graph.execute(new ChangeGraphAccess.Builder().graphId(graphA).ownerUserId(replacementUser.getUserId()).option(FederatedStoreConstants.KEY_FEDERATION_ADMIN, "true").build(), replacementUser);
    // then
    assertThat(changed).isFalse();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), replacementUser))).doesNotContain(graphA);
}
Also used : User(uk.gov.gchq.gaffer.user.User) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) ChangeGraphAccess(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess) Test(org.junit.jupiter.api.Test)

Example 15 with GetAllGraphIds

use of uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds in project Gaffer by gchq.

the class FederatedAdminIT method shouldChangeGraphIdForNonOwnedGraphAsAdminWhenRequestingAdminAccess.

@Test
public void shouldChangeGraphIdForNonOwnedGraphAsAdminWhenRequestingAdminAccess() throws Exception {
    // given
    final String graphA = "graphA";
    final String graphB = "graphB";
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("Auths1").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    // when
    final Boolean changed = graph.execute(new ChangeGraphId.Builder().graphId(graphA).newGraphId(graphB).option(FederatedStoreConstants.KEY_FEDERATION_ADMIN, "true").build(), ADMIN_USER);
    // then
    assertThat(changed).isTrue();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).doesNotContain(graphA).contains(graphB);
}
Also used : ChangeGraphId(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Aggregations

GetAllGraphIds (uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds)20 Test (org.junit.jupiter.api.Test)15 Schema (uk.gov.gchq.gaffer.store.schema.Schema)15 User (uk.gov.gchq.gaffer.user.User)6 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)5 FederatedAccess (uk.gov.gchq.gaffer.federatedstore.FederatedAccess)3 FederatedStoreCache (uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache)3 RemoveGraph (uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph)3 Graph (uk.gov.gchq.gaffer.graph.Graph)3 ChangeGraphAccess (uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess)2 ChangeGraphId (uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId)2 GetAllGraphInfo (uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo)2 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)2 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)2 Connector (org.apache.accumulo.core.client.Connector)1 Test (org.junit.Test)1 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)1 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)1 Error (uk.gov.gchq.gaffer.core.exception.Error)1 Element (uk.gov.gchq.gaffer.data.element.Element)1