use of com.sun.identity.entitlement.ConditionDecision in project OpenAM by OpenRock.
the class AuthenticateToRealmConditionTest method conditionShouldEvaluateToFalseWhenEnvironmentDoesNotContainServicesAndDoesNotMatch.
@Test
public void conditionShouldEvaluateToFalseWhenEnvironmentDoesNotContainServicesAndDoesNotMatch() throws EntitlementException {
//Given
String realm = "REALM";
Subject subject = new Subject();
String resourceName = "RESOURCE_NAME";
Map<String, Set<String>> env = new HashMap<String, Set<String>>();
Set<String> realms = new HashSet<String>();
SSOToken ssoToken = mock(SSOToken.class);
realms.add("OTHER_REALM");
subject.getPrivateCredentials().add(ssoToken);
given(coreWrapper.getAuthenticatedRealms(ssoToken)).willReturn(realms);
condition.setState("{\"authenticateToRealm\": \"REALM\"}");
//When
ConditionDecision decision = condition.evaluate(realm, subject, resourceName, env);
//Then
assertThat(decision.isSatisfied()).isFalse();
assertThat(decision.getAdvice()).containsOnly(entry(AUTHENTICATE_TO_REALM_CONDITION_ADVICE, Collections.singleton("REALM")));
}
use of com.sun.identity.entitlement.ConditionDecision in project OpenAM by OpenRock.
the class AuthenticateToRealmConditionTest method conditionShouldEvaluateToTrueWhenEnvironmentDoesNotContainRealmsAndMatches.
@Test
public void conditionShouldEvaluateToTrueWhenEnvironmentDoesNotContainRealmsAndMatches() throws EntitlementException {
//Given
String realm = "REALM";
Subject subject = new Subject();
String resourceName = "RESOURCE_NAME";
Map<String, Set<String>> env = new HashMap<String, Set<String>>();
Set<String> realms = new HashSet<String>();
SSOToken ssoToken = mock(SSOToken.class);
realms.add("REALM");
subject.getPrivateCredentials().add(ssoToken);
given(coreWrapper.getAuthenticatedRealms(ssoToken)).willReturn(realms);
condition.setState("{\"authenticateToRealm\": \"REALM\"}");
//When
ConditionDecision decision = condition.evaluate(realm, subject, resourceName, env);
//Then
assertThat(decision.isSatisfied()).isTrue();
assertThat(decision.getAdvice()).isEmpty();
}
use of com.sun.identity.entitlement.ConditionDecision in project OpenAM by OpenRock.
the class AuthenticateToRealmConditionTest method conditionShouldEvaluateToTrueWhenEnvironmentContainsRealmsAndMatches.
@Test
public void conditionShouldEvaluateToTrueWhenEnvironmentContainsRealmsAndMatches() throws EntitlementException {
//Given
String realm = "REALM";
Subject subject = new Subject();
String resourceName = "RESOURCE_NAME";
Map<String, Set<String>> env = new HashMap<String, Set<String>>();
Set<String> realms = new HashSet<String>();
realms.add("REALM");
env.put(REQUEST_AUTHENTICATED_TO_REALMS, realms);
condition.setState("{\"authenticateToRealm\": \"REALM\"}");
//When
ConditionDecision decision = condition.evaluate(realm, subject, resourceName, env);
//Then
assertThat(decision.isSatisfied()).isTrue();
assertThat(decision.getAdvice()).isEmpty();
}
use of com.sun.identity.entitlement.ConditionDecision in project OpenAM by OpenRock.
the class AMIdentityMembershipConditionTest method conditionShouldEvaluateToFalseWhenInvocatorPrincipalIsNull.
@Test
public void conditionShouldEvaluateToFalseWhenInvocatorPrincipalIsNull() throws EntitlementException {
//Given
String realm = "REALM";
Subject subject = new Subject();
String resourceName = "RESOURCE_NAME";
Map<String, Set<String>> env = new HashMap<String, Set<String>>();
env.put(INVOCATOR_PRINCIPAL_UUID, Collections.<String>singleton(null));
condition.setState("{\"amIdentityName\": [\"IDENTITY_ONE\", \"IDENTITY_TWO\"]}");
//When
ConditionDecision decision = condition.evaluate(realm, subject, resourceName, env);
//Then
assertThat(decision.isSatisfied()).isFalse();
assertThat(decision.getAdvice()).isEmpty();
}
use of com.sun.identity.entitlement.ConditionDecision in project OpenAM by OpenRock.
the class AMIdentityMembershipConditionTest method conditionShouldEvaluateToFalseWhenNoIdentitiesConfigured.
@Test
public void conditionShouldEvaluateToFalseWhenNoIdentitiesConfigured() throws EntitlementException {
//Given
String realm = "REALM";
Subject subject = new Subject();
String resourceName = "RESOURCE_NAME";
Map<String, Set<String>> env = new HashMap<String, Set<String>>();
env.put(INVOCATOR_PRINCIPAL_UUID, Collections.singleton("INVOCATOR_UUID"));
//When
ConditionDecision decision = condition.evaluate(realm, subject, resourceName, env);
//Then
assertThat(decision.isSatisfied()).isFalse();
assertThat(decision.getAdvice()).isEmpty();
}
Aggregations