Search in sources :

Example 6 with GetAllGraphIds

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

the class FederatedAdminIT method shouldGetAllGraphInfoForAdmin.

@Test
public void shouldGetAllGraphInfoForAdmin() throws Exception {
    // given
    final String graphA = "graphA";
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).graphAuths("authsValueA").build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    final FederatedAccess expectedFedAccess = new FederatedAccess.Builder().addingUserId(user.getUserId()).graphAuths("authsValueA").makePrivate().build();
    // when
    final Map<String, Object> allGraphsAndAuths = graph.execute(new GetAllGraphInfo.Builder().option(FederatedStoreConstants.KEY_FEDERATION_ADMIN, "true").build(), ADMIN_USER);
    // then
    assertThat(allGraphsAndAuths).hasSize(1);
    assertThat(allGraphsAndAuths.keySet().toArray(new String[] {})[0]).isEqualTo(graphA);
    assertThat(allGraphsAndAuths.values().toArray(new Object[] {})[0]).isEqualTo(expectedFedAccess);
}
Also used : GetAllGraphInfo(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) FederatedAccess(uk.gov.gchq.gaffer.federatedstore.FederatedAccess) Test(org.junit.jupiter.api.Test)

Example 7 with GetAllGraphIds

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

the class FederatedAdminIT method shouldNotChangeGraphIdForNonOwnedGraphAsAdminWhenNotRequestingAdminAccess.

@Test
public void shouldNotChangeGraphIdForNonOwnedGraphAsAdminWhenNotRequestingAdminAccess() 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).build(), ADMIN_USER);
    // then
    assertThat(changed).isFalse();
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA).doesNotContain(graphB);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) Test(org.junit.jupiter.api.Test)

Example 8 with GetAllGraphIds

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

the class FederatedAdminIT method shouldRemoveGraphFromCache.

@Test
public void shouldRemoveGraphFromCache() throws Exception {
    // given
    FederatedStoreCache federatedStoreCache = new FederatedStoreCache();
    final String graphA = "graphA";
    graph.execute(new AddGraph.Builder().graphId(graphA).schema(new Schema()).storeProperties(ACCUMULO_PROPERTIES).build(), user);
    assertThat(Lists.newArrayList(graph.execute(new GetAllGraphIds(), user))).contains(graphA);
    // when
    assertThat(federatedStoreCache.getGraphSerialisableFromCache(graphA)).isNotNull();
    final Boolean removed = graph.execute(new RemoveGraph.Builder().graphId(graphA).build(), user);
    // then
    assertThat(removed).isTrue();
    GraphSerialisable graphSerialisableFromCache = federatedStoreCache.getGraphSerialisableFromCache(graphA);
    assertThat(graphSerialisableFromCache).as(new String(JSONSerialiser.serialise(graphSerialisableFromCache, true))).isNull();
    assertThat(federatedStoreCache.getAllGraphIds()).isEmpty();
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) FederatedStoreCache(uk.gov.gchq.gaffer.federatedstore.FederatedStoreCache) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) Test(org.junit.jupiter.api.Test)

Example 9 with GetAllGraphIds

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

the class FederatedStoreRecursionIT method testInnerGetGraphIds.

protected void testInnerGetGraphIds(final String... ids) throws OperationException {
    ArrayList<? extends String> list = Lists.newArrayList(proxyToRestServiceFederatedGraph.execute(new FederatedOperationChain.Builder<Object, String>().operationChain(OperationChain.wrap(new GetAllGraphIds())).build(), user));
    assertThat(list).hasSameSizeAs(ids);
    for (String id : ids) {
        Assertions.<String>assertThat(list).as(list.toString()).contains(id);
    }
}
Also used : GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds)

Example 10 with GetAllGraphIds

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

the class FederatedStoreGraphVisibilityTest method commonAssertions.

private void commonAssertions() throws uk.gov.gchq.gaffer.operation.OperationException {
    Iterable<? extends String> graphIds = fedGraph.execute(new GetAllGraphIds(), nonAddingUser);
    final HashSet<Object> sets = Sets.newHashSet();
    Iterator<? extends String> iterator = graphIds.iterator();
    while (iterator.hasNext()) {
        sets.add(iterator.next());
    }
    assertNotNull(graphIds, "Returned iterator should not be null, it should be empty.");
    assertEquals(0, sets.size(), "Showing hidden graphId");
    graphIds = fedGraph.execute(new GetAllGraphIds(), authNonAddingUser);
    iterator = graphIds.iterator();
    sets.clear();
    while (iterator.hasNext()) {
        sets.add(iterator.next());
    }
    assertNotNull(graphIds, "Returned iterator should not be null, it should be empty.");
    assertEquals(1, sets.size(), "Not Showing graphId with correct auth");
    assertThat(sets).contains("g2");
    graphIds = fedGraph.execute(new GetAllGraphIds(), addingUser);
    iterator = graphIds.iterator();
    sets.clear();
    while (iterator.hasNext()) {
        sets.add(iterator.next());
    }
    assertNotNull(graphIds, "Returned iterator should not be null, it should be empty.");
    assertEquals(2, sets.size(), "Not Showing all graphId for adding user");
    assertThat(sets).contains("g1", "g2");
}
Also used : GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds)

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