use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldNotAllowSettingCreationDate.
@Test
public void shouldNotAllowSettingCreationDate() throws Exception {
// Given
JsonValue content = buildJson(field("creationDate", "2014-01-01T00:00:00.000Z"));
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
// 0 = not set
assertThat(result.getCreationDate()).isEqualTo(0);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldParseDescription.
@Test
public void shouldParseDescription() throws Exception {
// Given
String description = "A test description";
JsonValue content = buildJson(field("description", description));
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
assertThat(result.getDescription()).isEqualTo(description);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldParseApplicationNameAlongsideResource.
@Test
public void shouldParseApplicationNameAlongsideResource() throws Exception {
// Given
String applicationName = "a test application";
JsonValue content = buildJson(null);
content.put("applicationName", applicationName);
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
assertThat(result.getEntitlement().getApplicationName()).isEqualTo(applicationName);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldParseNestedAndConditions.
@Test
public void shouldParseNestedAndConditions() throws Exception {
// Given
// An AND condition containing a single OAuth2Scope condition
String scope = "givenName";
JsonValue content = buildJson(field("condition", object(field("type", "AND"), field("conditions", Collections.singletonList(object(field("type", "OAuth2Scope"), field("requiredScopes", array(scope))))))));
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
assertThat(result.getCondition()).isInstanceOf(AndCondition.class);
AndCondition and = (AndCondition) result.getCondition();
assertThat(and.getEConditions()).hasSize(1);
assertThat(and.getEConditions().iterator().next()).isInstanceOf(OAuth2ScopeCondition.class);
OAuth2ScopeCondition oauth2Scope = (OAuth2ScopeCondition) and.getEConditions().iterator().next();
assertThat(oauth2Scope.getRequiredScopes()).isEqualTo(Collections.singleton(scope));
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintLastModifiedBy.
@Test
public void shouldPrintLastModifiedBy() throws Exception {
// Given
Privilege policy = new StubPrivilege();
String lastModifiedBy = "test user";
policy.setLastModifiedBy(lastModifiedBy);
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get("lastModifiedBy").asString()).isEqualTo(lastModifiedBy);
}
Aggregations