use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintLastModifiedDateInIsoFormat.
@Test
public void shouldPrintLastModifiedDateInIsoFormat() throws Exception {
// Given
Privilege policy = new StubPrivilege();
Date lastModified = new Date(123456789l);
policy.setLastModifiedDate(lastModified.getTime());
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get("lastModifiedDate").asString()).isEqualTo(DateUtils.toUTCDateFormatWithMilliseconds(lastModified));
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class PolicyResourceTest method shouldAcceptPolicyNameFromUrl.
@Test
public void shouldAcceptPolicyNameFromUrl() throws Exception {
// Given
String policyName = "policyName";
JsonValue json = new JsonValue("");
CreateRequest request = mockCreateRequest(policyName, json);
Privilege policy = mockPrivilege(policyName, 123l);
given(mockParser.parsePolicy(policyName, json)).willReturn(policy);
// When
policyResource.createInstance(mockServerContext, request);
// Then
verify(mockParser).parsePolicy(policyName, json);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class PrivilegePolicyStoreTest method shouldDelegateUpdatesToPrivilegeManager.
@Test
public void shouldDelegateUpdatesToPrivilegeManager() throws Exception {
// Given
String name = "test";
Privilege policy = new StubPrivilege();
// When
Privilege response = testStore.update(name, policy);
// Then
verify(mockManager).modify(name, policy);
assertThat(response).isSameAs(policy);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldParseSimpleSubjects.
@Test
public void shouldParseSimpleSubjects() throws Exception {
// Given
JsonValue content = buildJson(field("subject", object(field("type", "AuthenticatedUsers"))));
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
assertThat(result.getSubject()).isInstanceOf(AuthenticatedUsers.class);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldCorrectlyParseConditionTypes.
@Test
public void shouldCorrectlyParseConditionTypes() throws Exception {
// Given
String scope = "givenName";
JsonValue content = buildJson(field("condition", object(field("type", "OAuth2Scope"), field("requiredScopes", array(scope)))));
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
assertThat(result.getCondition()).isInstanceOf(OAuth2ScopeCondition.class);
assertThat(((OAuth2ScopeCondition) result.getCondition()).getRequiredScopes()).isEqualTo(Collections.singleton(scope));
}
Aggregations