use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class OpenSSOApplicationPrivilegeManager method search.
@Override
public Set<String> search(Set<SearchFilter> filters) {
Set<String> names = new HashSet<String>();
Set<String> allNames = delegatables.getPrivilegeNames();
if ((filters == null) || filters.isEmpty()) {
names.addAll(allNames);
} else {
for (String name : allNames) {
Privilege p = delegatables.getPrivilege(name);
if (matchFilter(p, filters)) {
names.add(name);
}
}
}
return names;
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class PolicyResourceTest method shouldReportCreatePolicyStoreErrors.
@Test
public void shouldReportCreatePolicyStoreErrors() throws Exception {
// Given
String id = "uniqueId";
JsonValue json = new JsonValue("");
CreateRequest request = mockCreateRequest(id, json);
Privilege policy = mockPrivilege(id, 123l);
given(mockParser.parsePolicy(id, json)).willReturn(policy);
willThrow(new EntitlementException(EntitlementException.INVALID_APPLICATION_CLASS)).given(mockStore).create(policy);
// When
Promise<ResourceResponse, ResourceException> promise = policyResource.createInstance(mockServerContext, request);
// Then
assertThat(promise).failedWithException().isInstanceOf(InternalServerErrorException.class);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class PolicyResourceTest method shouldHandleQueryRequests.
@Test
public void shouldHandleQueryRequests() throws Exception {
// Given
QueryRequest request = mock(QueryRequest.class);
QueryResourceHandler handler = mock(QueryResourceHandler.class);
List<Privilege> policies = Arrays.<Privilege>asList(new StubPrivilege("one"), new StubPrivilege("two"));
given(mockStore.query(request)).willReturn(policies);
given(handler.handleResource(any(ResourceResponse.class))).willReturn(true);
// When
policyResource.queryCollection(mockServerContext, request, handler);
// Then
verify(handler, times(policies.size())).handleResource(any(ResourceResponse.class));
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldUseJsonNameFirst.
@Test
public void shouldUseJsonNameFirst() throws Exception {
// Given
String name = "realName";
JsonValue content = buildJson(field("name", name));
// When
Privilege result = parser.parsePolicy("resourceName", content);
// Then
assertThat(result.getName()).isEqualTo(name);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldNotPrintPolicyTTL.
@Test
public void shouldNotPrintPolicyTTL() throws Exception {
// Given
Privilege policy = new StubPrivilege();
policy.setEntitlement(new Entitlement());
policy.getEntitlement().setTTL(1234l);
// When
JsonValue result = parser.printPolicy(policy);
// Then
// TTL should not appear on the policy entitlement
assertThat(result.get("ttl").asLong()).isNull();
}
Aggregations