use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class ApplicationDelegationTest method negativeTest.
@Test
public void negativeTest() throws Exception {
SSOToken ssoToken = authenticate(USER1, USER1);
testUserSubject = SubjectUtils.createSubject(ssoToken);
Application appl = ApplicationManager.getApplication(testUserSubject, "/", APPL_NAME);
try {
ApplicationManager.saveApplication(testUserSubject, "/", appl);
} catch (EntitlementException e) {
if (e.getErrorCode() != 326) {
throw e;
}
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class ApplicationFilterTest method test.
@Test
public void test() throws Exception {
SSOToken userToken = AuthUtils.authenticate("/", USER1, USER1);
Subject userSubject = SubjectUtils.createSubject(userToken);
Set<SearchFilter> filters = new HashSet<SearchFilter>();
filters.add(new SearchFilter(Application.NAME_SEARCH_ATTRIBUTE, "ApplicationFilterTes*"));
Set<String> names = ApplicationManager.search(userSubject, "/", filters);
if (names.isEmpty()) {
throw new Exception("ApplicationFilterTest.test: expect to return one entry");
}
filters.clear();
filters.add(new SearchFilter(Application.NAME_SEARCH_ATTRIBUTE, "4rwrwr*"));
names = ApplicationManager.search(userSubject, "/", filters);
if (!names.isEmpty()) {
throw new Exception("ApplicationFilterTest.test: expect to return no entries");
}
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class AdminOnlyAuthzModuleTest method shouldAuthorizeValidContext.
@Test
public void shouldAuthorizeValidContext() throws Exception {
//given
SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class);
SSOToken mockSSOToken = mock(SSOToken.class);
given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test");
given(mockService.isSuperUser("test")).willReturn(true);
//when
Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext);
//then
assertTrue(result.get().isAuthorized());
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class AdminOnlyAuthzModuleTest method shouldFailNonSuperUser.
@Test
public void shouldFailNonSuperUser() throws Exception {
//given
SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class);
SSOToken mockSSOToken = mock(SSOToken.class);
given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test");
given(mockService.isSuperUser("test")).willReturn(false);
//when
Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext);
//then
assertFalse(result.get().isAuthorized());
}
use of com.iplanet.sso.SSOToken in project OpenAM by OpenRock.
the class SpecialOrAdminOrAgentAuthzModuleTest method shouldAuthorizeAdmin.
@Test
public void shouldAuthorizeAdmin() throws Exception {
//given
SSOTokenContext mockSSOTokenContext = mock(SSOTokenContext.class);
SSOToken mockSSOToken = mock(SSOToken.class);
Principal principal = mock(Principal.class);
given(mockSSOToken.getPrincipal()).willReturn(principal);
given(mockSSOTokenContext.getCallerSSOToken()).willReturn(mockSSOToken);
given(mockSSOToken.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willReturn("test");
given(mockAgentIdentity.isAgent(mockSSOToken)).willReturn(false);
given(mockSpecialUserIdentity.isSpecialUser(mockSSOToken)).willReturn(false);
given(mockService.isSuperUser("test")).willReturn(true);
//when
Promise<AuthorizationResult, ResourceException> result = testModule.authorize(mockSSOTokenContext);
//then
assertTrue(result.get().isAuthorized());
}
Aggregations