Search in sources :

Example 21 with AccessPredicate

use of uk.gov.gchq.gaffer.access.predicate.AccessPredicate in project Gaffer by gchq.

the class FederatedRemoveGraphHandlerTest method shouldNotRemoveGraphConfiguredWithNoAccessWritePredicate.

@Test
public void shouldNotRemoveGraphConfiguredWithNoAccessWritePredicate() throws Exception {
    FederatedStore store = new FederatedStore();
    final FederatedStoreProperties federatedStoreProperties = new FederatedStoreProperties();
    federatedStoreProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    final AccessPredicate noAccessPredicate = new NoAccessPredicate();
    store.addGraphs(testUser.getOpAuths(), "other", false, false, null, noAccessPredicate, new GraphSerialisable.Builder().config(new GraphConfig(EXPECTED_GRAPH_ID)).schema(new Schema.Builder().build()).properties(PROPERTIES).build());
    assertEquals(1, store.getGraphs(testUser, null, ignore).size());
    new FederatedRemoveGraphHandler().doOperation(new RemoveGraph.Builder().graphId(EXPECTED_GRAPH_ID).build(), new Context(testUser), store);
    Collection<Graph> graphs = store.getGraphs(testUser, null, ignore);
    assertThat(graphs).hasSize(1);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) FederatedStoreProperties(uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 22 with AccessPredicate

use of uk.gov.gchq.gaffer.access.predicate.AccessPredicate in project Gaffer by gchq.

the class FederatedAddGraphWithHooksHandlerTest method shouldAddGraphWithCustomReadAccessPredicate.

@Test
public void shouldAddGraphWithCustomReadAccessPredicate() throws Exception {
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    final Schema expectedSchema = new Schema.Builder().build();
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    final AccessPredicate allowBlankUserAndTestUserReadAccess = new AccessPredicate(new AdaptedPredicate(new CallMethod("getUserId"), new Or<>(new IsEqual(testUser.getUserId()), new IsEqual(blankUser.getUserId()))));
    new FederatedAddGraphWithHooksHandler().doOperation(new AddGraphWithHooks.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).readAccessPredicate(allowBlankUserAndTestUserReadAccess).build(), new Context(testUser), store);
    assertEquals(1, store.getGraphs(blankUser, null, ignore).size());
    assertEquals(1, store.getGraphs(testUser, null, ignore).size());
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Or(uk.gov.gchq.koryphe.impl.predicate.Or) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AdaptedPredicate(uk.gov.gchq.koryphe.predicate.AdaptedPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) CallMethod(uk.gov.gchq.koryphe.impl.function.CallMethod) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)22 AccessPredicate (uk.gov.gchq.gaffer.access.predicate.AccessPredicate)22 CustomUserPredicate (uk.gov.gchq.gaffer.access.predicate.user.CustomUserPredicate)7 UnrestrictedAccessPredicate (uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate)4 NamedViewWriteAccessPredicate (uk.gov.gchq.gaffer.data.elementdefinition.view.access.predicate.NamedViewWriteAccessPredicate)4 CallMethod (uk.gov.gchq.koryphe.impl.function.CallMethod)4 AdaptedPredicate (uk.gov.gchq.koryphe.predicate.AdaptedPredicate)4 NoAccessPredicate (uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate)3 FederatedGraphReadAccessPredicate (uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate)3 FederatedGraphWriteAccessPredicate (uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate)3 Context (uk.gov.gchq.gaffer.store.Context)3 Schema (uk.gov.gchq.gaffer.store.schema.Schema)3 User (uk.gov.gchq.gaffer.user.User)3 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)3 AccessPredicateTest (uk.gov.gchq.gaffer.access.predicate.AccessPredicateTest)2 NamedViewDetail (uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail)2 NamedOperationDetail (uk.gov.gchq.gaffer.named.operation.NamedOperationDetail)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)2 CollectionContains (uk.gov.gchq.koryphe.impl.predicate.CollectionContains)2