Search in sources :

Example 66 with CLIRequest

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

the class SchemaTest method setAttributeI18nKey.

@Parameters({ "subschema" })
@Test(groups = { "schema", "set-attr-i18n-key", "attribute-schema-ops", "subschema" }, dependsOnMethods = { "addAttributeSchema" })
public void setAttributeI18nKey(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("setAttributeI18nKey", params);
    String[] args = (subschema.length() == 0) ? new String[9] : new String[11];
    args[0] = "set-attr-i18n-key";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
    args[2] = TEST_SERVICE;
    args[3] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE;
    args[4] = "global";
    args[5] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_SCHEMA;
    args[6] = "mock-add";
    args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + ModifyAttributeSchemaI18nKey.ARGUMENT_I18N_KEY;
    args[8] = "123";
    if (subschema.length() > 0) {
        args[9] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
        args[10] = subschema;
    }
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema serviceSchema = mgr.getGlobalSchema();
        if (subschema.length() > 0) {
            serviceSchema = serviceSchema.getSubSchema(subschema);
        }
        AttributeSchema as = serviceSchema.getAttributeSchema("mock-add");
        assert (as.getI18NKey().equals("123"));
        exiting("setAttributeI18nKey");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setAttributeI18nKey", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setAttributeI18nKey", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setAttributeI18nKey", e.getMessage());
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 67 with CLIRequest

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

the class SchemaTest method createSubConfiguration.

@Test(groups = { "schema", "create-sub-cfg" })
public void createSubConfiguration() throws CLIException, SMSException, SSOException {
    entering("createSubConfiguration", null);
    String[] args = { "create-sub-cfg", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_ID, "subschemaX", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_NAME, "testConfig", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "attr1=1", "attr2=2" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceConfigManager scm = new ServiceConfigManager(TEST_SERVICE, getAdminSSOToken());
        ServiceConfig sc = scm.getGlobalConfig(null);
        sc = sc.getSubConfig("testConfig");
        assert (sc != null);
        exiting("createSubConfiguration");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "createSubConfiguration", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "createSubConfiguration", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "createSubConfiguration", e.getMessage());
        throw e;
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 68 with CLIRequest

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

the class SchemaTest method addSubSchema.

@Test(groups = { "schema", "add-sub-schema" })
public void addSubSchema() throws CLIException, SMSException, SSOException {
    entering("addSubSchema", null);
    String[] args = { "add-sub-schema", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE, "global", CLIConstants.PREFIX_ARGUMENT_LONG + AddSubSchema.ARGUMENT_FILENAME, MOCK_DIR + "/subschema.xml" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceSchemaManager mgr = new ServiceSchemaManager(TEST_SERVICE, getAdminSSOToken());
        ServiceSchema globalSchema = mgr.getSchema(SchemaType.GLOBAL);
        ServiceSchema s = globalSchema.getSubSchema("subschema");
        assert (s != null);
        exiting("addSubSchema");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "addSubSchema", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "addSubSchema", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "addSubSchema", e.getMessage());
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 69 with CLIRequest

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

the class RealmTest method deletePolicy.

@Test(groups = { "cli-realm", "delete-policies" }, dependsOnMethods = { "getPolicy" })
public void deletePolicy() throws CLIException, PolicyException, SSOException {
    entering("deletePolicy", null);
    String[] args = { "delete-policies", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, "/", CLIConstants.PREFIX_ARGUMENT_LONG + RealmDeletePolicy.ARGUMENT_POLICY_NAMES, "clipolicy" };
    SSOToken adminSSOToken = getAdminSSOToken();
    CLIRequest req = new CLIRequest(null, args, adminSSOToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    PolicyManager pm = new PolicyManager(adminSSOToken, "/");
    try {
        Policy p = pm.getPolicy("clipolicy");
        assert (p == null);
    } catch (NameNotFoundException e) {
    // do nothing
    }
    exiting("deletePolicy");
}
Also used : Policy(com.sun.identity.policy.Policy) PolicyManager(com.sun.identity.policy.PolicyManager) SSOToken(com.iplanet.sso.SSOToken) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) CLIRequest(com.sun.identity.cli.CLIRequest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 70 with CLIRequest

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

the class RealmTest method addRealmAttribute.

@Parameters({ "realm" })
@Test(groups = { "cli-realm", "add-realm-attrs" }, dependsOnMethods = { "assignedServiceToRealm" })
public void addRealmAttribute(String realm) throws CLIException, IdRepoException, SMSException, SSOException {
    String[] param = { realm };
    entering("addRealmAttribute", param);
    String[] args = { "set-realm-attrs", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, "sunIdentityRepositoryService", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "sunOrganizationAliases=dummy" };
    SSOToken adminSSOToken = getAdminSSOToken();
    CLIRequest req = new CLIRequest(null, args, adminSSOToken);
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminSSOToken, realm);
    Map map = orgMgr.getAttributes("sunIdentityRepositoryService");
    Set values = (Set) map.get("sunOrganizationAliases");
    assert (values.contains("dummy"));
    values.remove("dummy");
    orgMgr.setAttributes("sunIdentityRepositoryService", map);
    exiting("addRealmAttribute");
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) 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)

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