Search in sources :

Example 71 with CLIRequest

use of com.sun.identity.cli.CLIRequest in project OpenAM by OpenRock.

the class RealmTest method assignedServiceToRealm.

@Parameters({ "realm", "service-name", "attribute-value" })
@Test(groups = { "cli-realm", "add-svc-realm" })
public void assignedServiceToRealm(String realm, String serviceName, String attributeValue) throws CLIException, IdRepoException, SSOException {
    String[] param = { realm, serviceName, attributeValue };
    entering("assignedServiceToRealm", param);
    String[] args = { "add-svc-realm", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, serviceName, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, attributeValue };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    AMIdentityRepository amir = new AMIdentityRepository(getAdminSSOToken(), realm);
    AMIdentity ai = amir.getRealmIdentity();
    ai.getServiceAttributes(serviceName);
    exiting("assignedServiceToRealm");
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 72 with CLIRequest

use of com.sun.identity.cli.CLIRequest in project OpenAM by OpenRock.

the class RealmTest method createRealm.

@Parameters({ "realm" })
@BeforeTest(groups = { "cli-realm", "create-realm" })
public void createRealm(String realm) throws CLIException, SMSException {
    String[] param = { realm };
    entering("createRealm", param);
    String[] args = { "create-realm", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    String parentRealm = RealmUtils.getParentRealm(realm);
    String realmName = RealmUtils.getChildRealm(realm);
    OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminSSOToken(), parentRealm);
    Set names = ocm.getSubOrganizationNames(realmName, true);
    assert (names.size() == 1);
    String name = (String) names.iterator().next();
    assert name.equals(realmName);
    exiting("createRealm");
}
Also used : Set(java.util.Set) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) BeforeTest(org.testng.annotations.BeforeTest)

Example 73 with CLIRequest

use of com.sun.identity.cli.CLIRequest in project OpenAM by OpenRock.

the class RealmTest method setServiceAttribute.

@Parameters({ "realm", "service-name", "modify-attribute-value" })
@Test(groups = { "cli-realm", "services", "set-svc-attrs" }, dependsOnMethods = { "assignedServiceToRealm" })
public void setServiceAttribute(String realm, String serviceName, String attributeValue) throws CLIException, IdRepoException, SSOException {
    String[] param = { realm };
    entering("setServiceAttribute", param);
    String[] args = { "set-svc-attrs", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, serviceName, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, attributeValue };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    AMIdentityRepository amir = new AMIdentityRepository(getAdminSSOToken(), realm);
    AMIdentity ai = amir.getRealmIdentity();
    Map map = ai.getServiceAttributes(serviceName);
    Map<String, Set<String>> orig = CollectionUtils.parseStringToMap(attributeValue);
    String key = orig.keySet().iterator().next();
    String value = orig.get(key).iterator().next();
    Set resultSet = (Set) map.get(key);
    String result = (String) resultSet.iterator().next();
    assert (result.equals(value));
    exiting("setServiceAttribute");
}
Also used : Set(java.util.Set) AMIdentity(com.sun.identity.idm.AMIdentity) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) CLIRequest(com.sun.identity.cli.CLIRequest) HashMap(java.util.HashMap) Map(java.util.Map) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 74 with CLIRequest

use of com.sun.identity.cli.CLIRequest in project OpenAM by OpenRock.

the class IdRepoTest method deleteIdentity.

@Parameters({ "realm", "uid" })
@AfterTest(groups = { "cli-idrepo", "delete-identities" })
public void deleteIdentity(String realm, String uid) throws CLIException, IdRepoException, SSOException {
    String[] param = { realm, uid };
    entering("deleteRealm", param);
    String[] args = { "delete-identities", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_TYPE, "User", CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_NAMES, uid };
    SSOToken adminSSOToken = getAdminSSOToken();
    CLIRequest req = new CLIRequest(null, args, adminSSOToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    AMIdentityRepository amir = new AMIdentityRepository(adminSSOToken, realm);
    IdSearchControl isCtl = new IdSearchControl();
    IdSearchResults isr = amir.searchIdentities(IdType.USER, uid, isCtl);
    Set results = isr.getSearchResults();
    assert (results.isEmpty());
    exiting("deleteIdentities");
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) IdSearchResults(com.sun.identity.idm.IdSearchResults) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) IdSearchControl(com.sun.identity.idm.IdSearchControl) CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) AfterTest(org.testng.annotations.AfterTest)

Example 75 with CLIRequest

use of com.sun.identity.cli.CLIRequest in project OpenAM by OpenRock.

the class IdRepoTest method createIdentity.

@Parameters({ "realm", "uid", "attrs" })
@Test(groups = { "cli-idrepo", "create-identity" })
public void createIdentity(String realm, String uid, String attrs) throws CLIException {
    String[] param = { realm, uid, attrs };
    entering("createIdentity", param);
    List<String> arguments = new ArrayList<String>();
    arguments.add("create-identity");
    arguments.add(CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME);
    arguments.add(realm);
    arguments.add(CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_TYPE);
    arguments.add("User");
    arguments.add(CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_NAME);
    arguments.add(uid);
    arguments.add(CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES);
    StringTokenizer st = new StringTokenizer(attrs);
    while (st.hasMoreTokens()) {
        arguments.add(st.nextToken());
    }
    String[] args = new String[arguments.size()];
    int i = 0;
    for (String s : arguments) {
        args[i++] = s;
    }
    SSOToken adminSSOToken = getAdminSSOToken();
    CLIRequest req = new CLIRequest(null, args, adminSSOToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    AMIdentity amid = new AMIdentity(adminSSOToken, uid, IdType.USER, realm, null);
    assert (amid != null);
    exiting("createIdentity");
}
Also used : StringTokenizer(java.util.StringTokenizer) SSOToken(com.iplanet.sso.SSOToken) AMIdentity(com.sun.identity.idm.AMIdentity) ArrayList(java.util.ArrayList) CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Aggregations

CLIRequest (com.sun.identity.cli.CLIRequest)102 Test (org.testng.annotations.Test)95 BeforeTest (org.testng.annotations.BeforeTest)77 AfterTest (org.testng.annotations.AfterTest)66 Parameters (org.testng.annotations.Parameters)57 SSOException (com.iplanet.sso.SSOException)28 CLIException (com.sun.identity.cli.CLIException)27 SMSException (com.sun.identity.sm.SMSException)25 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)25 ServiceSchema (com.sun.identity.sm.ServiceSchema)21 AttributeSchema (com.sun.identity.sm.AttributeSchema)18 Set (java.util.Set)18 AMIdentity (com.sun.identity.idm.AMIdentity)14 HashSet (java.util.HashSet)14 SSOToken (com.iplanet.sso.SSOToken)13 ApplicationPrivilegeManager (com.sun.identity.entitlement.ApplicationPrivilegeManager)10 ApplicationPrivilege (com.sun.identity.entitlement.ApplicationPrivilege)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)5