use of ddf.security.permission.impl.CollectionPermissionImpl in project ddf by codice.
the class CollectionPermissionTest method testModifyPermissionList.
/**
* Tests that the permission list that comes back cannot be modified.
*/
@Test(expected = UnsupportedOperationException.class)
public void testModifyPermissionList() {
ArrayList<KeyValuePermission> permissionList = new ArrayList<KeyValuePermission>();
permissionList.add(new KeyValuePermissionImpl("key1", Arrays.asList("val1")));
permissionList.add(new KeyValuePermissionImpl("key2", Arrays.asList("val2")));
CollectionPermission collection = new CollectionPermissionImpl("", permissionList);
collection.getPermissionList().clear();
fail("Returned list should not be able to modify.");
}
use of ddf.security.permission.impl.CollectionPermissionImpl in project ddf by codice.
the class CollectionPermissionTest method testGetPermissionList.
/**
* Tests that the permission list which comes back is the same as what was put in.
*/
@Test
public void testGetPermissionList() {
ArrayList<KeyValuePermission> permissionList = new ArrayList<KeyValuePermission>();
permissionList.add(new KeyValuePermissionImpl("key1", Arrays.asList("val1")));
permissionList.add(new KeyValuePermissionImpl("key2", Arrays.asList("val2")));
CollectionPermission collection = new CollectionPermissionImpl("", permissionList);
assertEquals(permissionList, collection.getPermissionList());
}
use of ddf.security.permission.impl.CollectionPermissionImpl in project ddf by codice.
the class AuthorizationFilterTest method getMockContextPolicy.
private ContextPolicy getMockContextPolicy() {
ContextPolicy contextPolicy = mock(ContextPolicy.class);
when(contextPolicy.getAuthenticationMethods()).thenReturn(Collections.singletonList("BASIC"));
when(contextPolicy.getAllowedAttributePermissions()).thenReturn(new CollectionPermissionImpl(PATH, new KeyValuePermissionImpl(PATH, Collections.singleton("permission"))));
when(contextPolicy.getContextPath()).thenReturn(PATH);
return contextPolicy;
}
Aggregations