PrivilegeManagerTest.java revision 1350b637af96e2390d247918800c02a7f531b47d
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: PrivilegeManagerTest.java,v 1.3 2010/01/26 20:10:16 dillidorai Exp $
*
* Portions copyright 2014-2015 ForgeRock AS.
*/
/**
*
* @author dillidorai
*/
public class PrivilegeManagerTest {
private UserSubject ua1;
private UserSubject ua2;
public void setup()
if (!migrated) {
return;
}
createApplication("/");
adminToken, "/");
}
if (!migrated) {
return;
}
// Test disabled, unable to fix model change
// Set<String> appResources = new HashSet<String>();
// appResources.add(RESOURCE);
// appl.addResources(appResources);
}
if (!migrated) {
return;
}
//Sub Realm
PrivilegeManager prmSubReam = PrivilegeManager.getInstance(SUB_REALM, SubjectUtils.createSubject(adminToken));
ReferralPrivilegeManager referralM = new ReferralPrivilegeManager("/", SubjectUtils.createSubject(adminToken));
}
@Test
public void testNoSubjectInPrivilege() throws Exception {
if (!migrated) {
return;
}
try {
p.setSubject(os);
} catch (EntitlementException e) {
if (e.getErrorCode() != 310) {
throw e;
} else {
return;
}
}
throw new Exception("PrivilegeManagerTest.testNoSubjectInPrivilege failed");
}
ua1 = new OpenSSOUserSubject();
ua2 = new OpenSSOUserSubject();
return priv;
}
public void subRealmTest() throws Exception {
if (!migrated) {
return;
}
try {
} catch (EntitlementException e){
//ok
}
ReferralPrivilegeManager referralM = new ReferralPrivilegeManager("/", SubjectUtils.createSubject(adminToken));
throw new Exception("PrivilegeManagerTest.subRealmTest, resource is likely to be canonicalized");
}
}
@Test
public void testAddPrivilege() throws Exception {
if (!migrated) {
return;
}
privilege = createPrivilege();
throw new Exception(
"PrivilegeManagerTest.testAddPrivilege():"
+ "READ startIp "
+ " does not equal set startIp");
}
throw new Exception(
"PrivilegeManagerTest.testAddPrivilege():"
+ "READ endIp "
+ " does not equal set endIp");
}
throw new Exception("PrivilegeManagerTest.testAddPrivilege():"
+ "read privilege not"
+ "equal to saved privilege");
}
{
if (subjectCollections instanceof OrSubject) {
throw new Exception("PrivilegeManagerTest.testAddPrivilege: Subject does not matched.");
}
}
}
}
}
public void testAddPrivilege2() throws Exception {
if (!migrated) {
return;
}
privilege = createPrivilege();
throw new Exception(
"PrivilegeManagerTest.testAddPrivilege():"
+ "READ startIp "
+ " does not equal set startIp");
}
throw new Exception(
"PrivilegeManagerTest.testAddPrivilege():"
+ "READ endIp "
+ " does not equal set endIp");
}
throw new Exception("PrivilegeManagerTest.testAddPrivilege():"
+ "read privilege not"
+ "equal to saved privilege");
}
{
if (subjectCollections instanceof OrSubject) {
throw new Exception("PrivilegeManagerTest.testAddPrivilege: Subject does not matched.");
}
}
}
}
}
public void testGetPrivilegesXML() throws Exception {
}
public void testSerializePrivilege() throws Exception {
if (!migrated) {
return;
}
throw new Exception("PrivilegeManagerTest.testSerializePrivilege: failed");
}
}
public void testListPrivilegeNames() throws Exception {
if (!migrated) {
return;
}
throw new Exception(
"PrivilegeManagerTest.testListPrivilegeNames():"
+ "got privilege names does not contain saved privilege");
}
throw new Exception(
"PrivilegeManagerTest.testListPrivilegeNames():"
+ "got privilege names does not contain saved privilege");
}
}
public void testGetPrivilege() throws Exception {
if (!migrated) {
return;
}
if (p == null) {
throw new Exception("PrivilegeManagerTest.testGetPrivilege: "
+ "failed to get privilege.");
}
throw new Exception("PrivilegeManagerTest.testGetPrivilege: "
+ "failed to get privilege description.");
}
throw new Exception("PrivilegeManagerTest.testGetPrivilege: "
+ "failed to get privilege XML.");
}
}
public void testLastModifiedDate() throws Exception {
if (!migrated) {
return;
}
throw new Exception("PrivilegeManagerTest.testLastModifiedDate: "
+ "creation and last modified date are the same.");
}
}
}