use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class DelegationPrivilegeTest method testModify.
@Test(dependsOnMethods = { "testAdd" })
public void testModify() throws Exception {
SSOToken userSSOToken = AuthUtils.authenticate("/", testParams.get("DELEGATED_USER"), testParams.get("DELEGATED_USER"));
ApplicationPrivilegeManager mgr = ApplicationPrivilegeManager.getInstance(realm, SubjectUtils.createSubject(userSSOToken));
Set<SearchFilter> filters = new HashSet<SearchFilter>();
String privilegeName = testParams.get("DELEGATE_PRIVILEGE_NAME");
filters.add(new SearchFilter(Privilege.NAME_SEARCH_ATTRIBUTE, privilegeName));
Set<String> names = mgr.search(filters);
if ((names == null) || names.isEmpty()) {
throw new Exception("DelegationPrivilegeTest.testModify: search failed");
}
ApplicationPrivilege ap = mgr.getPrivilege(privilegeName);
Set<String> appRes = ap.getResourceNames(ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
appRes.add(testParams.get("DELEGATED_SUB_RESOURCE"));
mgr.replacePrivilege(ap);
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class DelegationPrivilegeTest method testModifyNegative.
@Test(dependsOnMethods = { "testModify" })
public void testModifyNegative() throws Exception {
SSOToken userSSOToken = AuthUtils.authenticate("/", testParams.get("NON_DELEGATED_USER"), testParams.get("NON_DELEGATED_USER"));
ApplicationPrivilegeManager mgr = ApplicationPrivilegeManager.getInstance(realm, SubjectUtils.createSubject(userSSOToken));
Set<SearchFilter> filters = new HashSet<SearchFilter>();
String privilegeName = testParams.get("DELEGATE_PRIVILEGE_NAME");
filters.add(new SearchFilter(Privilege.NAME_SEARCH_ATTRIBUTE, privilegeName));
Set<String> privilegeNames = mgr.search(filters);
if ((privilegeNames != null) && !privilegeNames.isEmpty()) {
throw new Exception("DelegationPrivilegeTest.testModifyNegative" + "privilegeNames should be empty");
}
try {
ApplicationPrivilege ap = mgr.getPrivilege(testParams.get("DELEGATE_PRIVILEGE_NAME"));
} catch (EntitlementException e) {
if (e.getErrorCode() != 325) {
throw e;
}
}
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class ApplicationDelegationTest method test.
@Test(dependsOnMethods = { "negativeTest" })
public void test() throws Exception {
Application appl = ApplicationManager.getApplication(testUserSubject, "/", APPL_NAME);
// Test disabled, unable to fix model change.
// Set<String> resources = appl.getResources();
// if ((resources.size() != 1) &&
// !resources.contains(DELEGATED_RESOURCE)) {
// throw new Exception("ApplicationDelegationTest.test: " +
// "incorrect resource in application object");
// }
Set<SearchFilter> filter = new HashSet<SearchFilter>();
filter.add(new SearchFilter(Privilege.NAME_SEARCH_ATTRIBUTE, PRIVILEGE_NAME + "*"));
PrivilegeManager pm = PrivilegeManager.getInstance("/", testUserSubject);
Set<String> names = pm.searchNames(filter);
// that is delegated to him
if (names.size() != 1) {
throw new Exception("ApplicationDelegationTest.test: " + "privilege manager is not returning the correct search privilege name");
}
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class ApplicationMetaData method test.
@Test
public void test() throws Exception {
if (!migrated) {
return;
}
Application appl = ApplicationManager.getApplication(adminSubject, "/", APPL_NAME);
String createdBy = appl.getCreatedBy();
long creationTime = appl.getCreationDate();
long modifiedTime = appl.getLastModifiedDate();
if (creationTime != modifiedTime) {
throw new Exception("ApplicationMetaData.test: modified and creation time diff");
}
ApplicationManager.saveApplication(adminSubject, "/", appl);
creationTime = appl.getCreationDate();
modifiedTime = appl.getLastModifiedDate();
if (creationTime == modifiedTime) {
throw new Exception("ApplicationMetaData.test: modified and creation time unchanged");
}
if (!createdBy.equals(appl.getLastModifiedBy())) {
throw new Exception("ApplicationMetaData.test: createdBy and modifiedBy should be the same");
}
Set<SearchFilter> filters = new HashSet<SearchFilter>();
filters.add(new SearchFilter(Application.NAME_SEARCH_ATTRIBUTE, APPL_NAME));
Set<String> results = ApplicationManager.search(adminSubject, "/", filters);
if (!results.contains(APPL_NAME)) {
throw new Exception("ApplicationMetaData.test: search fails");
}
}
use of com.sun.identity.entitlement.util.SearchFilter in project OpenAM by OpenRock.
the class MetaDataTest method test.
private void test(PrivilegeManager privilegMgr, SearchFilter.Operator operator, long value, String desc, boolean containCheckOnly) throws Exception {
Set<SearchFilter> filter = new HashSet<SearchFilter>();
filter.add(new SearchFilter(Privilege.CREATION_DATE_SEARCH_ATTRIBUTE, value, operator));
Set<String> privilegeNames = privilegMgr.searchNames(filter);
if (!containCheckOnly) {
if ((privilegeNames == null) || (privilegeNames.size() != 1)) {
throw new Exception("MetaDataTest.test: (" + desc + ") search privilege names failed");
}
}
if (!privilegeNames.contains(POLICY_NAME)) {
throw new Exception("MetaDataTest.test: (" + desc + ") search privilege names failed, Got the wrong privilege");
}
}
Aggregations