Search in sources :

Example 26 with CLIRequest

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

the class SchemaTest method setAttributeAny.

@Parameters({ "subschema" })
@Test(groups = { "schema", "set-attr-any", "attribute-schema-ops", "subschema" }, dependsOnMethods = { "addAttributeSchema" })
public void setAttributeAny(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("setAttributeAny", params);
    String[] args = (subschema.length() == 0) ? new String[9] : new String[11];
    args[0] = "set-attr-any";
    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 + ModifyAttributeSchemaAny.ARGUMENT_ANY;
    args[8] = "admin";
    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.getAny().equals("admin"));
        exiting("setAttributeAny");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setAttributeAny", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setAttributeAny", 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 27 with CLIRequest

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

the class SchemaTest method setSubConfiguration.

@Test(groups = { "schema", "set-sub-cfg" }, dependsOnMethods = { "createSubConfiguration" })
public void setSubConfiguration() throws CLIException, SMSException, SSOException {
    entering("setSubConfiguration", null);
    String[] args = { "set-sub-cfg", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + ModifySubConfiguration.ARGUMENT_OPERATION, "set", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_NAME, "/testConfig", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "attr1=2" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        Map map = getSubConfigurationValues("/testConfig");
        Set set = (Set) map.get("attr1");
        String attr1 = (String) set.iterator().next();
        assert attr1.equals("2");
        args[4] = "delete";
        req = new CLIRequest(null, args, getAdminSSOToken());
        cmdManager.addToRequestQueue(req);
        cmdManager.serviceRequestQueue();
        map = getSubConfigurationValues("/testConfig");
        set = (Set) map.get("attr1");
        assert (set == null) || set.isEmpty();
        args[4] = "add";
        args[8] = "attr3=2";
        req = new CLIRequest(null, args, getAdminSSOToken());
        cmdManager.addToRequestQueue(req);
        cmdManager.serviceRequestQueue();
        map = getSubConfigurationValues("/testConfig");
        set = (Set) map.get("attr3");
        attr1 = (String) set.iterator().next();
        assert attr1.equals("2");
        exiting("setSubConfiguration");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "setSubConfiguration", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "setSubConfiguration", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "setSubConfiguration", e.getMessage());
        throw e;
    }
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 28 with CLIRequest

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

the class SchemaTest method deleteServices.

private void deleteServices(List<String> serviceNames) throws CLIException {
    String[] args = new String[serviceNames.size() + 2];
    args[0] = "delete-svc";
    args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME;
    int cnt = 2;
    for (String xml : serviceNames) {
        args[cnt++] = xml;
    }
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
}
Also used : CLIRequest(com.sun.identity.cli.CLIRequest)

Example 29 with CLIRequest

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

the class SchemaTest method addAttributeSchema.

@Parameters({ "subschema" })
@Test(groups = { "schema", "add-attrs", "subschema" })
public void addAttributeSchema(String subschema) throws CLIException, SMSException, SSOException {
    Object[] params = { subschema };
    entering("addAttributeSchema", params);
    String[] args = (subschema.length() > 0) ? new String[9] : new String[7];
    args[0] = "add-attrs";
    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 + AddAttributeSchema.ARGUMENT_SCHEMA_FILES;
    args[6] = MOCK_DIR + "/addAttributeSchema.xml";
    if (subschema.length() > 0) {
        args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME;
        args[8] = 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 != null);
        exiting("addAttributeSchema");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "addAttributeSchema", e.getMessage(), params);
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "addAttributeSchema", e.getMessage(), params);
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "addAttributeSchema", e.getMessage(), params);
        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 30 with CLIRequest

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

the class SAML2Test method listCircleOfTrusts.

@Test(groups = { "samlv2", "samlv2entityop" }, dependsOnMethods = { "importEntity" })
public void listCircleOfTrusts() throws CLIException, SAML2MetaException {
    entering("listCircleOfTrusts", null);
    String[] args = { "list-cots", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, "/" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    cmdManager.serviceRequestQueue();
    exiting("listCircleOfTrusts");
}
Also used : CLIRequest(com.sun.identity.cli.CLIRequest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

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