Search in sources :

Example 1 with FederatedGraphReadAccessPredicate

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

the class FederatedAccessResourceAccessPredicateTest method shouldConfigureDefaultFederatedGraphAccessPredicatesWhenNoAccessPredicateConfigurationSupplied.

@Test
public void shouldConfigureDefaultFederatedGraphAccessPredicatesWhenNoAccessPredicateConfigurationSupplied() {
    final FederatedAccess access = new FederatedAccess.Builder().addingUserId(testUser.getUserId()).graphAuths(ALL_USERS).build();
    final AccessPredicate expectedNonPublicReadAccessPredicate = new FederatedGraphReadAccessPredicate(testUser.getUserId(), asList(ALL_USERS), false);
    final AccessPredicate expectedWriteAccessPredicate = new FederatedGraphWriteAccessPredicate(testUser.getUserId());
    assertEquals(expectedNonPublicReadAccessPredicate, access.getOrDefaultReadAccessPredicate());
    assertEquals(expectedWriteAccessPredicate, access.getOrDefaultWriteAccessPredicate());
    final FederatedAccess publicAccess = new FederatedAccess.Builder().addingUserId(testUser.getUserId()).graphAuths(ALL_USERS).makePublic().build();
    final AccessPredicate expectedPublicReadAccessPredicate = new FederatedGraphReadAccessPredicate(testUser.getUserId(), asList(ALL_USERS), true);
    assertEquals(expectedPublicReadAccessPredicate, publicAccess.getOrDefaultReadAccessPredicate());
    assertEquals(expectedWriteAccessPredicate, publicAccess.getOrDefaultWriteAccessPredicate());
}
Also used : FederatedGraphWriteAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate) FederatedGraphReadAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate) FederatedGraphWriteAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate) NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) FederatedGraphReadAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate) Test(org.junit.jupiter.api.Test)

Example 2 with FederatedGraphReadAccessPredicate

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

the class FederatedAccessAuthTest method shouldDeserialiseDefaultPredicateIfNotSpecified.

@Test
public void shouldDeserialiseDefaultPredicateIfNotSpecified() throws SerialisationException {
    // Given
    String json = "{" + "   \"addingUserId\": \"authUser\"," + "   \"public\": true," + "   \"graphAuths\": [ \"auth1\", \"auth2\" ]" + "}";
    // When
    FederatedAccess deserialised = JSONSerialiser.deserialise(json, FederatedAccess.class);
    // Then
    FederatedGraphReadAccessPredicate expectedReadPredicate = new FederatedGraphReadAccessPredicate(AUTH_USER_ID, Sets.newHashSet(AUTH_1, AUTH_2), true);
    FederatedGraphWriteAccessPredicate expectedWritePredicate = new FederatedGraphWriteAccessPredicate(AUTH_USER_ID);
    assertEquals(expectedReadPredicate, deserialised.getOrDefaultReadAccessPredicate());
    assertEquals(expectedWritePredicate, deserialised.getOrDefaultWriteAccessPredicate());
}
Also used : FederatedGraphWriteAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate) FederatedGraphReadAccessPredicate(uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 FederatedGraphReadAccessPredicate (uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphReadAccessPredicate)2 FederatedGraphWriteAccessPredicate (uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate)2 AccessPredicate (uk.gov.gchq.gaffer.access.predicate.AccessPredicate)1 NoAccessPredicate (uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate)1