use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintPolicyName.
@Test
public void shouldPrintPolicyName() throws Exception {
// Given
Privilege policy = new StubPrivilege();
String name = "test name";
policy.setName(name);
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get("name").asString()).isEqualTo(name);
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintSimpleSubjects.
@Test
public void shouldPrintSimpleSubjects() throws Exception {
// Given
Privilege policy = new StubPrivilege();
policy.setSubject(new AuthenticatedUsers());
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get(new JsonPointer("subject/type")).asString()).isEqualTo("AuthenticatedUsers");
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldAllowLegacyPolicyConditions.
@Test
public void shouldAllowLegacyPolicyConditions() throws Exception {
// Given
List<String> realm = Arrays.asList("REALM");
JsonValue content = buildJson(field("condition", object(field("type", "Policy"), field("className", AuthenticateToRealmCondition.class.getName()), field("properties", object(field("AuthenticateToRealm", realm))))));
// When
Privilege result = parser.parsePolicy(POLICY_NAME, content);
// Then
assertThat(result.getCondition()).isInstanceOf(PolicyCondition.class);
PolicyCondition condition = (PolicyCondition) result.getCondition();
assertThat(condition.getClassName()).isEqualTo(AuthenticateToRealmCondition.class.getName());
assertThat(condition.getProperties()).isEqualTo(Collections.singletonMap("AuthenticateToRealm", new HashSet<String>(realm)));
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintPolicyResourceSet.
@Test
public void shouldPrintPolicyResourceSet() throws Exception {
// Given
Privilege policy = new StubPrivilege();
Set<String> included = CollectionUtils.asSet("one", "two", "three");
Entitlement resources = new Entitlement();
resources.setResourceNames(included);
policy.setEntitlement(resources);
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get("resources").asList()).containsOnly(included.toArray());
}
use of com.sun.identity.entitlement.Privilege in project OpenAM by OpenRock.
the class JsonPolicyParserTest method shouldPrintPolicyActionValues.
@Test
public void shouldPrintPolicyActionValues() throws Exception {
// Given
Privilege policy = new StubPrivilege();
policy.setEntitlement(new Entitlement());
Map<String, Boolean> actionValues = new HashMap<String, Boolean>();
actionValues.put("one", true);
actionValues.put("two", false);
policy.getEntitlement().setActionValues(actionValues);
// When
JsonValue result = parser.printPolicy(policy);
// Then
assertThat(result.get("actionValues").asMap(Boolean.class)).isEqualTo(actionValues);
}
Aggregations