IdRepoTest.java revision 3a6d5ffcd36b94407cb6d3b5cf9ca204071559a0
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 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: IdRepoTest.java,v 1.5 2008/06/25 05:44:18 qcheng Exp $
*
*/
/**
* This is to test the idrepo related sub commands.
*/
public class IdRepoTest extends TestBase{
private CommandManager cmdManager;
/**
* Creates a new instance of <code>IdRepoTest</code>
*/
public IdRepoTest() {
super("CLI");
}
/**
* Create the CLIManager.
*/
public void suiteSetup()
throws CLIException {
"com.sun.identity.cli.AccessManager");
}
throws CLIException {
while (st.hasMoreTokens()) {
}
int i = 0;
args[i++] = s;
}
exiting("createIdentity");
}
@Parameters ({"realm"})
throws CLIException {
"show-identity-types",
realm};
exiting("getIdentityTypes");
}
@Parameters ({"realm"})
throws CLIException {
"show-identity-ops",
"User"};
exiting("getIdentityOperations");
}
dependsOnMethods = {"createIdentity"})
throws CLIException {
"list-identities",
"User",
uid,
realm};
exiting("listIdentities");
}
dependsOnMethods = {"createIdentity"})
throws CLIException {
"get-identity",
"User",
uid,
realm};
exiting("getAttributes");
}
// Duplicate of getIdentityServices?
// @Parameters ({"realm", "uid"})
// @Test(groups = {"cli-idrepo", "get-identity-svcs"},
// dependsOnMethods = {"createIdentity"})
// public void getServices(String realm, String uid)
// throws CLIException {
// String[] param = {realm, uid};
// entering("getServices", param);
// String[] args = {
// "get-identity-svcs",
// CLIConstants.PREFIX_ARGUMENT_LONG +
// IdentityCommand.ARGUMENT_ID_TYPE,
// "User",
// CLIConstants.PREFIX_ARGUMENT_LONG +
// IdentityCommand.ARGUMENT_ID_NAME,
// uid,
// CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
// realm};
//
// CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
// cmdManager.addToRequestQueue(req);
// cmdManager.serviceRequestQueue();
// exiting("getServices");
// }
dependsOnMethods = {"createIdentity"})
throws CLIException {
"list-identity-assignable-svcs",
"User",
uid,
realm};
exiting("getAssignableServices");
}
dependsOnMethods = {"createIdentity"})
"add-svc-identity",
"User",
uid,
"iPlanetAMSessionService",
"iplanet-am-session-quota-limit=10"};
exiting("assignServices");
}
"getAttributes"})
"remove-svc-identity",
"User",
uid,
"iPlanetAMSessionService"};
}
exiting("unassignServices");
}
dependsOnMethods = {"assignServices"})
"show-identity-svc-attrs",
"User",
uid,
"iPlanetAMSessionService"};
exiting("getServiceAttributes");
}
dependsOnMethods = {"assignServices"})
"set-identity-svc-attrs",
"User",
uid,
"iPlanetAMSessionService",
"iplanet-am-session-quota-limit=1"
};
exiting("setServiceAttributes");
}
dependsOnMethods = {"assignServices"})
"set-identity-attrs",
"User",
uid,
"cn=commonname"
};
exiting("setAttributes");
}
dependsOnMethods = {"createIdentity"})
throws CLIException {
"get-identity-svcs",
"User",
uid,
realm};
exiting("getIdentityServices");
}
dependsOnMethods = {"createIdentity"})
throws CLIException {
"show-members",
"Group",
"User",
realm};
exiting("getMembers");
}
dependsOnMethods = {"createIdentity"})
throws CLIException {
"show-memberships",
"User",
uid,
"Group",
realm};
exiting("getMemberships");
}
dependsOnMethods = {"createIdentity"})
"add-member",
"Group",
uid,
"User",
realm};
exiting("addMember");
}
dependsOnMethods = {"addMember"})
"remove-member",
"Group",
uid,
"User",
realm};
}
exiting("removeMember");
}
dependsOnMethods = {"createIdentity"})
"show-privileges",
"Group",
realm};
exiting("getPrivileges");
}
/*
@Parameters ({"realm"})
@Test(groups = {"cli-idrepo", "add-privileges", "issue245"},
dependsOnMethods = {"createIdentity"})
public void addPrivileges(String realm)
throws CLIException, IdRepoException, DelegationException, SSOException{
createDummyGroup(realm);
String[] param = {realm};
entering("addPrivileges", param);
String[] args = {
"add-privileges",
CLIConstants.PREFIX_ARGUMENT_LONG +
IdentityCommand.ARGUMENT_ID_TYPE,
"Group",
CLIConstants.PREFIX_ARGUMENT_LONG +
IdentityCommand.ARGUMENT_ID_NAME,
DUMMY_Group,
CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.PRIVILEGES,
"PolicyAdmin",
CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
realm};
SSOToken adminSSOToken = getAdminSSOToken();
CLIRequest req = new CLIRequest(null, args, adminSSOToken);
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
DelegationManager mgr = new DelegationManager(
adminSSOToken, realm);
AMIdentity amid = new AMIdentity(
adminSSOToken, DUMMY_GROUP, IdType.GROUP, realm, null);
Set results = mgr.getPrivileges(amid.getUniversalId());
boolean found = false;
for (Iterator i = results.iterator(); i.hasNext() && !found; ) {
DelegationPrivilege p = (DelegationPrivilege)i.next();
found = p.getName().equals("PolicyAdmin");
}
assert found;
exiting("addPrivileges");
}
@Parameters ({"realm"})
@Test(groups = {"cli-idrepo", "remove-privileges"},
dependsOnMethods = {"addPrivileges"})
public void removePrivileges(String realm)
throws CLIException, IdRepoException, DelegationException, SSOException{
String[] param = {realm};
entering("removePrivileges", param);
String[] args = {
"remove-privileges",
CLIConstants.PREFIX_ARGUMENT_LONG +
IdentityCommand.ARGUMENT_ID_TYPE,
"Group",
CLIConstants.PREFIX_ARGUMENT_LONG +
IdentityCommand.ARGUMENT_ID_NAME,
DUMMY_GROUP,
CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.PRIVILEGES,
"PolicyAdmin",
CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
realm};
SSOToken adminSSOToken = getAdminSSOToken();
CLIRequest req = new CLIRequest(null, args, adminSSOToken);
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
DelegationManager mgr = new DelegationManager(
adminSSOToken, realm);
AMIdentity amid = new AMIdentity(
adminSSOToken, DUMMY_GROUP, IdType.GROUP, realm, null);
Set results = mgr.getPrivileges(amid.getUniversalId());
boolean found = false;
for (Iterator i = results.iterator(); i.hasNext() && !found; ) {
DelegationPrivilege p = (DelegationPrivilege)i.next();
found = p.getName().equals("PolicyAdmin");
}
deleteDummyGroup(realm);
assert !found;
exiting("removePrivileges");
}
*/
throws IdRepoException, SSOException {
getAdminSSOToken(), realm);
}
throws IdRepoException, SSOException {
}
"delete-identities",
"User",
uid};
exiting("deleteIdentities");
}
}