use of com.iplanet.sso.providers.dpro.SSOPrincipal in project OpenAM by OpenRock.
the class ElevatedConnectionFactoryWrapperTest method requestGetsElevatedToAdminSession.
@Test
public void requestGetsElevatedToAdminSession() throws Exception {
// Given
SSOToken ssoToken = mock(SSOToken.class);
given(ssoTokenPrivilegedAction.run()).willReturn(ssoToken);
SSOPrincipal principal = new SSOPrincipal("test");
given(ssoToken.getPrincipal()).willReturn(principal);
SSOTokenID tokenID = mock(SSOTokenID.class);
given(ssoToken.getTokenID()).willReturn(tokenID);
given(internalConnectionFactory.getConnection()).willReturn(connection);
// When
RootContext context = new RootContext();
ReadRequest readRequest = Requests.newReadRequest("/test", "abc");
try (Connection connection = connectionFactory.getConnection()) {
connection.read(context, readRequest);
}
// Then
verify(connection).read(contextCaptor.capture(), eq(readRequest));
Context capturedContext = contextCaptor.getValue();
assertThat(capturedContext.containsContext(SecurityContext.class)).isTrue();
SecurityContext securityContext = capturedContext.asContext(SecurityContext.class);
assertThat(securityContext.getAuthenticationId()).isEqualTo("test");
assertThat(securityContext.getAuthorization()).containsOnlyKeys("authLevel", "tokenId");
}
use of com.iplanet.sso.providers.dpro.SSOPrincipal in project OpenAM by OpenRock.
the class StatelessSSOTokenTest method shouldReturnCorrectSSOPrincipal.
@Test
public void shouldReturnCorrectSSOPrincipal() throws Exception {
// Given
String name = "fred";
given(mockSession.getProperty(ISAuthConstants.PRINCIPAL)).willReturn(name);
// When
Principal result = statelessSSOToken.getPrincipal();
// Then
assertThat(result).isInstanceOf(SSOPrincipal.class).isEqualTo(new SSOPrincipal(name));
}
Aggregations