Search in sources :

Example 26 with NamedOperationDetail

use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.

the class NamedOperationCacheTest method shouldNotReturnNamedOperationConfiguredWithReadNoAccessPredicate.

@Test
public void shouldNotReturnNamedOperationConfiguredWithReadNoAccessPredicate() throws CacheOperationFailedException {
    final NamedOperationDetail noReadAccess = new NamedOperationDetail.Builder().creatorId(standardUser.getUserId()).description("an operation that does no allow read access").operationName("test").writers(writers).operationChain(standardOpChain).readAccessPredicate(new NoAccessPredicate()).build();
    cache.addNamedOperation(noReadAccess, false, standardUser);
    assertFalse(cache.getAllNamedOperations(standardUser).iterator().hasNext());
}
Also used : NoAccessPredicate(uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate) NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) Test(org.junit.jupiter.api.Test)

Example 27 with NamedOperationDetail

use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.

the class NamedOperationCacheTest method shouldAddNamedOperation.

@Test
public void shouldAddNamedOperation() throws CacheOperationFailedException {
    cache.addNamedOperation(standard, false, standardUser);
    NamedOperationDetail namedOperation = cache.getNamedOperation(OPERATION_NAME, standardUser);
    assertEquals(standard, namedOperation);
}
Also used : NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) Test(org.junit.jupiter.api.Test)

Example 28 with NamedOperationDetail

use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.

the class NamedOperationCacheTest method shouldBeAbleToReturnFullExtendedOperationChain.

@Test
public void shouldBeAbleToReturnFullExtendedOperationChain() throws CacheOperationFailedException {
    cache.addNamedOperation(standard, false, standardUser);
    NamedOperationDetail alt = new NamedOperationDetail.Builder().operationName("different").description("alt").creatorId(advancedUser.getUserId()).readers(readers).writers(writers).operationChain(alternativeOpChain).build();
    cache.addNamedOperation(alt, false, advancedUser);
    Set<NamedOperationDetail> actual = Sets.newHashSet(cache.getAllNamedOperations(standardUser));
    assert (actual.contains(standard));
    assert (actual.contains(alt));
    assert (actual.size() == 2);
}
Also used : NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) Test(org.junit.jupiter.api.Test)

Example 29 with NamedOperationDetail

use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.

the class NamedOperationCacheTest method shouldAllowAddingWhenUserHasAdminAuth.

@Test
public void shouldAllowAddingWhenUserHasAdminAuth() throws CacheOperationFailedException {
    cache.addNamedOperation(alternative, false, advancedUser, EMPTY_ADMIN_AUTH);
    NamedOperationDetail alt = new NamedOperationDetail.Builder().operationName(alternative.getOperationName()).description("alt").creatorId(standardUser.getUserId()).operationChain(alternativeOpChain).build();
    cache.addNamedOperation(alt, true, userWithAdminAuth, ADMIN_AUTH);
}
Also used : NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) Test(org.junit.jupiter.api.Test)

Example 30 with NamedOperationDetail

use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.

the class NamedOperationCacheTest method shouldNotReturnANamedOperationThatAUserCannotExecute.

@Test
public void shouldNotReturnANamedOperationThatAUserCannotExecute() throws CacheOperationFailedException {
    cache.addNamedOperation(standard, false, standardUser);
    NamedOperationDetail noReadAccess = new NamedOperationDetail.Builder().creatorId(advancedUser.getUserId()).description("an operation that a standard user cannot execute").operationName("test").readers(writers).writers(writers).operationChain(standardOpChain).build();
    cache.addNamedOperation(noReadAccess, false, advancedUser);
    Set<NamedOperationDetail> actual = Sets.newHashSet(cache.getAllNamedOperations(standardUser));
    assert actual.contains(standard);
    assert actual.size() == 1;
}
Also used : NamedOperationDetail(uk.gov.gchq.gaffer.named.operation.NamedOperationDetail) Test(org.junit.jupiter.api.Test)

Aggregations

NamedOperationDetail (uk.gov.gchq.gaffer.named.operation.NamedOperationDetail)40 Test (org.junit.jupiter.api.Test)27 User (uk.gov.gchq.gaffer.user.User)11 GetAllNamedOperations (uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations)10 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)10 NamedOperationCache (uk.gov.gchq.gaffer.store.operation.handler.named.cache.NamedOperationCache)10 AddNamedOperation (uk.gov.gchq.gaffer.named.operation.AddNamedOperation)9 Context (uk.gov.gchq.gaffer.store.Context)9 CacheOperationFailedException (uk.gov.gchq.gaffer.named.operation.cache.exception.CacheOperationFailedException)7 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)7 ParameterDetail (uk.gov.gchq.gaffer.named.operation.ParameterDetail)5 ArrayList (java.util.ArrayList)4 Element (uk.gov.gchq.gaffer.data.element.Element)4 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)4 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)4 Store (uk.gov.gchq.gaffer.store.Store)4 GetAdjacentIds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds)3 AddNamedOperationHandler (uk.gov.gchq.gaffer.store.operation.handler.named.AddNamedOperationHandler)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2