use of uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate 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());
}
use of uk.gov.gchq.gaffer.federatedstore.access.predicate.FederatedGraphWriteAccessPredicate 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());
}
Aggregations