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);
}
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);
}
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();
}
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);
}
}
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");
}
Aggregations