diff --git a/openam-test/pom.xml b/openam-test/pom.xml
deleted file mode 100755
index f1967ed4e6..0000000000
--- a/openam-test/pom.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
- 4.0.0
-
-
-
- org.openidentityplatform.openam
- openam
- 10.2.0-SNAPSHOT
-
-
-
- OpenAM Common Test Suite
- OpenAM Common TEST Suite
- openam-test
- jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- test-jar
- package
-
- test-jar
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
- true
-
-
-
-
-
-
-
-
- org.openidentityplatform.openam
- openam-cli
-
-
-
- org.openidentityplatform.openam
- openam-core
-
-
-
- org.openidentityplatform.openam
- openam-cli-impl
-
-
-
- jakarta.servlet
- jakarta.servlet-api
- provided
-
-
-
- org.testng
- testng
-
-
-
diff --git a/openam-test/src/test/java/com/sun/identity/cli/CLIFrameworkTest.java b/openam-test/src/test/java/com/sun/identity/cli/CLIFrameworkTest.java
deleted file mode 100644
index f3d75a02db..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/CLIFrameworkTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: CLIFrameworkTest.java,v 1.2 2008/06/25 05:44:15 qcheng Exp $
- *
- */
-
-package com.sun.identity.cli;
-
-import com.sun.identity.test.common.TestBase;
-import java.util.HashMap;
-import java.util.Map;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-/**
- * This is test to test the CLI Framework on parsing arguments;
- * checking for mandatory argument; etc.
- */
-public class CLIFrameworkTest extends TestBase{
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
-
- /**
- * Creates a new instance of CLIFrameworkTest
- */
- public CLIFrameworkTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- *
- */
- @BeforeSuite(groups = {"cli-framework"})
- public void suiteSetup()
- throws CLIException
- {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "testclifw");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.MockCLIManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
- @Test(groups = {"cli-framework"}, expectedExceptions = {CLIException.class})
- public void invalidSubCommand()
- throws CLIException {
- entering("invalidSubCommand", null);
- String[] args = {"ba-ba-black-sheep"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("invalidSubCommand");
- }
-
- @Test(groups = {"cli-framework"}, expectedExceptions = {CLIException.class})
- public void withoutMandatoryOption()
- throws CLIException {
- entering("withoutMandatoryOption", null);
- String[] args = {"test-command",
- CLIConstants.PREFIX_ARGUMENT_LONG + "optional",
- "test"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("withoutMandatoryOption");
- }
-
- @Test(groups = {"cli-framework"}, expectedExceptions = {CLIException.class})
- public void withInvalidOption()
- throws CLIException {
- entering("withInvalidOption", null);
- String[] args = {"test-command",
- CLIConstants.PREFIX_ARGUMENT_LONG + "notdefined",
- "test"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("withInvalidOption");
- }
-
- @Test(groups = {"cli-framework"}, expectedExceptions = {CLIException.class})
- public void withoutOptions()
- throws CLIException {
- entering("withoutOptions", null);
- String[] args = {"test-command"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("withoutOptions");
- }
-
- @Test(groups = {"cli-framework"})
- public void withMandatoryOption()
- throws CLIException {
- entering("withMandatoryOption", null);
- String[] args = {"test-command",
- CLIConstants.PREFIX_ARGUMENT_LONG + "mandatory",
- "test"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("withMandatoryOption");
- }
-
- @Test(groups = {"cli-framework"})
- public void matchOptionValues()
- throws CLIException {
- entering("matchOptionValues", null);
- String[] args = {"test-command",
- CLIConstants.PREFIX_ARGUMENT_LONG + "mandatory",
- "mandatory",
- CLIConstants.PREFIX_ARGUMENT_LONG + "optional",
- "optional",
- CLIConstants.PREFIX_ARGUMENT_LONG + "testmatch"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("matchOptionValues");
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/DevNullOutputWriter.java b/openam-test/src/test/java/com/sun/identity/cli/DevNullOutputWriter.java
deleted file mode 100644
index d93bdcea9d..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/DevNullOutputWriter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: DevNullOutputWriter.java,v 1.2 2008/06/25 05:44:15 qcheng Exp $
- *
- */
-
-package com.sun.identity.cli;
-
-
-/**
- * For Unit test, this writer does nothing!
- */
-public class DevNullOutputWriter implements IOutput {
- private StringBuffer buff = new StringBuffer();
-
- /**
- * Prints message.
- *
- * @param str Message string.
- */
- public void printMessage(String str) {
- buff.append(str).append("\n");
- }
-
- /**
- * Prints message with new line.
- *
- * @param str Message string.
- */
- public void printlnMessage(String str) {
- buff.append(str).append("\n");
- }
-
- /**
- * Prints error.
- *
- * @param str Error message string.
- */
- public void printError(String str) {
- buff.append(str).append("\n");
- }
-
- /**
- * Prints error with new line.
- *
- * @param str Error message string.
- */
- public void printlnError(String str) {
- buff.append(str).append("\n");
- }
-
- public String getMessages() {
- return buff.toString();
- }
-
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/DummyCommand.java b/openam-test/src/test/java/com/sun/identity/cli/DummyCommand.java
deleted file mode 100644
index 8d286e0f41..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/DummyCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: DummyCommand.java,v 1.2 2008/06/25 05:44:16 qcheng Exp $
- *
- */
-
-package com.sun.identity.cli;
-
-import com.sun.identity.cli.schema.SchemaCommand;
-
-/**
- * Dummy command for testing purposes.
- */
-public class DummyCommand extends SchemaCommand {
-
- /**
- * Services a Commandline Request.
- *
- * @param rc Request Context.
- * @throw CLIException if the request cannot serviced.
- */
- public void handleRequest(RequestContext rc)
- throws CLIException {
- super.handleRequest(rc);
- if (isOptionSet("testmatch")) {
- if (!getStringOptionValue("mandatory").equals("mandatory") ||
- !getStringOptionValue("optional").equals("optional") ) {
- throw new CLIException("option values does not matched.",
- ExitCodes.INVALID_OPTION_VALUE);
- }
- }
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/MockCLIManager.java b/openam-test/src/test/java/com/sun/identity/cli/MockCLIManager.java
deleted file mode 100644
index e392c323d4..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/MockCLIManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: MockCLIManager.java,v 1.4 2009/06/05 19:33:42 veiming Exp $
- *
- */
-
-/**
- * Portions Copyrighted 2012 ForgeRock Inc
- */
-package com.sun.identity.cli;
-
-/**
- * This is mock CLI Manager class which is used to test the CLI Framework.
- */
-public class MockCLIManager extends CLIDefinitionBase {
- private static String DEFINITION_CLASS =
- "com.sun.identity.cli.definition.MockCLI";
-
- /**
- * Constructs an instance of this class.
- */
- public MockCLIManager()
- throws CLIException {
- super(DEFINITION_CLASS);
- }
-
- /**
- * Returns product name.
- *
- * @return product name.
- */
- public String getProductName() {
- return rb.getString(AccessManagerConstants.I18N_PRODUCT_NAME);
- }
-
- /**
- * Returns true if the option is an authentication related
- * option such as user ID and password.
- *
- * @param opt Name of option.
- * @returns true if the option is an authentication related
- * option such as user ID and password.
- */
- public boolean isAuthOption(String opt) {
- return false;
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/ResourceBundleTest.java b/openam-test/src/test/java/com/sun/identity/cli/ResourceBundleTest.java
deleted file mode 100644
index 9bd759fe57..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/ResourceBundleTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: ResourceBundleTest.java,v 1.5 2008/06/25 05:44:16 qcheng Exp $
- *
- */
-
-/**
- * Portions Copyrighted 2012 ForgeRock Inc
- */
-package com.sun.identity.cli;
-
-import com.iplanet.sso.SSOException;
-import com.sun.identity.common.ISResourceBundle;
-import com.sun.identity.test.common.TestBase;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-/**
- * This is to test the resource bundle sub command.
- */
-public class ResourceBundleTest extends TestBase{
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
-
- /**
- * Creates a new instance of CLIFrameworkTest
- */
- public ResourceBundleTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- */
- @BeforeTest(groups = {"cli-resource-bundle"})
- public void suiteSetup()
- throws CLIException
- {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "testclifw");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
- @Parameters ({"bundle-name", "bundle-file-name", "locale"})
- @Test(groups = {"cli-resource-bundle", "add-res-bundle"})
- public void addResourceBundle(
- String bundleName,
- String fileName,
- String locale
- ) throws CLIException, SSOException {
- entering("addResourceBundle", null);
- String[] args = (locale.length() == 0) ? new String[5] : new String[7];
-
- args[0] = "add-res-bundle";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.RESOURCE_BUNDLE_NAME;
- args[2] = bundleName;
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- AddResourceBundle.ARGUMENT_RESOURCE_BUNDLE_FILE_NAME;
- args[4] = fileName;
-
- if (locale.length() > 0) {
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.RESOURCE_BUNDLE_LOCALE;
- args[6] = locale;
- }
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ResourceBundle res = (locale.length() == 0) ?
- ISResourceBundle.getResourceBundle(getAdminSSOToken(), bundleName,
- (String)null) :
- ISResourceBundle.getResourceBundle(getAdminSSOToken(), bundleName,
- locale);
- assert (res != null);
- exiting("addResourceBundle");
- }
-
- @Parameters ({"bundle-name", "locale"})
- @Test(groups = {"cli-resource-bundle", "list-res-bundle"},
- dependsOnMethods = {"addResourceBundle"})
- public void getResourceBundle(String bundleName, String locale)
- throws CLIException {
- entering("getResourceBundle", null);
- String[] args = (locale.length() == 0) ? new String[3] : new String[5];
-
- args[0] = "list-res-bundle";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.RESOURCE_BUNDLE_NAME;
- args[2] = bundleName;
-
- if (locale.length() > 0) {
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.RESOURCE_BUNDLE_LOCALE;
- args[4] = locale;
- }
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getResourceBundle");
- }
-
- @Parameters ({"bundle-name", "locale"})
- @Test(groups = {"cli-resource-bundle", "remove-res-bundle"},
- dependsOnMethods = {"getResourceBundle"})
- public void removeResourceBundle(String bundleName, String locale)
- throws CLIException, SSOException {
- entering("removeResourceBundle", null);
- String[] args = (locale.length() == 0) ? new String[3] : new String[5];
-
- args[0] = "remove-res-bundle";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.RESOURCE_BUNDLE_NAME;
- args[2] = bundleName;
-
- if (locale.length() > 0) {
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.RESOURCE_BUNDLE_LOCALE;
- args[4] = locale;
- }
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- try {
- ResourceBundle res = (locale.length() == 0) ?
- ISResourceBundle.getResourceBundle(getAdminSSOToken(),
- bundleName, (String)null) :
- ISResourceBundle.getResourceBundle(getAdminSSOToken(),
- bundleName, locale);
- assert (res.getLocale() == null);
- } catch (MissingResourceException e) {
- //Ignored
- }
- if (!locale.isEmpty()) {
- //clean up the default resourcebundle too, after removing the JP version
- removeResourceBundle(bundleName, "");
- }
- exiting("removeResourceBundle");
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/authentication/AuthConfigTest.java b/openam-test/src/test/java/com/sun/identity/cli/authentication/AuthConfigTest.java
deleted file mode 100644
index 6765ea1f10..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/authentication/AuthConfigTest.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: AuthConfigTest.java,v 1.3 2008/06/25 05:44:16 qcheng Exp $
- *
- */
-
-package com.sun.identity.cli.authentication;
-
-import com.sun.identity.authentication.config.AMAuthenticationManager;
-import com.sun.identity.authentication.config.AMConfigurationException;
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.cli.DevNullOutputWriter;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.test.common.TestBase;
-import java.util.HashMap;
-import java.util.Map;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-import org.testng.annotations.AfterGroups;
-
-
-/**
- * This is to test the authentication configuration sub commands.
- */
-public class AuthConfigTest extends TestBase{
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
- private static final String TEST_AUTH_INSTANCE = "clitestauthinstance";
- private static final String TEST_AUTH_CONFIG = "clitestauthconfig";
- private static final String TEST_AUTH_TYPE = "DataStore";
-
- /**
- * Creates a new instance of AuthConfigTest
- */
- public AuthConfigTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- */
- @BeforeTest(groups = {"cli-authconfig"})
- public void suiteSetup()
- throws CLIException {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "amadm");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "list-auth-instances"})
- public void listAuthInstances(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("listAuthInstances", param);
- String[] args = {
- "list-auth-instances",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listAuthInstances");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "create-auth-instance"})
- public void createAuthInstance(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("createAuthInstance", param);
- String[] args = {
- "create-auth-instance",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_INSTANCE_NAME,
- TEST_AUTH_INSTANCE,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_INSTANCE_TYPE,
- TEST_AUTH_TYPE
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("createAuthInstance");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "list-auth-cfgs"})
- public void listAuthConfigurations(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("listAuthConfigurations", param);
- String[] args = {
- "list-auth-cfgs",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listAuthConfigurations");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "create-auth-cfg"},
- dependsOnMethods = {"createAuthInstance"})
- public void createAuthConfiguration(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("createAuthConfiguration", param);
- String[] args = {
- "create-auth-cfg",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_CONFIG_NAME,
- TEST_AUTH_CONFIG
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("createAuthConfiguration");
- }
-
-/*
- * The following test will fail under flat file configuration datastore
- * because there is not notification in place. Auth configuration and instance
- * cannot be returned by the AMAuthConfigurationManager after they are created.
- * Works OK with Sun DS as configuration datastore.
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "update-auth-instance"},
- dependsOnMethods = {"createAuthInstance"})
- public void updateAuthInstance(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("updateAuthInstance", param);
- String[] args = {
- "update-auth-instance",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_INSTANCE_NAME,
- TEST_AUTH_INSTANCE,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES,
- "sunAMAuthDataStoreAuthLevel=1"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("updateAuthInstance");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "get-auth-instance"},
- dependsOnMethods = {"createAuthInstance"})
- public void getAuthInstance(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("getAuthInstance", param);
- String[] args = {
- "get-auth-instance",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_INSTANCE_NAME,
- TEST_AUTH_INSTANCE
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getAuthInstance");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops", "get-auth-cfg-entr"},
- dependsOnMethods = {"createAuthConfiguration"})
- public void getAuthConfigurationEntries(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("getAuthConfigurationEntries", param);
- String[] args = {
- "get-auth-cfg-entr",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_CONFIG_NAME,
- TEST_AUTH_CONFIG
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getAuthConfigurationEntries");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "ops",
- "update-auth-cfg-entr"},
- dependsOnMethods = {"createAuthConfiguration"})
- public void updateAuthConfigurationEntries(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("updateAuthConfigurationEntries", param);
- String[] args = {
- "update-auth-cfg-entr",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_CONFIG_NAME,
- TEST_AUTH_CONFIG,
- CLIConstants.PREFIX_ARGUMENT_LONG + AuthOptions.AUTH_CONFIG_ENTRIES,
- TEST_AUTH_INSTANCE + "|REQUIRED|"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("updateAuthConfigurationEntries");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "delete-auth-instances"}, alwaysRun=true,
- dependsOnGroups = {"ops"},
- dependsOnMethods = {"deleteAuthConfiguration"})
- public void deleteAuthInstance(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("deleteAuthInstance", param);
- String[] args = {
- "delete-auth-instances",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- AuthOptions.AUTH_INSTANCE_NAMES,
- TEST_AUTH_INSTANCE
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("deleteAuthInstance");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-authconfig", "delete-auth-cfgs"}, alwaysRun=true,
- dependsOnGroups = {"ops"})
- public void deleteAuthConfiguration(String realm)
- throws CLIException, AMConfigurationException {
- String[] param = {realm};
- entering("deleteAuthConfiguration", param);
- String[] args = {
- "delete-auth-cfgs",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- AuthOptions.AUTH_CONFIG_NAMES,
- TEST_AUTH_CONFIG
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("deleteAuthConfiguration");
- }
- */
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/datastore/DataStoreTest.java b/openam-test/src/test/java/com/sun/identity/cli/datastore/DataStoreTest.java
deleted file mode 100644
index 6d2efdbb98..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/datastore/DataStoreTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: DataStoreTest.java,v 1.2 2008/06/25 05:44:16 qcheng Exp $
- *
- */
-
-package com.sun.identity.cli.datastore;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.cli.DevNullOutputWriter;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.test.common.TestBase;
-import java.util.HashMap;
-import java.util.Map;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-
-
-/**
- * This is to test the data store sub commands.
- */
-public class DataStoreTest extends TestBase{
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
- private static final String TEST_DATASTORE_NAME = "samplesdatastore";
- private static final String TEST_DATASTORE_TYPE = "files";
-
- /**
- * Creates a new instance of DataStoreTest
- */
- public DataStoreTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- */
- @BeforeTest(groups = {"cli-datastore"})
- public void suiteSetup()
- throws CLIException {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "amadm");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-datastore", "ops", "list-datastores"})
- public void listDataStores(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("listDataStores", param);
- String[] args = {
- "list-datastores",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listDataStores");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-datastore", "ops", "create-datastore"})
- public void createDataStore(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("createDataStore", param);
- String[] args = {
- "create-datastore",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + DatastoreOptions.DATASTORE_NAME,
- TEST_DATASTORE_NAME,
- CLIConstants.PREFIX_ARGUMENT_LONG + DatastoreOptions.DATASTORE_TYPE,
- TEST_DATASTORE_TYPE,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES,
- "sunIdRepoClass=com.sun.identity.idm.plugins.files.FilesRepo",
- "sunFilesIdRepoDirectory=/tmp/clitestdatastore"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("createDataStore");
- }
-
-/*
- * The following test will fail under flat file configuration datastore
- * because there is not notification in place. Service Configurations is not
- * made avaiable after they are created.
- * Works OK with Sun DS as configuration datastore.
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-datastore", "ops", "update-datastore"},
- dependsOnMethods = {"createDataStore"}
- )
- public void updateDataStore(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("updateDataStore", param);
- String[] args = {
- "update-datastore",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + DatastoreOptions.DATASTORE_NAME,
- TEST_DATASTORE_NAME,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES,
- "sunFilesIdRepoDirectory=/tmp/clitestdatastoreChanged"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("updateDataStore");
- } */
-
- @Parameters ({"realm"})
- @AfterSuite(groups = {"cli-datastore", "delete-datastores"})
- public void deleteDataStores(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("deleteDataStores", param);
- String[] args = {
- "delete-datastores",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- DatastoreOptions.DATASTORE_NAMES,
- TEST_DATASTORE_NAME
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("deleteDataStores");
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/definition/MockCLI.java b/openam-test/src/test/java/com/sun/identity/cli/definition/MockCLI.java
deleted file mode 100644
index 7781b0b691..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/definition/MockCLI.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: MockCLI.java,v 1.7 2008/06/25 05:44:18 qcheng Exp $
- *
- */
-
-package com.sun.identity.cli.definition;
-
-import com.sun.identity.cli.annotation.DefinitionClassInfo;
-import com.sun.identity.cli.annotation.ResourceStrings;
-import com.sun.identity.cli.annotation.SubCommandInfo;
-
-
-public class MockCLI {
- @DefinitionClassInfo(
- productName="Mock Product",
- logName="amadm",
- resourceBundle="MockCLI")
- private String product;
-
- @ResourceStrings(
- string={}
- )
- private String resourcestrings;
-
- @SubCommandInfo(
- implClassName="com.sun.identity.cli.DummyCommand",
- description="A dummy command for testing purposes.",
- webSupport="true",
- mandatoryOptions={
- "mandatory|m|s|Mandatory option."},
- optionAliases={},
- macro="",
- optionalOptions={
- "optional|o|s|Optional option.",
- "testmatch|t|u|Set this flag to test options"},
- resourceStrings={
- "mandatory=Mandatory."})
- private String test_command;
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ApplicationPrivilegeCLITest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/ApplicationPrivilegeCLITest.java
deleted file mode 100644
index 490933b0fe..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ApplicationPrivilegeCLITest.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: ApplicationPrivilegeCLITest.java,v 1.2 2009/11/16 21:42:20 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.iplanet.sso.SSOException;
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.entitlement.ApplicationPrivilege;
-import com.sun.identity.entitlement.ApplicationPrivilegeManager;
-import com.sun.identity.entitlement.ApplicationTypeManager;
-import com.sun.identity.entitlement.EntitlementException;
-import com.sun.identity.entitlement.SubjectImplementation;
-import com.sun.identity.entitlement.opensso.OpenSSOUserSubject;
-import com.sun.identity.idm.AMIdentity;
-import com.sun.identity.idm.AMIdentityRepository;
-import com.sun.identity.idm.IdRepoException;
-import com.sun.identity.idm.IdType;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author dennis
- */
-public class ApplicationPrivilegeCLITest extends CLITestImpl {
- private static final String PRIVILEGE_NAME = "ApplicationPrivilegeCLITest";
- private AMIdentity user1;
- private AMIdentity user2;
-
- @Override
- protected void beforeClass() throws Exception {
- user1 = createUser("ApplicationPrivilegeCLITestUser1");
- user2 = createUser("ApplicationPrivilegeCLITestUser2");
- }
-
- @AfterClass
- public void cleanup() throws Exception {
- AMIdentityRepository amir = new AMIdentityRepository(
- adminToken, "/");
- Set identities = new HashSet();
- identities.add(user1);
- identities.add(user2);
- amir.deleteIdentities(identities);
- }
-
- @Test
- public void createApplicationPrivilege() throws Exception {
- String[] args = new String[17];
- args[0] = "add-app-priv";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_APPL_NAME;
- args[6] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_ACTIONS;
- args[8] = ApplicationPrivilegeBase.PARAM_ACTION_ALL;
-
- args[9] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
- args[10] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
-
- args[11] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECTS;
- args[12] = user1.getUniversalId();
-
- args[13] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_DESCRIPTION;
- args[14] = "desc";
-
- args[15] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_RESOURCES;
- args[16] = "http://www.example.com";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- if (!ap.getDescription().equals("desc")) {
- throw new Exception(
- "ApplicationPrivilegeCLITest.createApplicationPrivilege: " +
- "description is incorrect.");
- }
- if (!ap.getActionValues().equals(
- ApplicationPrivilege.PossibleAction.READ_MODIFY_DELEGATE)
- ) {
- throw new Exception(
- "ApplicationPrivilegeCLITest.createApplicationPrivilege: " +
- "actions is incorrect.");
- }
-
- Set resources = new HashSet();
- resources.add("http://www.example.com");
- validateResources(ap, resources, "createApplicationPrivilege");
-
- Set users = new HashSet();
- users.add(user1);
- validateSubjects(ap, users, "createApplicationPrivilege");
- }
-
- private void validateResources(
- ApplicationPrivilege ap,
- Set resources,
- String methodName
- ) throws Exception {
- Set origResources = ap.getResourceNames(
- ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
- if ((origResources == null) ||
- (origResources.size() != resources.size())
- ) {
- throw new Exception(
- "ApplicationPrivilegeCLITest." + methodName + ": " +
- "resources size is incorrect.");
- }
-
- for (String r : origResources) {
- if (!resources.contains(r)) {
- throw new Exception(
- "ApplicationPrivilegeCLITest." + methodName + ": " +
- "resource is incorrect.");
- }
- }
- }
-
- private void validateSubjects(
- ApplicationPrivilege ap,
- Set users,
- String methodName)
- throws Exception {
- Set subjects = ap.getSubjects();
- if ((subjects == null) || (subjects.size() != users.size())) {
- throw new Exception(
- "ApplicationPrivilegeCLITest." + methodName + ": " +
- "subjects is empty.");
- }
-
- for (SubjectImplementation subject : subjects) {
- if (!(subject instanceof OpenSSOUserSubject)) {
- throw new Exception(
- "ApplicationPrivilegeCLITest." + methodName + ": " +
- "subject is incorrect.");
- }
-
- String uuid = ((OpenSSOUserSubject)subject).getID();
- boolean found = false;
- for (AMIdentity user : users) {
- if (uuid.equals(user.getUniversalId())) {
- found = true;
- break;
- }
- }
- if (!found) {
- throw new Exception(
- "ApplicationPrivilegeCLITest." + methodName + ": " +
- "uuid is incorrect.");
- }
- }
- }
-
-
- @Test (dependsOnMethods="createApplicationPrivilege")
- public void listApplicationPrivileges() throws Exception {
- String[] args = new String[3];
- args[0] = "list-app-privs";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-
- @Test (dependsOnMethods="listApplicationPrivileges")
- public void changeDescription() throws Exception {
- String[] args = new String[7];
- args[0] = "update-app-priv";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_DESCRIPTION;
- args[6] = "descChanged";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- if (!ap.getDescription().equals("descChanged")) {
- throw new Exception(
- "ApplicationPrivilegeCLITest.changeDescription: " +
- "description is incorrect.");
- }
- }
-
-
- @Test (dependsOnMethods="changeDescription")
- public void changeAction() throws Exception {
- String[] args = new String[7];
- args[0] = "update-app-priv";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_ACTIONS;
- args[6] = ApplicationPrivilegeBase.PARAM_ACTION_DELEGATE;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- if (!ap.getActionValues().equals(
- ApplicationPrivilege.PossibleAction.READ_DELEGATE)) {
- throw new Exception(
- "ApplicationPrivilegeCLITest.changeAction: " +
- "action is incorrect.");
- }
- }
-
- @Test (dependsOnMethods="changeAction")
- public void setSubjects() throws Exception {
- String[] args = new String[9];
- args[0] = "update-app-priv-subjects";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
- args[6] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECTS;
- args[8] = user2.getUniversalId();
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- Set users = new HashSet();
- users.add(user2);
- validateSubjects(ap, users, "setSubjects");
- }
-
- @Test (dependsOnMethods="setSubjects")
- public void addSubjects() throws Exception {
- String[] args = new String[10];
- args[0] = "update-app-priv-subjects";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
- args[6] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECTS;
- args[8] = user1.getUniversalId();
-
- args[9] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_ADD;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- Set users = new HashSet();
- users.add(user1);
- users.add(user2);
- validateSubjects(ap, users, "setSubjects");
- }
-
- @Test (dependsOnMethods="addSubjects")
- public void removeSubjects() throws Exception {
- String[] args = new String[9];
- args[0] = "remove-app-priv-subjects";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECT_TYPE;
- args[6] = ApplicationPrivilegeBase.PARAM_SUBJECT_USER;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_SUBJECTS;
- args[8] = user2.getUniversalId();
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- Set users = new HashSet();
- users.add(user1);
- validateSubjects(ap, users, "setSubjects");
- }
-
- @Test(dependsOnMethods = "removeSubjects")
- public void setResources() throws Exception {
- String[] args = new String[10];
- args[0] = "update-app-priv-resources";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_APPL_NAME;
- args[6] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_RESOURCES;
- args[8] = "http://www.example1.com";
- args[9] = "http://www.example2.com";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- Set resources = new HashSet();
- resources.add("http://www.example1.com");
- resources.add("http://www.example2.com");
- validateResources(ap, resources, "setResources");
- }
-
- @Test(dependsOnMethods = "setResources")
- public void addResources() throws Exception {
- String[] args = new String[10];
- args[0] = "update-app-priv-resources";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_APPL_NAME;
- args[6] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_RESOURCES;
- args[8] = "http://www.example3.com";
-
- args[9] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_ADD;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- Set resources = new HashSet();
- resources.add("http://www.example1.com");
- resources.add("http://www.example2.com");
- resources.add("http://www.example3.com");
- validateResources(ap, resources, "setResources");
- }
-
- @Test(dependsOnMethods = "addResources")
- public void removeResources() throws Exception {
- String[] args = new String[9];
- args[0] = "remove-app-priv-resources";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_NAME;
- args[4] = PRIVILEGE_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_APPL_NAME;
- args[6] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- ApplicationPrivilegeBase.PARAM_RESOURCES;
- args[8] = "http://www.example3.com";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
- ApplicationPrivilege ap = apm.getPrivilege(PRIVILEGE_NAME);
-
- Set resources = new HashSet();
- resources.add("http://www.example1.com");
- resources.add("http://www.example2.com");
- validateResources(ap, resources, "setResources");
- }
-
- @Test(dependsOnMethods = "removeResources")
- public void removedApplicationPrivilege() throws Exception {
- String[] args = new String[5];
- args[0] = "remove-app-privs";
-
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
-
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- DeleteApplicationPrivilege.PARAM_NAMES;
- args[4] = PRIVILEGE_NAME;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- ApplicationPrivilegeManager apm =
- ApplicationPrivilegeManager.getInstance("/", adminSubject);
-
- try {
- apm.getPrivilege(PRIVILEGE_NAME);
- } catch (EntitlementException ex) {
- if (ex.getErrorCode() != 325) {
- throw ex;
- }
- }
- }
-
- private AMIdentity createUser(String name)
- throws SSOException, IdRepoException {
- AMIdentityRepository amir = new AMIdentityRepository(
- adminToken, "/");
- Map> attrValues = new HashMap>();
- Set set = new HashSet();
- set.add(name);
- attrValues.put("givenname", set);
- attrValues.put("sn", set);
- attrValues.put("cn", set);
- attrValues.put("userpassword", set);
- return amir.createIdentity(IdType.USER, name, attrValues);
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/CLITestImpl.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/CLITestImpl.java
deleted file mode 100644
index cd63bbbab5..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/CLITestImpl.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: CLITestImpl.java,v 1.2 2009/11/10 19:01:05 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.entitlement.opensso.SubjectUtils;
-import com.sun.identity.security.AdminTokenAction;
-import java.security.AccessController;
-import java.util.HashMap;
-import java.util.Map;
-import javax.security.auth.Subject;
-import org.testng.annotations.BeforeClass;
-
-
-public abstract class CLITestImpl {
- protected CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
- protected SSOToken adminToken = (SSOToken) AccessController.doPrivileged(
- AdminTokenAction.getInstance());
- protected Subject adminSubject = SubjectUtils.createSubject(adminToken);
-
- @BeforeClass
- public void setup() throws Exception {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "testclifw");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
-
- beforeClass();
- }
-
- protected void beforeClass() throws Exception {
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/CreateApplicationTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/CreateApplicationTest.java
deleted file mode 100644
index ec918cfcd5..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/CreateApplicationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: CreateApplicationTest.java,v 1.1 2009/08/21 22:27:55 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.entitlement.ApplicationManager;
-import com.sun.identity.entitlement.ApplicationTypeManager;
-import com.sun.identity.entitlement.EntitlementException;
-import com.sun.identity.entitlement.opensso.SubjectUtils;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-
-public class CreateApplicationTest extends CLITestImpl {
- private static final String APPL_NAME = "CreateApplicationTestAppl";
-
- @AfterClass
- public void cleanup() throws EntitlementException {
- ApplicationManager.deleteApplication(SubjectUtils.createSubject(
- adminToken), "/", APPL_NAME);
- }
-
- @Test
- public void createApp() throws CLIException {
- String[] args = new String[18];
- args[0] = "create-appl";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- CreateApplication.PARAM_APPL_NAME;
- args[4] = APPL_NAME;
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- CreateApplication.PARAM_APPL_TYPE_NAME;
- args[6] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
-
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.ATTRIBUTE_VALUES;
- args[8] = CreateApplication.ATTR_ACTIONS + "=GET=true";
- args[9] = CreateApplication.ATTR_ACTIONS + "=POST=true";
- args[10] = CreateApplication.ATTR_CONDITIONS +
- "=com.sun.identity.admin.model.DateRangeCondition";
- args[11] = CreateApplication.ATTR_SUBJECTS +
- "=com.sun.identity.admin.model.IdRepoGroupViewSubject";
- args[12] = CreateApplication.ATTR_RESOURCES +
- "=https://";
- args[13] = CreateApplication.ATTR_SUBJECT_ATTRIBUTE_NAMES +
- "=uid";
- args[14] = CreateApplication.ATTR_ENTITLEMENT_COMBINER +
- "=com.sun.identity.entitlement.DenyOverride";
- args[15] = CreateApplication.ATTR_RESOURCE_COMPARATOR +
- "=com.sun.identity.entitlement.URLResourceName";
- args[16] = CreateApplication.ATTR_SAVE_INDEX +
- "=com.sun.identity.entitlement.util.ResourceNameIndexGenerator";
- args[17] = CreateApplication.ATTR_SEARCH_INDEX +
- "=com.sun.identity.entitlement.util.ResourceNameSplitter";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/DeleteApplicationsTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/DeleteApplicationsTest.java
deleted file mode 100644
index 344f1ddaaa..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/DeleteApplicationsTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: DeleteApplicationsTest.java,v 1.1 2009/08/21 22:27:55 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.entitlement.Application;
-import com.sun.identity.entitlement.ApplicationManager;
-import com.sun.identity.entitlement.ApplicationTypeManager;
-import com.sun.identity.entitlement.DenyOverride;
-import com.sun.identity.entitlement.EntitlementException;
-import java.util.HashMap;
-import java.util.Map;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
-public class DeleteApplicationsTest extends CLITestImpl {
- private static final String APPL_NAME = "DeleteApplicationTestAppl";
-
- @BeforeClass
- @Override
- public void setup() throws Exception {
- super.setup();
- Application appl = ApplicationManager.newApplication("/", APPL_NAME,
- ApplicationTypeManager.getAppplicationType(adminSubject,
- ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
-
- Map actions = new HashMap();
- actions.put("GET", true);
- appl.setActions(actions);
- appl.setEntitlementCombiner(DenyOverride.class);
-
- ApplicationManager.saveApplication(adminSubject, "/", appl);
- }
-
- @AfterClass
- public void cleanup() throws EntitlementException {
- ApplicationManager.deleteApplication(adminSubject, "/", APPL_NAME);
- }
-
- @Test
- public void deleteApp() throws CLIException {
- String[] args = new String[5];
- args[0] = "delete-appls";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- CreateApplication.PARAM_APPL_NAMES;
- args[4] = APPL_NAME;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/DevNullOutputWriter.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/DevNullOutputWriter.java
deleted file mode 100644
index 2a10a91d92..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/DevNullOutputWriter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: DevNullOutputWriter.java,v 1.1 2009/08/21 22:27:55 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.IOutput;
-
-/**
- * For Unit test, this writer does nothing!
- */
-public class DevNullOutputWriter implements IOutput {
-
- private StringBuffer buff = new StringBuffer();
-
- /**
- * Prints message.
- *
- * @param str Message string.
- */
- public void printMessage(String str) {
- buff.append(str).append("\n");
- }
-
- /**
- * Prints message with new line.
- *
- * @param str Message string.
- */
- public void printlnMessage(String str) {
- buff.append(str).append("\n");
- }
-
- /**
- * Prints error.
- *
- * @param str Error message string.
- */
- public void printError(String str) {
- buff.append(str).append("\n");
- }
-
- /**
- * Prints error with new line.
- *
- * @param str Error message string.
- */
- public void printlnError(String str) {
- buff.append(str).append("\n");
- }
-
- public String getMessages() {
- return buff.toString();
- }
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListApplicationTypesTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListApplicationTypesTest.java
deleted file mode 100644
index d4cf570e7e..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListApplicationTypesTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: ListApplicationTypesTest.java,v 1.1 2009/08/21 22:27:55 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import org.testng.annotations.Test;
-
-
-public class ListApplicationTypesTest extends CLITestImpl {
- @Test
- public void listAppTypes() throws CLIException {
- String[] args = new String[1];
- args[0] = "list-appl-types";
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListApplicationsTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListApplicationsTest.java
deleted file mode 100644
index f461af9df6..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListApplicationsTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: ListApplicationsTest.java,v 1.1 2009/08/21 22:27:55 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import org.testng.annotations.Test;
-
-
-public class ListApplicationsTest extends CLITestImpl {
- @Test
- public void listApps() throws CLIException {
- String[] args = new String[3];
- args[0] = "list-appls";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListPolicyNamesTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListPolicyNamesTest.java
deleted file mode 100644
index 9388fe4711..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ListPolicyNamesTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: ListPolicyNamesTest.java,v 1.1 2009/12/18 07:13:28 dillidorai Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.cli.realm.RealmGetPolicy;
-
-import com.sun.identity.entitlement.Entitlement;
-import com.sun.identity.entitlement.EntitlementException;
-import com.sun.identity.entitlement.EntitlementSubject;
-import com.sun.identity.entitlement.Privilege;
-import com.sun.identity.entitlement.PrivilegeManager;
-
-import com.sun.identity.entitlement.opensso.OpenSSOUserSubject;
-import com.sun.identity.entitlement.opensso.SubjectUtils;
-
-import com.sun.identity.security.AdminTokenAction;
-
-import com.sun.identity.sm.ServiceManager;
-
-import java.security.AccessController;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
-public class ListPolicyNamesTest extends CLITestImpl {
-
- private static String APPL_NAME = "iPlanetAMWebAgentService";
-
- private static final String POLICY_NAME1 = "ListPolicyNamesTest1";
- private static final String POLICY_NAME2 = "ListPolicyNamesTest2";
-
- private PrivilegeManager pm;
-
- public void beforeClass() throws EntitlementException {
- pm = PrivilegeManager.getInstance("/",
- SubjectUtils.createSubject(adminToken));
- createPrivilege(POLICY_NAME1);
- createPrivilege(POLICY_NAME2);
- }
-
- @AfterClass
- public void cleanup() throws EntitlementException {
- pm.removePrivilege(POLICY_NAME1);
- pm.removePrivilege(POLICY_NAME2);
- }
-
- @Test
- public void listPolicyNames() throws CLIException {
- String[] args = new String[6];
- args[0] = "list-policies";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- RealmGetPolicy.ARGUMENT_POLICY_NAMES;
- args[4] = "*";
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.NAMES_ONLY;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-
- @Test
- public void listXACMLPolicyNames() throws CLIException {
- String[] args = new String[6];
- args[0] = "list-xacml";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- RealmGetPolicy.ARGUMENT_POLICY_NAMES;
- args[4] = "*";
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.NAMES_ONLY;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-
- private void createPrivilege(String name) throws EntitlementException {
- Map actionValues = new HashMap();
- actionValues.put("GET", Boolean.TRUE);
- actionValues.put("POST", Boolean.FALSE);
- String resourceName = "http://www.listpolicynamestest.com:80";
- Entitlement entitlement = new Entitlement(APPL_NAME,
- resourceName, actionValues);
- entitlement.setName("ent1");
-
- String user = "id=demo,ou=user," + ServiceManager.getBaseDN();
- OpenSSOUserSubject usersubj = new OpenSSOUserSubject();
- usersubj.setID(user);
-
- Privilege priv = Privilege.getNewInstance();
- priv.setName(name);
- priv.setEntitlement(entitlement);
- priv.setSubject(usersubj);
- pm.addPrivilege(priv);
- }
-
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/SetApplicationTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/SetApplicationTest.java
deleted file mode 100644
index d4fbfde00c..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/SetApplicationTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: SetApplicationTest.java,v 1.1 2009/08/21 22:27:55 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.entitlement.Application;
-import com.sun.identity.entitlement.ApplicationManager;
-import com.sun.identity.entitlement.ApplicationTypeManager;
-import com.sun.identity.entitlement.DenyOverride;
-import com.sun.identity.entitlement.EntitlementException;
-import java.util.HashMap;
-import java.util.Map;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-
-public class SetApplicationTest extends CLITestImpl {
- private static final String APPL_NAME = "SetApplicationTestAppl";
-
- @BeforeClass
- @Override
- public void setup() throws Exception {
- super.setup();
- Application appl = ApplicationManager.newApplication("/", APPL_NAME,
- ApplicationTypeManager.getAppplicationType(adminSubject,
- ApplicationTypeManager.URL_APPLICATION_TYPE_NAME));
-
- Map actions = new HashMap();
- actions.put("GET", true);
- appl.setActions(actions);
- appl.setEntitlementCombiner(DenyOverride.class);
-
- ApplicationManager.saveApplication(adminSubject, "/", appl);
- }
-
- @AfterClass
- public void cleanup() throws EntitlementException {
- ApplicationManager.deleteApplication(adminSubject, "/", APPL_NAME);
- }
-
- @Test
- public void modifyApp() throws CLIException {
- String[] args = new String[16];
- args[0] = "set-appl";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- CreateApplication.PARAM_APPL_NAME;
- args[4] = APPL_NAME;
-
- args[5] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.ATTRIBUTE_VALUES;
- args[6] = CreateApplication.ATTR_ACTIONS + "=GET=true";
- args[7] = CreateApplication.ATTR_ACTIONS + "=POST=true";
- args[8] = CreateApplication.ATTR_CONDITIONS +
- "=com.sun.identity.admin.model.DateRangeCondition";
- args[9] = CreateApplication.ATTR_SUBJECTS +
- "=com.sun.identity.admin.model.IdRepoGroupViewSubject";
- args[10] = CreateApplication.ATTR_RESOURCES +
- "=https://";
- args[11] = CreateApplication.ATTR_SUBJECT_ATTRIBUTE_NAMES +
- "=uid";
- args[12] = CreateApplication.ATTR_ENTITLEMENT_COMBINER +
- "=com.sun.identity.entitlement.DenyOverride";
- args[13] = CreateApplication.ATTR_RESOURCE_COMPARATOR +
- "=com.sun.identity.entitlement.URLResourceName";
- args[14] = CreateApplication.ATTR_SAVE_INDEX +
- "=com.sun.identity.entitlement.util.ResourceNameIndexGenerator";
- args[15] = CreateApplication.ATTR_SEARCH_INDEX +
- "=com.sun.identity.entitlement.util.ResourceNameSplitter";
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ShowApplicationTest.java b/openam-test/src/test/java/com/sun/identity/cli/entitlement/ShowApplicationTest.java
deleted file mode 100644
index 48e01f54c5..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/entitlement/ShowApplicationTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: ShowApplicationTest.java,v 1.1 2009/08/21 22:27:56 veiming Exp $
- */
-
-package com.sun.identity.cli.entitlement;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.entitlement.ApplicationTypeManager;
-import org.testng.annotations.Test;
-
-
-public class ShowApplicationTest extends CLITestImpl {
- @Test
- public void createApp() throws CLIException {
- String[] args = new String[5];
- args[0] = "show-appl";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME;
- args[2] = "/";
- args[3] = CLIConstants.PREFIX_ARGUMENT_LONG +
- CreateApplication.PARAM_APPL_NAME;
- args[4] = ApplicationTypeManager.URL_APPLICATION_TYPE_NAME;
-
- CLIRequest req = new CLIRequest(null, args, adminToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/idrepo/IdRepoTest.java b/openam-test/src/test/java/com/sun/identity/cli/idrepo/IdRepoTest.java
deleted file mode 100644
index b857e7a1e3..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/idrepo/IdRepoTest.java
+++ /dev/null
@@ -1,752 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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 $
- *
- */
-
-package com.sun.identity.cli.idrepo;
-
-import com.iplanet.sso.SSOToken;
-import com.iplanet.sso.SSOException;
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.cli.DevNullOutputWriter;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.delegation.DelegationException;
-import com.sun.identity.delegation.DelegationManager;
-import com.sun.identity.delegation.DelegationPrivilege;
-import com.sun.identity.idm.AMIdentity;
-import com.sun.identity.idm.AMIdentityRepository;
-import com.sun.identity.idm.IdRepoException;
-import com.sun.identity.idm.IdSearchControl;
-import com.sun.identity.idm.IdSearchResults;
-import com.sun.identity.idm.IdType;
-import com.sun.identity.test.common.TestBase;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-/**
- * This is to test the idrepo related sub commands.
- */
-public class IdRepoTest extends TestBase{
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
-
- private static final String TOP_LEVEL_ADMIN_GROUP = "Top-Level Admin Group";
- private static final String DUMMY_GROUP = "IdRepoDevUnitTestGroup";
-
- /**
- * Creates a new instance of IdRepoTest
- */
- public IdRepoTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- */
- @BeforeTest(groups = {"cli-idrepo"})
- public void suiteSetup()
- throws CLIException {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "amadm");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
- @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 arguments = new ArrayList();
- 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");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-idrepo", "show-identity-types"})
- public void getIdentityTypes(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("getIdentityTypes", param);
- String[] args = {
- "show-identity-types",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getIdentityTypes");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-idrepo", "show-identity-ops"})
- public void getIdentityOperations(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("getIdentityOperations", param);
- String[] args = {
- "show-identity-ops",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "User"};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getIdentityOperations");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "list-identities"},
- dependsOnMethods = {"createIdentity"})
- public void listIdentities(String realm, String uid)
- throws CLIException {
- String[] param = {realm, uid};
- entering("listIdentities", param);
- String[] args = {
- "list-identities",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "User",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.FILTER,
- uid,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listIdentities");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "get-identity"},
- dependsOnMethods = {"createIdentity"})
- public void getAttributes(String realm, String uid)
- throws CLIException {
- String[] param = {realm, uid};
- entering("getAttributes", param);
- String[] args = {
- "get-identity",
- 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("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");
-// }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "list-identity-assignable-svcs"},
- dependsOnMethods = {"createIdentity"})
- public void getAssignableServices(String realm, String uid)
- throws CLIException {
- String[] param = {realm, uid};
- entering("getAssignableServices", param);
- String[] args = {
- "list-identity-assignable-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("getAssignableServices");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "add-svc-identity"},
- dependsOnMethods = {"createIdentity"})
- public void assignServices(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("assignServices", param);
- String[] args = {
- "add-svc-identity",
- 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,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- "iPlanetAMSessionService",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES,
- "iplanet-am-session-quota-limit=10"};
-
- 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);
- Set services = amid.getAssignedServices();
- assert services.contains("iPlanetAMSessionService");
- exiting("assignServices");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "remove-svc-identity"},
- dependsOnMethods = {"setServiceAttributes", "getServiceAttributes",
- "getAttributes"})
- public void unassignServices(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("unassignServices", param);
- String[] args = {
- "remove-svc-identity",
- 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,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- "iPlanetAMSessionService"};
-
- 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);
- Set services = amid.getAssignedServices();
- for (Iterator i = services.iterator(); i.hasNext(); ) {
- String svc = (String)i.next();
- assert (!svc.equals("iPlanetAMSessionService"));
- }
- exiting("unassignServices");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "show-identity-svc-attrs"},
- dependsOnMethods = {"assignServices"})
- public void getServiceAttributes(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("getServiceAttributes", param);
- String[] args = {
- "show-identity-svc-attrs",
- 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,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- "iPlanetAMSessionService"};
-
- SSOToken adminSSOToken = getAdminSSOToken();
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getServiceAttributes");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "set-identity-svc-attrs"},
- dependsOnMethods = {"assignServices"})
- public void setServiceAttributes(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("setServiceAttributes", param);
- String[] args = {
- "set-identity-svc-attrs",
- 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,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- "iPlanetAMSessionService",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES,
- "iplanet-am-session-quota-limit=1"
- };
-
- SSOToken adminSSOToken = getAdminSSOToken();
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- AMIdentity user = new AMIdentity(
- adminSSOToken, uid, IdType.USER, realm, null);
- Map attrValues = user.getServiceAttributes("iPlanetAMSessionService");
- Set values = (Set)attrValues.get("iplanet-am-session-quota-limit");
- String val = (String)values.iterator().next();
- assert val.equals("1");
- exiting("setServiceAttributes");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "set-svc-attrs"},
- dependsOnMethods = {"assignServices"})
- public void setAttributes(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("setAttributes", param);
- String[] args = {
- "set-identity-attrs",
- 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,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES,
- "cn=commonname"
- };
-
- SSOToken adminSSOToken = getAdminSSOToken();
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- AMIdentity user = new AMIdentity(
- adminSSOToken, uid, IdType.USER, realm, null);
- Map attrValues = user.getServiceAttributes("iPlanetAMUserService");
- Set values = (Set)attrValues.get("cn");
- String val = (String)values.iterator().next();
- assert val.equals("commonname");
- exiting("setAttributes");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "get-identity-svcs"},
- dependsOnMethods = {"createIdentity"})
- public void getIdentityServices(String realm, String uid)
- throws CLIException {
- String[] param = {realm, uid};
- entering("getIdentityServices", 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("getIdentityServices");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "show-members"},
- dependsOnMethods = {"createIdentity"})
- public void getMembers(String realm, String uid)
- throws CLIException {
- String[] param = {realm, uid};
- entering("getMembers", param);
- String[] args = {
- "show-members",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "Group",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_NAME,
- DUMMY_GROUP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- GetMembers.ARGUMENT_MEMBERSHIP_IDTYPE,
- "User",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getMembers");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "show-memberships"},
- dependsOnMethods = {"createIdentity"})
- public void getMemberships(String realm, String uid)
- throws CLIException {
- String[] param = {realm, uid};
- entering("getMemberships", param);
- String[] args = {
- "show-memberships",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "User",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_NAME,
- uid,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- GetMemberships.ARGUMENT_MEMBERSHIP_IDTYPE,
- "Group",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getMemberships");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "add-members"},
- dependsOnMethods = {"createIdentity"})
- public void addMember(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("addMember", param);
- createDummyGroup(realm);
- String[] args = {
- "add-member",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "Group",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_NAME,
- DUMMY_GROUP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_MEMBER_IDNAME,
- uid,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_MEMBER_IDTYPE,
- "User",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- SSOToken adminSSOToken = getAdminSSOToken();
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- AMIdentity group = new AMIdentity(
- adminSSOToken, DUMMY_GROUP, IdType.GROUP, realm, null);
- AMIdentity user = new AMIdentity(
- adminSSOToken, uid, IdType.USER, realm, null);
- Set members = group.getMembers(IdType.USER);
- assert (members.contains(user));
- exiting("addMember");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "add-members"},
- dependsOnMethods = {"addMember"})
- public void removeMember(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("removeMember", param);
- String[] args = {
- "remove-member",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "Group",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_NAME,
- DUMMY_GROUP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_MEMBER_IDNAME,
- uid,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_MEMBER_IDTYPE,
- "User",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- SSOToken adminSSOToken = getAdminSSOToken();
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- AMIdentity group = new AMIdentity(
- adminSSOToken, DUMMY_GROUP, IdType.GROUP, realm, null);
- Set members = group.getMembers(IdType.USER);
- for (Iterator i = members.iterator(); i.hasNext(); ) {
- AMIdentity x = (AMIdentity)i.next();
- assert (!x.getName().equals(uid));
- }
- deleteDummyGroup(realm);
- exiting("removeMember");
- }
-
- @Parameters ({"realm", "uid"})
- @Test(groups = {"cli-idrepo", "show-privileges"},
- dependsOnMethods = {"createIdentity"})
- public void getPrivileges(String realm, String uid)
- throws CLIException, IdRepoException, SSOException {
- String[] param = {realm, uid};
- entering("getPrivileges", param);
- String[] args = {
- "show-privileges",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_TYPE,
- "Group",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IdentityCommand.ARGUMENT_ID_NAME,
- TOP_LEVEL_ADMIN_GROUP,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- SSOToken adminSSOToken = getAdminSSOToken();
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- 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");
- }
- */
-
- private AMIdentity createDummyGroup(String realm)
- throws IdRepoException, SSOException {
- AMIdentityRepository amir = new AMIdentityRepository(
- getAdminSSOToken(), realm);
- return amir.createIdentity(IdType.GROUP, DUMMY_GROUP,
- Collections.EMPTY_MAP);
- }
-
- private void deleteDummyGroup(String realm)
- throws IdRepoException, SSOException {
- SSOToken adminSSOToken = getAdminSSOToken();
- AMIdentityRepository amir = new AMIdentityRepository(
- adminSSOToken, realm);
- AMIdentity amid = new AMIdentity(
- adminSSOToken, DUMMY_GROUP, IdType.GROUP, realm, null);
- Set set = new HashSet(2);
- set.add(amid);
- amir.deleteIdentities(set);
- }
-
-
- @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");
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/realm/RealmTest.java b/openam-test/src/test/java/com/sun/identity/cli/realm/RealmTest.java
deleted file mode 100644
index 73372f8ffe..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/realm/RealmTest.java
+++ /dev/null
@@ -1,491 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: RealmTest.java,v 1.8 2008/06/25 05:44:18 qcheng Exp $
- *
- */
-
-/**
- * Portions Copyrighted 2012 ForgeRock Inc
- */
-package com.sun.identity.cli.realm;
-
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.cli.DevNullOutputWriter;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.idm.AMIdentity;
-import com.sun.identity.idm.AMIdentityRepository;
-import com.sun.identity.idm.IdRepoException;
-import com.sun.identity.policy.NameNotFoundException;
-import com.sun.identity.policy.Policy;
-import com.sun.identity.policy.PolicyException;
-import com.sun.identity.policy.PolicyManager;
-import com.sun.identity.shared.test.CollectionUtils;
-import com.sun.identity.sm.OrganizationConfigManager;
-import com.sun.identity.sm.SMSException;
-import com.sun.identity.test.common.TestBase;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-/**
- * This is to test the realm related sub commands.
- */
-public class RealmTest extends TestBase{
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
-
- /**
- * Creates a new instance of RealmTest
- */
- public RealmTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- */
- @BeforeTest(groups = {"cli-realm"})
- public void suiteSetup()
- throws CLIException {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "amadm");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
- @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");
- }
-
- @Parameters ({"parent-realm"})
- @Test(groups = {"cli-realm", "list-realms"})
- public void listRealms(String parentRealm)
- throws CLIException, SMSException {
- String[] param = {parentRealm};
- entering("listRealms", param);
- String[] args = {
- "list-realms",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.FILTER,
- "*",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- parentRealm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listRealms");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-realm", "list-realm-assignable-svcs"})
- public void getAssignableServicesInRealm(String realm)
- throws CLIException, SMSException {
- String[] param = {realm};
- entering("getAssignableServicesInRealm", param);
- String[] args = {
- "list-realm-assignable-svcs",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getAssignableServicesInRealm");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-realm", "show-realm-svcs"})
- public void getAssignedServicesInRealm(String realm)
- throws CLIException, SMSException {
- String[] param = {realm};
- entering("getAssignedServicesInRealm", param);
- String[] args = {
- "show-realm-svcs",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm};
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getAssignedServicesInRealm");
- }
-
- @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");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-realm", "get-realm"})
- public void getRealmAttributeValues(String realm)
- throws CLIException {
- String[] param = {realm};
- entering("getRealmAttributeValues", param);
- String[] args = {
- "get-realm",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- "/",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- "sunIdentityRepositoryService"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getRealmAttributeValues");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-realm", "set-realm-attrs"},
- dependsOnMethods = {"removeRealmAttribute"})
- public void setRealmAttributeValues(String realm)
- throws CLIException, SMSException, SSOException {
- String[] param = {realm};
- entering("setRealmAttributeValues", 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,
- "sunOrganizationStatus=Active"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- OrganizationConfigManager ocm = new OrganizationConfigManager(
- getAdminSSOToken(), realm);
- Map values = ocm.getAttributes("sunIdentityRepositoryService");
- Set attrValues = (Set)values.get("sunOrganizationStatus");
- assert attrValues.contains("Active");
- exiting("setRealmAttributeValues");
- }
-
- @Parameters ({"realm"})
- @Test(groups = {"cli-realm", "delete-realm-attr"})
- public void removeRealmAttribute(String realm)
- throws CLIException, SMSException, SSOException {
- String[] param = {realm};
- entering("removeRealmAttribute", param);
- String[] args = {
- "delete-realm-attr",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- "sunIdentityRepositoryService",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_NAME,
- "sunOrganizationStatus"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- OrganizationConfigManager ocm = new OrganizationConfigManager(
- getAdminSSOToken(), realm);
- Map values = ocm.getAttributes("sunIdentityRepositoryService");
- Set attrValues = (Set)values.get("sunOrganizationStatus");
- assert (attrValues == null);
- exiting("removeRealmAttribute");
- }
-
- @Test(groups = {"cli-realm", "create-policies"})
- public void createPolicy()
- throws CLIException, PolicyException, SSOException {
- entering("createPolicy", null);
- String[] args = {
- "create-policies",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- "/",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.XML_FILE,
- "mock/cli/createpolicy.xml"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- PolicyManager pm = new PolicyManager(getAdminSSOToken(), "/");
- Policy p = pm.getPolicy("clipolicy");
- assert (p != null);
- exiting("createPolicy");
- }
-
- @Test(groups = {"cli-realm", "list-policies"},
- dependsOnMethods = {"createPolicy"})
- public void getPolicy()
- throws CLIException, PolicyException, SSOException {
- entering("getPolicy", null);
- String[] args = {
- "list-policies",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- "/"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getPolicy");
- }
-
- @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");
- }
-
- @Parameters ({"realm", "service-name"})
- @Test(groups = {"cli-realm", "services", "show-realm-svc-attrs"},
- dependsOnMethods = {"assignedServiceToRealm"})
- public void getServiceAttribute(String realm, String serviceName)
- throws CLIException {
- String[] param = {realm};
- entering("getServiceAttribute", param);
- String[] args = {
- "get-realm-svc-attrs",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- serviceName
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("getServiceAttribute");
- }
-
-
- @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> 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");
- }
-
- @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");
- }
-
- @Parameters ({"realm", "service-name", "attribute-value"})
- @Test(groups = {"cli-realm", "remove-svc-realm"},
- dependsOnGroups = {"services"})
- public void unassignServiceFromRealm(
- String realm,
- String serviceName,
- String attributeValue
- ) throws CLIException, IdRepoException, SSOException {
- String[] param = {realm};
- entering("unassignServiceFromRealm", param);
- String[] args = {
- "remove-svc-realm",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
- realm,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- serviceName
- };
-
- 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 orig = CollectionUtils.parseStringToMap(attributeValue);
- assert !map.equals(orig);
- exiting("unassignServiceFromRealm");
- }
-
- @Parameters ({"realm"})
- @AfterTest(groups = {"cli-realm", "delete-realm"})
- public void deleteRealm(String realm)
- throws CLIException, SMSException {
- String[] param = {realm};
- entering("deleteRealm", param);
- String[] args = {
- "delete-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 results = ocm.getSubOrganizationNames(realmName, false);
- assert (results.isEmpty());
- exiting("deleteRealm");
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/cli/schema/SchemaTest.java b/openam-test/src/test/java/com/sun/identity/cli/schema/SchemaTest.java
deleted file mode 100644
index e278693d5e..0000000000
--- a/openam-test/src/test/java/com/sun/identity/cli/schema/SchemaTest.java
+++ /dev/null
@@ -1,1693 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: SchemaTest.java,v 1.6 2008/06/25 05:44:19 qcheng Exp $
- *
- */
-
-/**
- * Portions Copyrighted 2012 ForgeRock Inc
- */
-package com.sun.identity.cli.schema;
-
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.cli.DevNullOutputWriter;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.sm.AttributeSchema;
-import com.sun.identity.sm.PluginInterface;
-import com.sun.identity.sm.SMSException;
-import com.sun.identity.sm.SchemaType;
-import com.sun.identity.sm.ServiceConfig;
-import com.sun.identity.sm.ServiceConfigManager;
-import com.sun.identity.sm.ServiceNotFoundException;
-import com.sun.identity.sm.ServiceSchema;
-import com.sun.identity.sm.ServiceSchemaManager;
-import com.sun.identity.test.common.TestBase;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-public class SchemaTest extends TestBase {
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
- private static String MOCK_DIR = "mock/cli";
- private static String TEST_SERVICE_XML = MOCK_DIR + "/testService.xml";
- private static String TEST_SERVICE = "TestService";
-
- public SchemaTest() {
- super("CLI");
- }
-
- /**
- * Create the CLIManager.
- *
- */
- @BeforeTest(groups = {"cli"})
- public void suiteSetup()
- throws CLIException
- {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "amadm");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.cli.AccessManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
- @BeforeTest(groups = {"schema", "subschema"})
- public void loadSchema()
- throws CLIException, SMSException, SSOException {
- entering("loadSchema", null);
- try {
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- TEST_SERVICE, getAdminSSOToken());
- } catch (SMSException ex) {
- //create the service if it does not exist
- List list = new ArrayList();
- list.add(TEST_SERVICE_XML);
-
- try {
- createServices(list);
- assert serviceExists(TEST_SERVICE);
- exiting("loadSchema");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "loadSchema", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "loadSchema", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "loadSchema", e.getMessage());
- throw e;
- }
- }
- }
-
- @AfterTest(groups = {"schema", "subschema"})
- public void deleteService() throws Exception {
- entering("deleteService", null);
- List serviceNames = new ArrayList();
- serviceNames.add(TEST_SERVICE);
- deleteServices(serviceNames);
-
- try {
- cmdManager.serviceRequestQueue();
- assert !serviceExists(TEST_SERVICE);
- } catch (Exception e) {
- this.log(Level.SEVERE, "deleteService", e.getMessage());
- throw e;
- } finally {
- exiting("deleteService");
- }
- }
-
-
- @Test(groups = {"schema", "create-svc"})
- public void loadMultipleServices()
- throws CLIException, SMSException, SSOException {
- entering("loadMultipleServices", null);
- List list = new ArrayList();
- list.add(MOCK_DIR + "/testService1.xml");
- list.add(MOCK_DIR + "/testService2.xml");
- list.add(MOCK_DIR + "/testService3.xml");
-
- try {
- createServices(list);
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- "TestService1", getAdminSSOToken());
- assert serviceExists("TestService1");
- assert serviceExists("TestService2");
- assert serviceExists("TestService3");
- exiting("loadMultipleServices");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "loadMultipleServices", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "loadMultipleServices", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "loadMultipleServices", e.getMessage());
- throw e;
- }
- }
-
- @Test(groups = {"schema", "delete-svc"},
- dependsOnMethods = {"loadMultipleServices"}
- )
- public void deleteMultipleServices() throws Exception {
- entering("deleteMultipleServices", null);
- List list = new ArrayList();
- list.add("TestService1");
- list.add("TestService2");
- list.add("TestService3");
-
- try {
- deleteServices(list);
-
- assert !serviceExists("TestService1");
- assert !serviceExists("TestService2");
- assert !serviceExists("TestService3");
- } catch (Exception e) {
- this.log(Level.SEVERE, "deleteMultipleServices", e.getMessage());
- throw e;
- } finally {
- exiting("deleteMultipleServices");
- }
- }
-
- @Test(groups = {"schema", "set-inheritance"})
- public void setInheritance()
- throws CLIException, SMSException, SSOException {
- entering("setInheritance", null);
- String[] args = {"set-inheritance",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE,
- "global",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUBSCHEMA_NAME,
- "subschema-inheritance",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- ModifyInheritance.ARGUMENT_INHERITANCE,
- "multiple"
- };
- 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 ss = globalSchema.getSubSchema(
- "subschema-inheritance");
- assert ss.supportsMultipleConfigurations();
- exiting("setInheritance");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setInheritance", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setInheritance", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setInheritance", e.getMessage());
- throw e;
- }
- }
-
- @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;
- }
- }
-
- @Test(groups = {"schema", "delete-sub-cfg"},
- dependsOnMethods = {"setSubConfiguration"})
- public void deleteSubConfiguration()
- throws CLIException, SMSException, SSOException {
- entering("deleteSubConfiguration", null);
- String[] args = {"delete-sub-cfg",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG +IArgument.SUB_CONFIGURATION_NAME,
- "/testConfig"
- };
- 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("deleteSubConfiguration");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "deleteSubConfiguration", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "deleteSubConfiguration", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "deleteSubConfiguration", e.getMessage());
- throw e;
- }
- }
-
- @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;
- }
- }
-
- @Test(groups = {"schema", "add-plugin-interface"})
- public void addPluginInterface()
- throws CLIException, SMSException, SSOException {
- entering("addPluginInterface", null);
- String[] args = {"add-plugin-interface",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- AddPluginInterface.ARGUMENT_I18N_KEY,
- "123",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- AddPluginInterface.ARGUMENT_PLUGIN_NAME,
- "testPlugIn",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- AddPluginInterface.ARGUMENT_INTERFACE_NAME,
- "com.sun.identity.cli.schema.DummyInterface"};
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
-
- try {
- cmdManager.serviceRequestQueue();
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- TEST_SERVICE, getAdminSSOToken());
- PluginInterface pl = mgr.getPluginInterface("testPlugIn");
- assert (pl != null);
- exiting("addPluginInterface");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "addPluginInterface", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "addPluginInterface", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "addPluginInterface", e.getMessage());
- throw e;
- }
- }
-
- private Map getSubConfigurationValues(String name)
- throws SMSException, SSOException {
- ServiceConfigManager scm = new ServiceConfigManager(
- TEST_SERVICE, getAdminSSOToken());
- ServiceConfig sc = scm.getGlobalConfig(null);
- sc = sc.getSubConfig("testConfig");
- return sc.getAttributes();
- }
-
- @Test(groups = {"schema", "set-svc-i18n-key"})
- public void setServiceI18nKey()
- throws CLIException, SMSException, SSOException {
- entering("setServiceI18nKey", null);
- String[] args = {"set-svc-i18n-key",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- SetServiceSchemaI18nKey.ARGUMENT_I18N_KEY,
- "service-18nKey"
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
-
- try {
- cmdManager.serviceRequestQueue();
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- TEST_SERVICE, getAdminSSOToken());
- assert mgr.getI18NKey().equals("service-18nKey");
- exiting("setServiceI18nKey");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setServiceI18nKey", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setServiceI18nKey", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setServiceI18nKey", e.getMessage());
- throw e;
- }
- }
-
- @Test(groups = {"schema", "set-svc-view-bean-url"})
- public void setServiceViewBeanURL()
- throws CLIException, SMSException, SSOException {
- entering("setServiceViewBeanURL", null);
- String[] args = {"set-svc-view-bean-url",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- SetServiceSchemaPropertiesViewBeanURL.ARGUMENT_URL,
- "mockviewbeanURL"
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
-
- try {
- cmdManager.serviceRequestQueue();
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- TEST_SERVICE, getAdminSSOToken());
- assert mgr.getPropertiesViewBeanURL().equals("mockviewbeanURL");
- exiting("setServiceViewBeanURL");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setServiceViewBeanURL", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setServiceViewBeanURL", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setServiceViewBeanURL", e.getMessage());
- throw e;
- }
- }
-
- private void updateService()
- throws CLIException, SMSException, SSOException {
- entering("updateService", null);
- String[] args = {"update-svc",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.XML_FILE,
- TEST_SERVICE_XML
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
-
- try {
- cmdManager.serviceRequestQueue();
- assert serviceExists(TEST_SERVICE);
- exiting("updateService");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "updateService", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "updateService", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "updateService", e.getMessage());
- throw e;
- }
- }
-
- @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;
- }
- }
-
- @Test(groups = {"schema", "remove-sub-schema"},
- dependsOnMethods = {"addSubSchema"})
- public void removeSubSchema()
- throws CLIException, SMSException, SSOException {
- entering("removeSubSchema", null);
- String[] args = {"remove-sub-schema",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SCHEMA_TYPE,
- "global",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- RemoveSubSchema.ARGUMENT_SCHEMA_NAMES,
- "subschema"
- };
- 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("removeSubSchema");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "removeSubSchema", e.getMessage());
- throw e;
- }
- }
-
- @Test(groups = {"schema", "set-revision-number", "get-revision-number"})
- public void setGetServiceRevisionNumber()
- throws CLIException, SMSException, SSOException {
- entering("setGetServiceRevisionNumber", null);
- String[] args = {"set-revision-number",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- SetServiceRevisionNumber.ARGUMENT_VERSION,
- "20"
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- String[] arg1s = {"get-revision-number",
- CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME,
- TEST_SERVICE
- };
- req = new CLIRequest(null, arg1s, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
-
- try {
- cmdManager.serviceRequestQueue();
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- TEST_SERVICE, getAdminSSOToken());
- assert (mgr.getRevisionNumber() == 20);
- exiting("setGetServiceRevisionNumber");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setGetServiceRevisionNumber",
- e.getMessage());
- throw e;
- }
- }
-
- @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;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "add-attr-defs", "attribute-schema-ops",
- "subschema"},
- dependsOnMethods = {"addAttributeSchema"}
- )
- public void addAttributeDefaultValues(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("addAttributeDefaultValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[7] : new String[9];
- args[0] = "add-attr-defs";
- 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_VALUES;
- args[6] = "mock-add=test1";
-
- 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);
- 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");
- Set values = as.getDefaultValues();
- assert (values.size() == 1);
- assert (values.contains("test1"));
- exiting("addAttributeDefaultValues");
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "add-attribute-default-values", "attribute-schema-ops",
- "subschema"},
- dependsOnMethods = {"showAttributeDefaultValues"}
- )
- public void deleteAttributeDefaultValues(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("deleteAttributeDefaultValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
- args[0] = "delete-attr-def-values";
- 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 + IArgument.DEFAULT_VALUES;
- args[8] = "test1";
-
- 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);
- 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");
- Set values = as.getDefaultValues();
- assert (!values.contains("test1"));
- exiting("deleteAttributeDefaultValues");
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-defs", "attribute-schema-ops",
- "subschema"},
- dependsOnMethods = {"deleteAttributeDefaultValues"}
- )
- public void setAttributeDefaults(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeDefaults", params);
-
- SSOToken adminSSOToken = getAdminSSOToken();
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- TEST_SERVICE, adminSSOToken);
- ServiceSchema serviceSchema = mgr.getGlobalSchema();
- if (subschema.length() > 0) {
- serviceSchema = serviceSchema.getSubSchema(subschema);
- }
- AttributeSchema as = serviceSchema.getAttributeSchema("mock-add");
- as.addChoiceValue("testx", "testx");
- //as.addChoiceValue("testy", "testy");
-
- String[] args = (subschema.length() == 0)
- ? new String[7] : new String[9];
- args[0] = "set-attr-defs";
- 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_VALUES;
- args[6] = "mock-add=testx";
- //args[7] = "mock-add=testy";
-
- if (subschema.length() > 0) {
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.SUBSCHEMA_NAME;
- args[8] = subschema;
- }
-
- CLIRequest req = new CLIRequest(null, args, adminSSOToken);
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- mgr = new ServiceSchemaManager(TEST_SERVICE, adminSSOToken);
- serviceSchema = mgr.getGlobalSchema();
- if (subschema.length() > 0) {
- serviceSchema = serviceSchema.getSubSchema(subschema);
- }
-
- as = serviceSchema.getAttributeSchema("mock-add");
- Set defaultValues = as.getDefaultValues();
- assert (defaultValues.size() == 1);
- assert (defaultValues.contains("testx"));
- //assert (defaultValues.contains("testy"));
- exiting("setAttributeDefaults");
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-view-bean-url",
- "attribute-schema-ops", "subschema"},
- dependsOnMethods = {"addAttributeSchema"}
- )
- public void setAttributeViewBeanURL(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
-
- entering("setAttributeViewBeanURL", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-view-bean-url";
- 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 +
- ModifyAttributeSchemaPropertiesViewBeanURL.ARGUMENT_URL;
- args[8] = "mockattributeURL";
-
- 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.getPropertiesViewBeanURL().equals("mockattributeURL"));
- exiting("setAttributeViewBeanURL");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeViewBeanURL", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeViewBeanURL", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeViewBeanURL", e.getMessage());
- throw e;
- }
- }
-
-
- @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;
- }
- }
-
- @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;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-type", "attribute-schema-ops",
- "subschema"},
- dependsOnMethods = {"addAttributeSchema", "showAttributeDefaultValues"}
- )
- public void setAttributeSchemaType(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaType", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-type";
- 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 +
- ModifyAttributeSchemaType.ARGUMENT_TYPE;
- args[8] = "multiple_choice";
-
- 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.getType().equals(AttributeSchema.Type.MULTIPLE_CHOICE));
- exiting("setAttributeSchemaType");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaType", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaType", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaType", e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-syntax", "attribute-schema-ops",
- "subschema"},
- dependsOnMethods = {"addAttributeSchema", "showAttributeDefaultValues"}
- )
- public void setAttributeSchemaSyntax(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaSyntax", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-syntax";
- 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 +
- ModifyAttributeSchemaSyntax.ARGUMENT_SYNTAX;
- args[8] = "paragraph";
-
- 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.getSyntax().equals(AttributeSchema.Syntax.PARAGRAPH));
- exiting("setAttributeSchemaSyntax");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaSyntax", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaSyntax", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaSyntax", e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-ui-type", "attribute-schema-ops",
- "subschema"},
- dependsOnMethods = {"addAttributeSchema", "showAttributeDefaultValues"}
- )
- public void setAttributeSchemaUIType(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaUIType", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-ui-type";
- 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 +
- ModifyAttributeSchemaUIType.ARGUMENT_UI_TYPE;
- args[8] = "button";
-
- 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.getUIType().equals(AttributeSchema.UIType.BUTTON));
- exiting("setAttributeSchemaUIType");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaUIType", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaUIType", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaUIType", e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-start-range", "subschema"})
- public void setAttributeSchemaStartRange(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaStartRange", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-start-range";
- 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-number";
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- SetAttributeSchemaStartRange.ARGUMENT_RANGE;
- args[8] = "10";
-
- 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-number");
- assert as.getStartRange().equals("10");
- exiting("setAttributeSchemaStartRange");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaStartRange",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaStartRange",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaStartRange",
- e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-end-range", "subschema"})
- public void setAttributeSchemaEndRange(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaEndRange", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-end-range";
- 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-number";
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG +
- SetAttributeSchemaEndRange.ARGUMENT_RANGE;
- args[8] = "100";
-
- 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-number");
- assert as.getEndRange().equals("100");
- exiting("setAttributeSchemaEndRange");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaEndRange",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaEndRange",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaEndRange",
- e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-validator",
- "attribute-schema-ops", "subschema"})
- public void setAttributeSchemaValidator(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaValidator", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-validator";
- 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 +
- SetAttributeSchemaValidator.ARGUMENT_VALIDATOR;
- args[8] = "com.dummy.Dummy";
-
- 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");
- /*
- * unable to verify because AttributeSchema does not have
- * getValidator method. Hence pass if there are no exceptions.
- */
- exiting("setAttributeSchemaValidator");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaValidator",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaValidator",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaValidator",
- e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-choicevals",
- "attribute-schema-ops", "subschema"})
- public void setAttributeSchemaChoiceValues(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaChoiceValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "set-attr-choicevals";
- 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_NAME;
- args[6] = "mock-single-choice";
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.CHOICE_VALUES;
- args[8] = "i18nKey1=choice1";
-
- 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-single-choice");
- String[] choiceValues = as.getChoiceValues();
- assert (choiceValues.length == 1);
- assert choiceValues[0].equals("choice1");
- String i18nKey = as.getChoiceValueI18NKey("choice1");
- assert i18nKey.equals("i18nKey1");
- exiting("setAttributeSchemaChoiceValues");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaChoiceValues",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaChoiceValues",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaChoiceValues",
- e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "remove-attr-choicevals",
- "attribute-schema-ops", "subschema"},
- dependsOnMethods = {"setAttributeSchemaChoiceValues"})
- public void removeAttributeSchemaChoiceValues(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("removeAttributeSchemaChoiceValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[9] : new String[11];
-
- args[0] = "remove-attr-choicevals";
- 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_NAME;
- args[6] = "mock-single-choice";
- args[7] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.CHOICE_VALUES;
- args[8] = "choice1";
-
- 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-single-choice");
- String[] choiceValues = as.getChoiceValues();
- assert (choiceValues.length == 0);
- exiting("removeAttributeSchemaChoiceValues");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "removeAttributeSchemaChoiceValues",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "removeAttributeSchemaChoiceValues",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "removeAttributeSchemaChoiceValues",
- e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "set-attr-bool-values", "subschema"})
- public void setAttributeSchemaBooleanValues(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("setAttributeSchemaBooleanValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[15] : new String[17];
-
- args[0]= "set-attr-bool-values";
- 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_NAME;
- args[6]= "mock-boolean";
- args[7]= CLIConstants.PREFIX_ARGUMENT_LONG +
- SetAttributeSchemaBooleanValues.ARGUMENT_TRUE_VALUE;
- args[8]= "true";
- args[9]= CLIConstants.PREFIX_ARGUMENT_LONG +
- SetAttributeSchemaBooleanValues.ARGUMENT_TRUE_I18N_KEY;
- args[10]= "truei18nKey";
- args[11]= CLIConstants.PREFIX_ARGUMENT_LONG +
- SetAttributeSchemaBooleanValues.ARGUMENT_FALSE_VALUE;
- args[12]= "false";
- args[13]= CLIConstants.PREFIX_ARGUMENT_LONG +
- SetAttributeSchemaBooleanValues.ARGUMENT_FALSE_I18N_KEY;
- args[14]= "falsei18nKey";
-
- if (subschema.length() > 0) {
- args[15] = CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.SUBSCHEMA_NAME;
- args[16] = 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-boolean");
- assert (as.getTrueValue().equals("true"));
- assert (as.getTrueValueI18NKey().equals("truei18nKey"));
- assert (as.getFalseValue().equals("false"));
- assert (as.getFalseValueI18NKey().equals("falsei18nKey"));
- exiting("setAttributeSchemaBooleanValues");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "setAttributeSchemaBooleanValues",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "setAttributeSchemaBooleanValues",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "setAttributeSchemaBooleanValues",
- e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "delete-attr", "subschema"},
- dependsOnGroups = {"attribute-schema-ops"}
- )
- public void deleteAttributeSchema(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("deleteAttributeSchema", params);
- String[] args = (subschema.length() == 0)
- ? new String[7] : new String[9];
-
- args[0] = "delete-attr";
- 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";
-
- 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("deleteAttributeSchema");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "deleteAttributeSchema", e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "deleteAttributeSchema", e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "deleteAttributeSchema", e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "show-attr-defs",
- "attribute-schema-ops", "subschema"},
- dependsOnMethods = {"addAttributeDefaultValues"}
- )
- public void showAttributeDefaultValues(String subschema)
- throws CLIException {
- Object[] params = {subschema};
- entering("showAttributeDefaultValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[7] : new String[9];
-
- args[0] = "get-attr-defs";
- 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_NAMES;
- args[6] = "mock-add";
-
- 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();
- String messages = outputWriter.getMessages();
- assert (messages.indexOf("mock-add=test1") != -1);
- } catch (CLIException e) {
- this.log(Level.SEVERE, "showAttributeDefaultValues",e.getMessage());
- throw e;
- }
- }
-
- @Parameters({"subschema"})
- @Test(groups = {"schema", "remove-attr-defs",
- "attribute-schema-ops", "subschema"},
- dependsOnMethods = {"showAttributeDefaultValues"}
- )
- public void removeAttributeDefaultValues(String subschema)
- throws CLIException, SMSException, SSOException {
- Object[] params = {subschema};
- entering("removeAttributeDefaultValues", params);
- String[] args = (subschema.length() == 0)
- ? new String[7] : new String[9];
-
- args[0] = "remove-attr-defs";
- 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_NAMES;
- args[6] = "mock-add";
-
- 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");
- Set values = as.getDefaultValues();
- assert values.isEmpty();
- exiting("removeAttributeDefaultValues");
- } catch (CLIException e) {
- this.log(Level.SEVERE, "removeAttributeDefaultValues",
- e.getMessage());
- throw e;
- } catch (SMSException e) {
- this.log(Level.SEVERE, "removeAttributeDefaultValues",
- e.getMessage());
- throw e;
- } catch (SSOException e) {
- this.log(Level.SEVERE, "removeAttributeDefaultValues",
- e.getMessage());
- throw e;
- }
- }
-
- private void createServices(List xmlFileNames)
- throws CLIException {
- String[] args = new String[xmlFileNames.size() +2];
- args[0] = "create-svc";
- args[1] = CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.XML_FILE;
- int cnt = 2;
- for (String xml : xmlFileNames) {
- args[cnt++] = xml;
- }
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- }
-
- private void deleteServices(List 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();
- }
-
- private boolean serviceExists(String serviceName) throws SMSException, SSOException {
- try {
- ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, getAdminSSOToken());
- return true;
- } catch (ServiceNotFoundException snfe) {
- return false;
- }
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/federation/cli/SAML2Test.java b/openam-test/src/test/java/com/sun/identity/federation/cli/SAML2Test.java
deleted file mode 100644
index 4ad16ce73b..0000000000
--- a/openam-test/src/test/java/com/sun/identity/federation/cli/SAML2Test.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: SAML2Test.java,v 1.9 2008/11/20 17:53:03 veiming Exp $
- *
- */
-
-package com.sun.identity.federation.cli;
-
-import com.sun.identity.cli.CLIConstants;
-import com.sun.identity.cli.CLIException;
-import com.sun.identity.cli.CLIRequest;
-import com.sun.identity.cli.CommandManager;
-import com.sun.identity.cli.DevNullOutputWriter;
-import com.sun.identity.cli.IArgument;
-import com.sun.identity.cot.CircleOfTrustManager;
-import com.sun.identity.cot.CircleOfTrustDescriptor;
-import com.sun.identity.cot.COTException;
-import com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement;
-import com.sun.identity.saml2.jaxb.entityconfig.XACMLPDPConfigElement;
-import com.sun.identity.saml2.jaxb.entityconfig.XACMLAuthzDecisionQueryConfigElement;
-import com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement;
-import com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement;
-import com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement;
-import com.sun.identity.saml2.jaxb.metadata.XACMLPDPDescriptorElement;
-import com.sun.identity.saml2.jaxb.metadata.XACMLAuthzDecisionQueryDescriptorElement;
-import com.sun.identity.saml2.jaxb.metadata.SPSSODescriptorElement;
-import com.sun.identity.saml2.meta.SAML2MetaException;
-import com.sun.identity.saml2.meta.SAML2MetaManager;
-import com.sun.identity.test.common.TestBase;
-import java.util.HashMap;
-import java.util.Map;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-public class SAML2Test extends TestBase {
- private CommandManager cmdManager;
- private static DevNullOutputWriter outputWriter = new DevNullOutputWriter();
- private static String NAME_COT = "clitest";
- private static String NAME_IDP = "www.idp.com";
-
- public SAML2Test() {
- super("FederationCLI");
- }
-
- /**
- * Create the CLIManager.
- */
- @BeforeTest(groups = {"cli"})
- public void suiteSetup()
- throws CLIException
- {
- Map env = new HashMap();
- env.put(CLIConstants.SYS_PROPERTY_COMMAND_NAME, "famadm");
- env.put(CLIConstants.SYS_PROPERTY_DEFINITION_FILES,
- "com.sun.identity.federation.cli.FederationManager");
- env.put(CLIConstants.SYS_PROPERTY_OUTPUT_WRITER, outputWriter);
- cmdManager = new CommandManager(env);
- }
-
- @Test(groups = {"samlv2"})
- public void createCircleOfTrust()
- throws CLIException, COTException, SAML2MetaException {
- entering("createCircleOfTrust", null);
- String[] args = {"create-cot",
- CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_COT,
- NAME_COT
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
-
- try {
- cmdManager.serviceRequestQueue();
- CircleOfTrustManager cotManager = new CircleOfTrustManager();
- CircleOfTrustDescriptor objCircleOfTrust =
- cotManager.getCircleOfTrust("/", NAME_COT);
- assert(objCircleOfTrust != null);
- } finally {
- exiting("createCircleOfTrust");
- }
- }
-
- @Test(groups = {"samlv2", "samlv2op"},
- dependsOnMethods={"createCircleOfTrust"})
- public void createMetaTemplate()
- throws CLIException {
- entering("createMetaTemplate", null);
- String[] args = {
- "create-metadata-templ",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_ENTITY_ID,
- NAME_IDP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_METADATA,
- "meta",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_EXTENDED_DATA,
- "extended",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_SERVICE_PROVIDER,
- "/sp",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_IDENTITY_PROVIDER,
- "/idp",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_PDP,
- "/pdp",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_PEP,
- "/pep",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.SPECIFICATION_VERSION,
- FedCLIConstants.SAML2_SPECIFICATION
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("createMetaTemplate");
- }
-
- @Test(groups = {"samlv2", "samlv2op"},
- dependsOnMethods={"createMetaTemplate"})
- public void importEntity()
- throws CLIException, SAML2MetaException {
- entering("importEntity", null);
- String[] args = {
- "import-entity",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_METADATA,
- "meta",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_EXTENDED_DATA,
- "extended",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_COT,
- NAME_COT,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.SPECIFICATION_VERSION,
- FedCLIConstants.SAML2_SPECIFICATION
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- SAML2MetaManager mgr = new SAML2MetaManager();
- EntityDescriptorElement entity = mgr.getEntityDescriptor(
- "/", NAME_IDP);
- assert (entity != null);
-
- SPSSODescriptorElement spElt = mgr.getSPSSODescriptor("/", NAME_IDP);
- assert(spElt != null);
- IDPSSODescriptorElement idpElt = mgr.getIDPSSODescriptor("/", NAME_IDP);
- assert(idpElt != null);
- XACMLPDPDescriptorElement pdpElt = mgr.getPolicyDecisionPointDescriptor(
- "/", NAME_IDP);
- assert(pdpElt != null);
- XACMLAuthzDecisionQueryDescriptorElement pepElt =
- mgr.getPolicyEnforcementPointDescriptor("/", NAME_IDP);
- assert(pepElt != null);
-
- IDPSSOConfigElement idpConfig = mgr.getIDPSSOConfig("/", NAME_IDP);
- assert(idpConfig != null);
- SPSSOConfigElement spConfig = mgr.getSPSSOConfig("/", NAME_IDP);
- assert(spConfig != null);
- XACMLPDPConfigElement pdpConfig = mgr.getPolicyDecisionPointConfig(
- "/", NAME_IDP);
- assert(pdpConfig != null);
- XACMLAuthzDecisionQueryConfigElement pepConfig =
- mgr.getPolicyEnforcementPointConfig("/", NAME_IDP);
- assert(pepConfig != null);
-
- exiting("importEntity");
- }
-
- @Test(groups = {"samlv2", "samlv2entityop"},
- dependsOnMethods={"importEntity"})
- public void listEntity()
- throws CLIException, SAML2MetaException {
- entering("listEntity", null);
- String[] args = {
- "list-entities",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.SPECIFICATION_VERSION,
- FedCLIConstants.SAML2_SPECIFICATION
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listEntity");
- }
-
- @Test(groups = {"samlv2", "samlv2entityop"},
- dependsOnMethods={"importEntity"})
- public void listCircleOfTrustMembers()
- throws CLIException, SAML2MetaException {
- entering("listCircleOfTrustMembers", null);
- String[] args = {
- "list-cot-members",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_COT,
- NAME_COT,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- IArgument.REALM_NAME,
- "/"
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("listCircleOfTrustMembers");
- }
-
- @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");
- }
-
- @Test(groups = {"samlv2", "samlv2entityop"},
- dependsOnMethods={"importEntity"})
- public void exportEntity()
- throws CLIException, SAML2MetaException {
- entering("exportEntity", null);
- String[] args = {
- "export-entity",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_ENTITY_ID,
- NAME_IDP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_METADATA,
- "meta",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_EXTENDED_DATA,
- "extended",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.SPECIFICATION_VERSION,
- FedCLIConstants.SAML2_SPECIFICATION
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("exportEntity");
- }
-
- @Test(groups = {"samlv2", "samlv2op"},
- dependsOnMethods={"removeProviderFromCircleOfTrust"})
- public void deleteEntity()
- throws CLIException, SAML2MetaException {
- entering("deleteEntity", null);
- String[] args = {
- "delete-entity",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_ENTITY_ID,
- NAME_IDP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.SPECIFICATION_VERSION,
- FedCLIConstants.SAML2_SPECIFICATION
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- SAML2MetaManager mgr = new SAML2MetaManager();
- EntityDescriptorElement entity = mgr.getEntityDescriptor(
- "/", NAME_IDP);
-
- assert (entity == null);
- exiting("deleteEntity");
- }
-
- @Test(groups = {"samlv2", "samlv2op"}, dependsOnGroups={"samlv2entityop"})
- public void removeProviderFromCircleOfTrust()
- throws CLIException, SAML2MetaException {
- entering("removeProviderFromCircleOfTrust", null);
- String[] args = {
- "remove-cot-member",
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_ENTITY_ID,
- NAME_IDP,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.ARGUMENT_COT,
- NAME_COT,
- CLIConstants.PREFIX_ARGUMENT_LONG +
- FedCLIConstants.SPECIFICATION_VERSION,
- FedCLIConstants.SAML2_SPECIFICATION
- };
-
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
- exiting("removeProviderFromCircleOfTrust");
- }
-
- @Test(groups = {"samlv2"},
- dependsOnMethods = {"removeProviderFromCircleOfTrust"},
- expectedExceptions = {COTException.class})
- public void deleteCircleOfTrust()
- throws CLIException, COTException, SAML2MetaException {
- entering("deleteCircleOfTrust", null);
- String[] args = {"delete-cot",
- CLIConstants.PREFIX_ARGUMENT_LONG + FedCLIConstants.ARGUMENT_COT,
- NAME_COT
- };
- CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
- cmdManager.addToRequestQueue(req);
- cmdManager.serviceRequestQueue();
-
- try {
- cmdManager.serviceRequestQueue();
- CircleOfTrustManager cotManager = new CircleOfTrustManager();
- CircleOfTrustDescriptor objCircleOfTrust =
- cotManager.getCircleOfTrust("/", NAME_COT);
- } finally {
- exiting("deleteCircleOfTrust");
- }
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/idm/AMIdentityTestBase.java b/openam-test/src/test/java/com/sun/identity/idm/AMIdentityTestBase.java
deleted file mode 100644
index 11f08948f1..0000000000
--- a/openam-test/src/test/java/com/sun/identity/idm/AMIdentityTestBase.java
+++ /dev/null
@@ -1,765 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: AMIdentityTestBase.java,v 1.5 2008/06/25 05:44:19 qcheng Exp $
- *
- */
-
-/**
- * Portions Copyrighted 2012 ForgeRock Inc
- */
-package com.sun.identity.idm;
-
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.shared.test.CollectionUtils;
-import com.sun.identity.sm.DNMapper;
-import com.sun.identity.sm.OrganizationConfigManager;
-import com.sun.identity.sm.SMSException;
-import com.sun.identity.test.common.FileHelper;
-import com.sun.identity.test.common.TestBase;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-/**
- * This class tests the com.sun.identity.idm.AMIdentity class.
- */
-public class AMIdentityTestBase extends TestBase {
-
- public AMIdentityTestBase() {
- super("IDM");
- }
-
- /**
- * Creates realm before the test suites are executed.
- *
- * @throws SMSException if realm cannot be created.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realms"})
- @BeforeSuite(groups = {"api"})
- public void suiteSetup(String realms)
- throws SSOException, SMSException {
- Object[] params = {realms};
- entering("suiteSetup", params);
-
- StringTokenizer st = new StringTokenizer(realms, ",");
- while (st.hasMoreElements()) {
- String realm = st.nextToken().trim();
- createSubRealm(getAdminSSOToken(), realm);
- }
-
- exiting("suiteSetup");
- }
-
- /**
- * Creates realm and AMIdenity object before the testcases are
- * executed.
- *
- * @throws Exception if AMIdenity object cannot be created.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-creation-attributes"})
- @BeforeTest(groups = {"api"})
- public void setup(
- String parentRealm,
- String idType,
- String entityName,
- String createAttributes
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName, createAttributes};
- entering("setup", params);
- try {
- IdType type = IdUtils.getType(idType);
- Map values = CollectionUtils.parseStringToMap(createAttributes);
-
- AMIdentity amid = createIdentity(parentRealm, type, entityName,
- values);
- assert amid.getName().equals(entityName);
- assert amid.getType().equals(type);
- String amidRealm = DNMapper.orgNameToRealmName(amid.getRealm());
- if (amidRealm.charAt(0) != '/') {
- amidRealm = "/" + amidRealm;
- }
- assert amidRealm.equals(parentRealm);
- if (type.equals(IdType.AGENT) || type.equals(IdType.USER)) {
- assert amid.isActive();
- }
- assert amid.isExists();
- } catch (Exception e) {
- log(Level.SEVERE, "setup", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("setup");
- }
-
- /**
- * Assigning and deassigning services to AMIdentity object.
- *
- * @throws Exception if cannot access to AMIdentity object.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-modify-service1-name", "entity-modify-service1-attributes"})
- @Test(groups = {"api", "service"})
- public void assignUnassignService(
- String parentRealm,
- String idType,
- String entityName,
- String strServiceNames,
- String svcModificationAttrs
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName, strServiceNames,
- svcModificationAttrs};
- entering("assignUnassignService", params);
- try {
-
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
-
- Set serviceNames = CollectionUtils.parseStringToSet(
- strServiceNames);
- if ((serviceNames != null) && !serviceNames.isEmpty()) {
- String serviceName = serviceNames.iterator().next();
- amid.assignService(serviceName, Collections.EMPTY_MAP);
- Map> values =
- CollectionUtils.parseStringToMap(svcModificationAttrs);
- amid.modifyService(serviceName, values);
- Map> verification = amid.getServiceAttributes(serviceName);
- for (String key : verification.keySet()) {
- if (values.keySet().contains(key)) {
- assert values.get(key).equals(verification.get(key));
- }
- }
- }
- } catch (Exception e) {
- log(Level.SEVERE, "setup", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("assignUnassignService");
- }
-
- /**
- * Modifies attributes
- *
- * @throws Exception if cannot access to AMIdentity object.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-modify-attributes"})
- @Test(groups = {"api"})
- public void modifyAttributes(
- String parentRealm,
- String idType,
- String entityName,
- String modificationAttributes
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName,
- modificationAttributes};
- entering("modifyAttributes", params);
-
- Map> values = CollectionUtils.parseStringToMap(
- modificationAttributes);
- if (!values.isEmpty()) {
- try {
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
- modifyIdentity(amid, values);
- Map verification = amid.getAttributes(
- values.keySet());
- assert verification.equals(values);
- } catch (Exception e) {
- log(Level.SEVERE, "modifyAttributes", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
- }
-
- exiting("modifyAttributes");
- }
-
- /**
- * Sets and gets binary attributes
- *
- * @throws Exception if cannot access to AMIdentity object.
- **/
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-binary-attributes"})
- @Test(groups = {"api", "user-base"})
- public void setGetBinaryAttributes(
- String parentRealm,
- String idType,
- String entityName,
- String fileName
- ) throws Exception {
- // Issue 77
- Object[] params = {parentRealm, idType, entityName, fileName};
- entering("setGetBinaryAttributes", params);
- try {
- byte[] content = FileHelper.getBinary(fileName);
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
- Map map = new HashMap();
- byte[][] values = new byte[1][];
- map.put("telephonenumber", values);
- values[0] = content;
- amid.setBinaryAttributes(map);
- amid.store();
-
- Set set = new HashSet();
- set.add("telephonenumber");
- Map verify = amid.getBinaryAttributes(set);
- assert !verify.values().isEmpty();
- byte[][] verifyArr = (byte[][]) verify.values().iterator().next();
-
- assert Arrays.deepEquals(values, verifyArr);
- } catch (Exception e) {
- log(Level.SEVERE, "setGetBinaryAttributes",
- e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("setGetBinaryAttributes");
- }
-
- /**
- * Passes an null (Map) to the modify attribute API.
- *
- * @throws Exception if cannot access to AMIdentity object.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name"})
- @Test(groups = {"api"})
- public void modifyWithNullValues(
- String parentRealm,
- String idType,
- String entityName
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName};
- entering("modifyWithNullValues", params);
-
- try {
-
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
- modifyIdentity(amid, null);
- } catch (Exception e) {
- log(Level.SEVERE, "modifyWithNullValues", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("modifyWithNullValues");
- }
-
- @Parameters({"parent-realm", "entity-type", "entity-name"})
- @Test(groups = {"api", "memberships"}, expectedExceptions = {IdRepoException.class})
- public void assignMemberTwice(String parentRealm, String idType, String entityName) throws IdRepoException, SSOException {
- Object[] params = {parentRealm, idType, entityName};
- entering("assignMemberTwice", params);
- try {
- AMIdentity amid1 = createDummyUser(parentRealm, entityName, "1");
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
-
- amid.addMember(amid1);
- assert amid1.isMember(amid);
- // add twice
- amid.addMember(amid1);
-
- } catch (SSOException e) {
- log(Level.SEVERE, "assignMemberTwice", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- } finally {
- deleteIdentity(parentRealm, IdType.USER, entityName + "1");
- }
- exiting("assignMemberTwice");
- }
-
- /**
- * Adds and removes members from the AMIdentity object.
- *
- * @throws Exception if cannot access to AMIdentity
- */
- @Parameters({"parent-realm", "entity-type", "entity-name"})
- @Test(groups = {"api", "memberships"})
- public void assignUnassignMembers(
- String parentRealm,
- String idType,
- String entityName
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName};
- entering("assignUnassignMembers", params);
- try {
-
- AMIdentity amid1 = createDummyUser(parentRealm, entityName, "1");
- AMIdentity amid2 = createDummyUser(parentRealm, entityName, "2");
- AMIdentity amid3 = createDummyUser(parentRealm, entityName, "3");
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
-
- amid.addMember(amid1);
-
- assert amid1.isMember(amid);
- amid.addMember(amid2);
- assert amid1.isMember(amid);
- assert amid2.isMember(amid);
- amid.addMember(amid3);
- assert amid1.isMember(amid);
- assert amid2.isMember(amid);
- assert amid3.isMember(amid);
-
- Set set = new HashSet();
- set.add(amid2);
- set.add(amid3);
-
- amid.removeMember(amid1);
- assert !amid1.isMember(amid);
-
- Set members = amid.getMembers(IdType.USER);
- assert members.equals(set);
-
- amid.removeMembers(set);
- assert !amid1.isMember(amid);
- assert !amid2.isMember(amid);
- assert !amid3.isMember(amid);
- deleteIdentity(parentRealm, IdType.USER, entityName + "1");
- deleteIdentity(parentRealm, IdType.USER, entityName + "2");
- deleteIdentity(parentRealm, IdType.USER, entityName + "3");
- } catch (Exception e) {
- log(Level.SEVERE, "assignUnassignMembers", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("assignUnassignMembers");
- }
-
-
- /**
- * Creates AMIdentity twice.
- *
- * @throws IdRepoException if AMIdentity object cannot be
- * created.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-creation-attributes"})
- @Test(groups = {"api"}, expectedExceptions={IdRepoException.class})
- public void createIdentityTwice(
- String parentRealm,
- String idType,
- String entityName,
- String createAttributes
- ) throws IdRepoException, SSOException {
- Object[] params = {parentRealm, idType, entityName, createAttributes};
- entering("createIdentityTwice", params);
-
- try {
-
- IdType type = IdUtils.getType(idType);
- Map values = CollectionUtils.parseStringToMap(createAttributes);
- createIdentity(parentRealm, type, entityName, values);
- } catch (SSOException e) {
- log(Level.SEVERE, "createIdentityTwice", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("createIdentityTwice");
- }
-
- /**
- * Creates AMIdentity twice with long name.
- *
- * @throws IdRepoException if AMIdentity object cannot be
- * created.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-creation-attributes"})
- @Test(groups = {"api"})
- public void createIdentityWithLongName(
- String parentRealm,
- String idType,
- String entityName,
- String createAttributes
- ) throws IdRepoException, SSOException {
- Object[] params = {parentRealm, idType, entityName, createAttributes};
- entering("createIdentityWithLongName", params);
- try {
-
- String name = entityName;
- for (int i = 0; i < 100; i++) {
- name += entityName;
- }
- IdType type = IdUtils.getType(idType);
- Map values = CollectionUtils.parseStringToMap(createAttributes);
- createIdentity(parentRealm, type, name, values);
- deleteIdentity(parentRealm, type, name);
- } catch (SSOException e) {
- log(Level.SEVERE, "createIdentityWithLongName", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("createIdentityWithLongName");
- }
-
-
- /**
- * Creates AMIdentity twice with no name.
- *
- * @throws IdRepoException if AMIdentity object cannot be
- * created.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realm", "entity-type", "entity-creation-attributes"})
- @Test(groups = {"api"}, expectedExceptions={IdRepoException.class})
- public void createIdenityWithNoName(
- String parentRealm,
- String idType,
- String createAttributes
- ) throws IdRepoException, SSOException {
- Object[] params = {parentRealm, idType, createAttributes};
- entering("createIdenityWithNoName", params);
- try {
-
- IdType type = IdUtils.getType(idType);
- Map values = CollectionUtils.parseStringToMap(createAttributes);
- createIdentity(parentRealm, type, "", values);
- } catch (SSOException e) {
- log(Level.SEVERE, "createIdenityWithNoName", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("createIdenityWithNoName");
- }
-
-
- /**
- * Set required values of required attributes in AMIdentity
- * to null.
- *
- * @throws IdRepoException if AMIdentity object cannot be
- * modified.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-required-attributes"})
- @Test(groups = {"api", "ldap"}, expectedExceptions={IdRepoException.class})
- public void nullifyRequiredAttribute(
- String parentRealm,
- String idType,
- String entityName,
- String requiredAttributes
- ) throws IdRepoException, SSOException {
- Object[] params = {parentRealm, idType, entityName, requiredAttributes};
- entering("nullifyRequiredAttribute", params);
- try {
-
- Set setRequiredAttributes =
- CollectionUtils.parseStringToSet(requiredAttributes);
- if (!setRequiredAttributes.isEmpty()) {
- Map> emptyValues =
- CollectionUtils.getEmptyValuesMap(setRequiredAttributes);
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
- amid.setAttributes(emptyValues);
- amid.store();
- }
- } catch (SSOException e) {
- log(Level.SEVERE, "nullifyRequiredAttribute", e.getMessage(),
- params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("nullifyRequiredAttribute");
- }
-
- /**
- * Removes membership of AMIdentity itself from it.
- *
- * @throws IdRepoException if membership removal failed.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name"})
- @Test(groups = {"api", "memberships"},
- expectedExceptions={IdRepoException.class})
- public void addItselfAsMember(
- String parentRealm,
- String idType,
- String entityName
- ) throws IdRepoException, SSOException {
- Object[] params = {parentRealm, idType, entityName};
- entering("addItselfAsMember", params);
-
- try {
- AMIdentity amid = getIdentity(parentRealm,
- IdUtils.getType(idType), entityName);
- amid.removeMember(amid);
- } catch (SSOException e) {
- log(Level.SEVERE, "addItselfAsMember", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("addItselfAsMember");
- }
-
-
- /**
- * Tests isExists method.
- *
- * @throws Exception if cannot access to AMIdentity object.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name",
- "entity-creation-attributes"})
- @Test(groups = {"api"})
- public void verifyExistence(
- String parentRealm,
- String idType,
- String entityName,
- String createAttributes
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName, createAttributes};
- entering("verifyExistence", params);
- try {
- Map values = CollectionUtils.parseStringToMap(createAttributes);
- IdType type = IdUtils.getType(idType);
- AMIdentity a = createIdentity(parentRealm, type, entityName +
- "exist", values);
- assert a.isExists();
- AMIdentityRepository repo = new AMIdentityRepository(
- getAdminSSOToken(), parentRealm);
- IdSearchResults results = repo.searchIdentities(type,
- entityName + "exist", new IdSearchControl());
- Set resultSets = results.getSearchResults();
- assert resultSets.size() == 1;
- deleteIdentity(parentRealm, type, entityName + "exist");
- resultSets = repo.searchIdentities(type, entityName + "exist", new IdSearchControl()).getSearchResults();
- assert resultSets.isEmpty();
- } catch (Exception e) {
- log(Level.SEVERE, "verifyExistence", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- } finally {
- exiting("verifyExistence");
- }
- }
-
- /**
- * Removes AMIdentity object after suite test is
- * done.
- *
- * @throws Exception if AMIdenity object cannot be deleted.
- */
- @Parameters({"parent-realm", "entity-type", "entity-name"})
- @AfterTest(groups = {"api"})
- public void tearDown(
- String parentRealm,
- String idType,
- String entityName
- ) throws Exception {
- Object[] params = {parentRealm, idType, entityName};
- entering("tearDown", params);
- try {
-
- deleteIdentity(parentRealm, IdUtils.getType(idType), entityName);
- } catch (Exception e) {
- log(Level.SEVERE, "tearDown", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("tearDown");
- }
-
- /**
- * Removes realm after suite test is done.
- *
- * @throws SMSException if realm cannot be deleted.
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
- @Parameters({"parent-realms"})
- @AfterSuite(groups = {"api"})
- public void suiteTearDown(String realms)
- throws SSOException, SMSException {
- Object[] params = {realms};
- entering("suiteTearDown", params);
-
- StringTokenizer st = new StringTokenizer(realms, ",");
- while (st.hasMoreElements()) {
- String realm = st.nextToken().trim();
- deleteRealm(getAdminSSOToken(), realm);
- }
-
- exiting("suiteTearDown");
- }
-
- private AMIdentity createIdentity(
- String parentRealm,
- IdType idType,
- String entityName,
- Map values
- ) throws IdRepoException, SSOException {
- SSOToken ssoToken = getAdminSSOToken();
- AMIdentityRepository repo = new AMIdentityRepository(
- ssoToken, parentRealm);
- AMIdentity amid = repo.createIdentity(idType, entityName, values);
- return amid;
- }
-
- private AMIdentity getIdentity(
- String parentRealm,
- IdType idType,
- String entityName
- ) throws IdRepoException, SSOException {
- SSOToken ssoToken = getAdminSSOToken();
- AMIdentityRepository repo = new AMIdentityRepository(
- ssoToken, parentRealm);
- return new AMIdentity(ssoToken, entityName, idType, parentRealm, null);
- }
-
- private void modifyIdentity(AMIdentity amid, Map values)
- throws IdRepoException, SSOException {
- amid.setAttributes(values);
- amid.store();
- }
-
- private void deleteIdentity(
- String parentRealm,
- IdType idType,
- String entityName
- ) throws IdRepoException, SSOException {
- SSOToken ssoToken = getAdminSSOToken();
- AMIdentityRepository repo = new AMIdentityRepository(
- ssoToken, parentRealm);
- repo.deleteIdentities(getAMIdentity(
- ssoToken, entityName, idType, parentRealm));
- IdSearchResults results = repo.searchIdentities(idType, entityName,
- new IdSearchControl());
- Set resultSets = results.getSearchResults();
- assert resultSets.isEmpty();
- }
-
- private Set getAMIdentity(
- SSOToken ssoToken,
- String name,
- IdType idType,
- String realm
- ) {
- Set set = new HashSet();
- set.add(new AMIdentity(ssoToken, name, idType, realm, null));
- return set;
- }
-
- private AMIdentity createDummyUser(
- String parentRealm,
- String entityName,
- String suffix
- ) throws IdRepoException, SSOException {
- Map> map = new HashMap>();
- CollectionUtils.putSetIntoMap("sn", map, "sn" + suffix);
- CollectionUtils.putSetIntoMap("cn", map, "cn" + suffix);
- CollectionUtils.putSetIntoMap("userpassword", map, "password" + suffix);
- CollectionUtils.putSetIntoMap("inetuserstatus", map, "Active");
- return createIdentity(parentRealm, IdType.USER, entityName + suffix,
- map);
- }
-
- private String getParentRealm(String realm) {
- int idx = realm.lastIndexOf("/");
- if (idx == -1) {
- throw new RuntimeException("Incorrect Realm, " + realm);
- }
- return (idx == 0) ? "/" : realm.substring(0, idx);
- }
-
- private void createSubRealm(SSOToken ssoToken, String realm)
- throws SSOException, SMSException
- {
- if ((realm != null) && !realm.equals("/")) {
- String parentRealm = getParentRealm(realm);
- createSubRealm(ssoToken, parentRealm);
- OrganizationConfigManager orgMgr = new OrganizationConfigManager(
- ssoToken, parentRealm);
- int idx = realm.lastIndexOf("/");
- try {
- orgMgr.createSubOrganization(realm.substring(idx + 1), null);
- } catch (SMSException e) {
- //ignore if the sub organization already exists.
- }
- }
- }
-
- private void deleteRealm(SSOToken ssoToken, String realm)
- throws SSOException
- {
- if ((realm != null) && !realm.equals("/")) {
- String parentRealm = getParentRealm(realm);
- try {
- OrganizationConfigManager orgMgr = new
- OrganizationConfigManager(ssoToken, parentRealm);
- int idx = realm.lastIndexOf("/");
- orgMgr.deleteSubOrganization(realm.substring(idx+1), true);
- } catch (SMSException e) {
- //ignore if the sub organization already exists.
- }
- deleteRealm(ssoToken, parentRealm);
- }
- }
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/log/AMLogTest.java b/openam-test/src/test/java/com/sun/identity/log/AMLogTest.java
deleted file mode 100644
index dccdc4f8f2..0000000000
--- a/openam-test/src/test/java/com/sun/identity/log/AMLogTest.java
+++ /dev/null
@@ -1,689 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: AMLogTest.java,v 1.3 2008/06/25 05:44:19 qcheng Exp $
- *
- */
-
-package com.sun.identity.log;
-
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.authentication.AuthContext;
-import com.sun.identity.authentication.spi.AuthLoginException;
-import com.sun.identity.authentication.share.AuthXMLTags;
-import com.sun.identity.idm.AMIdentity;
-import com.sun.identity.log.AMLogException;
-import com.sun.identity.log.LogConstants;
-import com.sun.identity.log.LogManagerUtil;
-import com.sun.identity.log.LogQuery;
-import com.sun.identity.log.LogReader;
-import com.sun.identity.log.LogRecord;
-import com.sun.identity.log.Logger;
-import com.sun.identity.log.QueryElement;
-import com.sun.identity.shared.test.CollectionUtils;
-import com.sun.identity.sm.AttributeSchema;
-import com.sun.identity.sm.SchemaType;
-import com.sun.identity.sm.ServiceSchema;
-import com.sun.identity.sm.ServiceSchemaManager;
-import com.sun.identity.sm.SMSException;
-import com.sun.identity.test.common.FileHelper;
-import com.sun.identity.test.common.TestBase;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-/**
- * This class tests the
- * com.sun.identity.log.LogRecord and
- * com.sun.identity.log.Logger classes.
- */
-public class AMLogTest extends TestBase {
-
- public AMLogTest() {
- super("LogTest");
- }
-
- /**
- * before running test:
- * clean out the logfile (or remove it) - manual task
- *
- * @throws SSOException if the super administrator Single Sign On is
- * invalid.
- */
-
- private String theRealm = null;
-
- // msgDatPrefixData is the "data" part of msgDataPrefix
- private final String msgDataPrefixData = "data #";
- private final String msgDataPrefix = "AMLogTest " + msgDataPrefixData;
- private final String defaultLogName = "AMLogTestLog";
-
- private String loggingLocation = null;
- private String logName = null;
- private String logPath = null;
- private Logger logger = null;
-
- private java.util.logging.LogManager lmgr = null;
-
-
- /**
- * the logging testng program currently consists of
- * logging attempts by amadmin.
- * logwrite-number-of-records records should be written.
- *
- * the log reading tests exercise the LogReader formats, with
- * LogQuery and QueryElement classes.
- */
-
-
- /**
- * suiteSetup
- * For setup, get:
- * o a logger instance
- */
-
- @Parameters({"logtest-realm"})
- @BeforeSuite(groups = {"api-adminwrite", "api-adminread"})
- public void suiteSetup (String realm) throws Exception {
- Object[] params = {realm};
- entering("suiteSetup", params);
-
- try {
- lmgr = LogManagerUtil.getLogManager(); // NOTE5
- } catch (Exception e) {
- log(Level.SEVERE, "suiteSetup", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
- theRealm = realm;
- exiting("suiteSetup");
- }
-
-
-
- /**
- * Before running the test(s), ensure:
- * o the log svc config is set with buffer timer off, buff size = 1
- *
- * @throws Exception if an AMLogException occurs
- */
- @Parameters({"logtest-log-location", "logtest-logname"})
- @BeforeTest(groups = {"api-adminwrite", "api-adminread"})
- public void setup(String logLoc, String logFName)
- throws Exception {
- Object[] params = {theRealm, logLoc, logFName};
- entering("setup", params);
- setbufferSizer("OFF", "1");
-
- try {
- lmgr.readConfiguration();
- String tlogLoc = lmgr.getProperty(LogConstants.LOG_LOCATION);
- if ((tlogLoc == null) || (tlogLoc.length() == 0)) {
- tlogLoc = logLoc;
- }
- if ((logFName != null) && (logFName.length() > 0)) {
- logName = logFName;
- } else {
- logName = defaultLogName;
- }
- loggingLocation = tlogLoc;
- logPath = loggingLocation + "/" + logName;
- File f1 = new File(logPath);
- if (f1.exists() && (f1.length() > 0)) {
- f1.delete();
- }
-
- logger = (Logger)Logger.getLogger(logFName);
- } catch (Exception e) {
- log(Level.SEVERE, "setup", e.getMessage(), params);
- e.printStackTrace();
- throw e;
- }
-
- exiting("setup");
- }
-
- private void setbufferSizer(String statusVal, String buffSize)
- throws SSOException, SMSException {
- SSOToken adminSSOToken = getAdminSSOToken();
- ServiceSchemaManager mgr = new ServiceSchemaManager(
- "iPlanetAMLoggingService", adminSSOToken);
- ServiceSchema globalSchema = mgr.getSchema(SchemaType.GLOBAL);
- {
- AttributeSchema status = globalSchema.getAttributeSchema(
- "iplanet-am-logging-time-buffering-status");
- Set set = new HashSet(2);
- set.add(statusVal);
- status.setDefaultValues(set);
- }
- {
- AttributeSchema bufferSize = globalSchema.getAttributeSchema(
- "iplanet-am-logging-buffer-size");
- Set set = new HashSet(2);
- set.add(buffSize);
- bufferSize.setDefaultValues(set);
- }
- }
-
-
- /**
- * need:
- * only the amadmin SSOToken (used in LogRecord), since
- * can't (currently) use user SSOTokens. also means
- * the log delegation can't be tested.
- * column values
- * data
- * module_name
- * domain
- * log_level
- * login_id
- * ip_addr
- * host_name
- * message_id
- * number of records to write
- *
- */
-
- @Parameters({"logwrite-data",
- "logwrite-modulename",
- "logwrite-domain",
- "logwrite-log-level",
- "logwrite-login-id",
- "logwrite-ip-addr",
- "logwrite-host-name",
- "logwrite-message-id",
- "logwrite-number-of-records"})
- @Test(groups = {"api-adminwrite"})
- public void writeAdminLogRecord(
- String rData,
- String rModuleName,
- String rDomain,
- String rLogLevel,
- String rLoginId,
- String rIPAddr,
- String rHostName,
- String rMsgId,
- String rNumRecs
- ) throws AMLogException {
- LogRecord lR = null;
- Level llevel = null;
- int numRecs = 0;
-
- if ((rNumRecs != null) && (rNumRecs.length() > 0)) {
- try {
- numRecs = Integer.parseInt(rNumRecs);
- } catch (NumberFormatException nfe) {
- log(Level.WARNING, "writeAdminLogRecord",
- nfe.getMessage());
- numRecs = 1;
- }
- }
-
- llevel = getLogLevel(rLogLevel);
-
- /**
- * DOMAIN, LOGIN_ID, IP_ADDR, and HOST_NAME are extracted from the
- * SSOToken and added by the LogRecord handling. if any values are
- * provided to the test, then they'll be added.
- */
-
- int totalRecs = 0;
-
- SSOToken adminToken = getAdminSSOToken();
- /*
- * put variable data in ("msgDataPrefix + i") reverse
- * order, so we can test sortBy in the read test.
- */
- for (int i = (numRecs-1); i >= 0; i-- ) {
- lR = new LogRecord(llevel,
- msgDataPrefix + i + "|" + rData, adminToken);
- if ((rDomain != null) && (rDomain.length() > 0)) {
- lR.addLogInfo(LogConstants.DOMAIN, rDomain);
- }
- // ignore rLoginId parameter; use "amAdmin"
- lR.addLogInfo(LogConstants.LOGIN_ID, "amAdmin");
- if ((rIPAddr != null) && (rIPAddr.length() > 0)) {
- lR.addLogInfo(LogConstants.IP_ADDR, rIPAddr);
- }
- if ((rHostName != null) && (rHostName.length() > 0)) {
- lR.addLogInfo(LogConstants.HOST_NAME, rHostName);
- }
- if ((rModuleName != null) && (rModuleName.length() > 0)) {
- lR.addLogInfo(LogConstants.MODULE_NAME, rModuleName);
- }
- if ((rMsgId != null) && (rMsgId.length() > 0)) {
- String msgid = rMsgId + i;
- lR.addLogInfo(LogConstants.MESSAGE_ID, msgid);
- }
- try {
- logger.log(lR, adminToken);
- totalRecs++;
- } catch (AMLogException alex) {
- // unexpected exception
- log(Level.SEVERE, "writeAdminLogRecord",
- alex.getMessage());
- throw alex;
- }
- }
- }
-
-
- /**
- * the amadmin read log record test. test reads as amadmin only.
- *
- * test 1: retrieve all records. *should* be
- * logwrite-number-of-records
- * if the logtest-logname exists before the whole run,
- * then this test will fail (more than expected records
- * retrieved).
- */
- @Parameters({"logtest-logname",
- "logwrite-number-of-records"})
- @Test(groups = {"api-adminread"},
- dependsOnMethods = {"writeAdminLogRecord"})
- public void readAdminLogRecord(String rLogName, String rNumRecs)
- throws AMLogException {
-
- /*
- * since "regular" user SSOToken stuff doesn't seem to work,
- * just read as amadmin.
- *
- * there are a bunch of types of read tests to run...
- * 1. read all
- * 2. read selective (of various varieties)
- */
-
- SSOToken adminToken = getAdminSSOToken();
- int numRecs = 0;
-
- if ((rNumRecs != null) && (rNumRecs.length() > 0)) {
- try {
- numRecs = Integer.parseInt(rNumRecs);
- } catch (NumberFormatException nfe) {
- numRecs = 1;
- }
- }
- readAllRecords(rLogName, adminToken, numRecs);
-
- readLogQuery(rLogName, adminToken, numRecs);
- }
-
- private void readAllRecords(String fileName, SSOToken ssot, int numRecsExp)
- throws AMLogException {
- int numRecs = 0;
- try {
- String[][] result = LogReader.read(fileName, ssot);
- numRecs = Array.getLength(result);
- } catch (AMLogException ale) {
- throw new AMLogException("readAllRecords:AMLogException: " +
- ale.getMessage());
- } catch (NoSuchFieldException nsfe) {
- throw new AMLogException("readAllRecords:NoSuchField: " +
- nsfe.getMessage());
- } catch (IOException ioe) {
- throw new AMLogException("readAllRecords:IOException: " +
- ioe.getMessage());
- } catch (Exception e) {
- throw new AMLogException("readAllRecords:Exception: " +
- e.getMessage());
- }
-
- // first record has the column names
- if (numRecs != (numRecsExp + 2)) {
- throw new AMLogException("Number of records read (" +
- numRecs + ") doesn't match expected (" +
- (numRecsExp+1) + ")");
- }
- }
-
-
- private void readLogQuery(String fileName, SSOToken ssot, int recsWritten)
- throws AMLogException
- {
-
- /*
- * can have:
- * LogQuery(), which sets:
- * maxRecord = LogQuery.MOST_RECENT_MAX_RECORDS
- * globalOperand = LogQuery.MATCH_ANY_CONDITION
- * queries = null
- * sortBy = null
- * LogQuery(int max_record), which sets:
- * maxRecord = max_record
- * globalOperand = LogQuery.MATCH_ANY_CONDITION
- * queries = null
- * sortBy = null
- * LogQuery(int max_record,
- * int matchCriteria,
- * String sortingBy), which sets:
- * maxRecord = max_record
- * globalOperand = matchCriteria
- * sortBy = sortingBy
- * queries = null
- *
- * use lq.addQuery(QueryElement qryElement) to
- * add query elements to the LoqQuery's list of queries
- * QueryElement(String fld, String val, int rel)
- * fieldName = fld
- * fieldValue = val
- * relation = rel
- * QueryElement()
- * fieldName = new String()
- * fieldValue = new String()
- * relation = QueryElement.EQ
- * use:
- * QueryElement.setFieldName(String field)
- * QueryElement.setFieldValue(String value)
- * QueryElement.setRelation(int value)
- */
-
-
- int totalRecsRead = 0;
-
- /*
- * test 1:
- * all records, any condition, no sorting
- * should be same as read all.
- */
-
- LogQuery lq = new LogQuery (LogQuery.ALL_RECORDS,
- LogQuery.MATCH_ANY_CONDITION,
- null);
-
- int numRecs = 0;
- String[][] result = new String[1][1];
- try {
- result = LogReader.read(fileName, lq, ssot);
- numRecs = Array.getLength(result);
- } catch (AMLogException ale) {
- throw new AMLogException("readLogQuery:AMLogException: " +
- ale.getMessage());
- } catch (NoSuchFieldException nsfe) {
- throw new AMLogException("readLogQuery:NoSuchField: " +
- nsfe.getMessage());
- } catch (IllegalArgumentException iaex) {
- throw new AMLogException("readLogQuery:IllegalArgumentException: "+
- iaex.getMessage());
- } catch (IOException ioe) {
- throw new AMLogException("readLogQuery:IOException: " +
- ioe.getMessage());
- } catch (Exception e) {
- throw new AMLogException("readLogQuery:Exception: " +
- e.getMessage());
- }
- if (numRecs != (recsWritten + 2)) {
- throw new AMLogException("Number of records read test 1 (" +
- numRecs + ") doesn't match expected (" +
- (recsWritten+1) + ")");
- }
-
- /*
- * test 2:
- * only read 2 most recent records
- */
-
- lq = new LogQuery (2, LogQuery.MATCH_ANY_CONDITION, null);
-
- result = new String[1][1];
- numRecs = 0;
- try {
- result = LogReader.read(fileName, lq, ssot);
- numRecs = Array.getLength(result);
- } catch (AMLogException ale) {
- throw new AMLogException("readLogQuery:AMLogException: " +
- ale.getMessage());
- } catch (NoSuchFieldException nsfe) {
- throw new AMLogException("readLogQuery:NoSuchField: " +
- nsfe.getMessage());
- } catch (IllegalArgumentException iaex) {
- throw new AMLogException("readLogQuery:IllegalArgumentException: "+
- iaex.getMessage());
- } catch (IOException ioe) {
- throw new AMLogException("readLogQuery:IOException: " +
- ioe.getMessage());
- } catch (Exception e) {
- throw new AMLogException("readLogQuery:Exception: " +
- e.getMessage());
- }
- if (numRecs != 3) {
- throw new AMLogException("Number of records read test 2 (" +
- (numRecs-1) + ") doesn't match expected (2)");
- }
-
- // two most recent should be "...data #1" and "...data #0"
- String temp = result[1][1];
- if (!temp.contains(msgDataPrefixData+"1")) {
- throw new AMLogException("Read test 2: second most recent = " +
- temp + ", not " + msgDataPrefixData + "1");
- }
- temp = result[2][1];
- if (!temp.contains(msgDataPrefixData+"0")) {
- throw new AMLogException("Read test 2: most recent = " +
- temp + ", not " + msgDataPrefixData + "0");
- }
-
- /*
- * test 3:
- * get records that end with "XX2" in the MessageID field.
- * should only be one.
- */
-
- lq = new LogQuery (LogQuery.ALL_RECORDS,
- LogQuery.MATCH_ALL_CONDITIONS,
- null);
- QueryElement qe = new QueryElement("MessageID",
- "XX2",
- QueryElement.EW);
- lq.addQuery(qe);
-
- result = new String[1][1];
- numRecs = 0;
- try {
- result = LogReader.read(fileName, lq, ssot);
- numRecs = Array.getLength(result);
- } catch (AMLogException ale) {
- throw new AMLogException("readLogQuery:AMLogException: " +
- ale.getMessage());
- } catch (NoSuchFieldException nsfe) {
- throw new AMLogException("readLogQuery:NoSuchField: " +
- nsfe.getMessage());
- } catch (IllegalArgumentException iaex) {
- throw new AMLogException("readLogQuery:IllegalArgumentException: "+
- iaex.getMessage());
- } catch (IOException ioe) {
- throw new AMLogException("readLogQuery:IOException: " +
- ioe.getMessage());
- } catch (Exception e) {
- throw new AMLogException("readLogQuery:Exception: " +
- e.getMessage());
- }
- if (numRecs != 2) {
- throw new AMLogException("Number of records read test 3 (" +
- (numRecs-1) + ") doesn't match expected (1)");
- }
-
- // assume MessageID is in column 8 (starting from 0)
- temp = result[1][8];
- if (!temp.contains("XX2")) {
- throw new AMLogException("Read test 3: record = " +
- temp + ", not XX2");
- }
-
- /*
- * test 4:
- * get records that contain "data #4", "data #0" or "data #2"
- * in the Data field. specify them in that order, with
- * sort by Data field.
- * msgDataPrefixData = "data #"
- */
-
- lq = new LogQuery (LogQuery.ALL_RECORDS,
- LogQuery.MATCH_ANY_CONDITION,
- "Data");
- qe = new QueryElement("Data", msgDataPrefixData+"4", QueryElement.CN);
- lq.addQuery(qe);
- qe = new QueryElement("Data", msgDataPrefixData+"0", QueryElement.CN);
- lq.addQuery(qe);
- qe = new QueryElement("Data", msgDataPrefixData+"2", QueryElement.CN);
- lq.addQuery(qe);
-
- result = new String[1][1];
- numRecs = 0;
- try {
- result = LogReader.read(fileName, lq, ssot);
- numRecs = Array.getLength(result);
- } catch (AMLogException ale) {
- throw new AMLogException("readLogQuery:AMLogException: " +
- ale.getMessage());
- } catch (NoSuchFieldException nsfe) {
- throw new AMLogException("readLogQuery:NoSuchField: " +
- nsfe.getMessage());
- } catch (IllegalArgumentException iaex) {
- throw new AMLogException("readLogQuery:IllegalArgumentException: "+
- iaex.getMessage());
- } catch (IOException ioe) {
- throw new AMLogException("readLogQuery:IOException: " +
- ioe.getMessage());
- } catch (Exception e) {
- throw new AMLogException("readLogQuery:Exception: " +
- e.getMessage());
- }
- if (numRecs != 4) {
- throw new AMLogException("Number of records read test 4 (" +
- (numRecs-1) + ") doesn't match expected (3)");
- }
- /*
- * gonna expect Data column is in result[x][1]. also
- * that with sorting, result[1][1] contains "...data #0",
- * result[2][1] contains "...data #2", and result[3][1]
- * contains "...data #4".
- */
- temp = result[1][1];
- if (!temp.contains(msgDataPrefixData+"0")) {
- throw new AMLogException("Read test 4: first sorted record = " +
- temp + ", not " + msgDataPrefixData + "0");
- }
- temp = result[2][1];
- if (!temp.contains(msgDataPrefixData+"2")) {
- throw new AMLogException("Read test 4: second sorted record = " +
- temp + ", not " + msgDataPrefixData + "2");
- }
- temp = result[3][1];
- if (!temp.contains(msgDataPrefixData+"4")) {
- throw new AMLogException("Read test 4: third sorted record = " +
- temp + ", not " + msgDataPrefixData + "4");
- }
- }
-
-
- private void printResults(String [][] results) {
-
- System.out.println("size of results = " +
- Array.getLength(results));
- int numRecords = Array.getLength(results);
- /*
- * first record contains column names
- */
- System.out.println ("Row 0 (Column names) =");
- int ii = Array.getLength(results[0]);
- String tempS;
- for (int i = 0; i < ii; i ++) {
- tempS = results[0][i];
- System.out.print (" " + tempS + "\t");
- }
-
- for (int i = 1; i < numRecords; i++) {
- System.out.println("\nsize of row " + i + " = " + ii +
- "\nrecord " + i + " =");
- for (int j = 0; j < ii; j++) {
- System.out.println (" " + results[0][j] +
- ":\t" + results[i][j]);
- }
- System.out.println("");
- }
- return;
- }
-
-
- private Level getLogLevel (String level) {
- // default to INFO
- Level logLevel = java.util.logging.Level.INFO;
-
- if (level.equalsIgnoreCase("OFF")) {
- logLevel = Level.OFF;
- } else if (level.equalsIgnoreCase("SEVERE")) {
- logLevel = Level.SEVERE;
- } else if (level.equalsIgnoreCase("WARNING")) {
- logLevel = Level.WARNING;
- } else if (level.equalsIgnoreCase("INFO")) {
- logLevel = Level.INFO;
- } else if (level.equalsIgnoreCase("CONFIG")) {
- logLevel = Level.CONFIG;
- } else if (level.equalsIgnoreCase("FINE")) {
- logLevel = Level.FINE;
- } else if (level.equalsIgnoreCase("FINER")) {
- logLevel = Level.FINER;
- } else if (level.equalsIgnoreCase("FINEST")) {
- logLevel = Level.FINEST;
- } else if (level.equalsIgnoreCase("ALL")) {
- logLevel = Level.ALL;
- }
- return logLevel;
- }
-
-
- /**
- * tearDown
- * undo what setup did
- */
- @Parameters({})
- @AfterTest(groups = {"api-adminwrite", "api-adminread"})
- public void tearDown()
- throws Exception {
- setbufferSizer("ON", "60");
- }
-
- /**
- * suiteTearDown
- * undo what suiteSetup did:
- * o set the realm's logging service's config back, if necessary
- */
- @Parameters({"logtest-realm"})
- @AfterSuite(groups = {"api-adminwrite", "api-adminread"})
- public void suiteTearDown (String realm) {
- }
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/policy/TokenUtils.java b/openam-test/src/test/java/com/sun/identity/policy/TokenUtils.java
deleted file mode 100644
index 9af3d931fc..0000000000
--- a/openam-test/src/test/java/com/sun/identity/policy/TokenUtils.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: TokenUtils.java,v 1.2 2008/06/25 05:44:19 qcheng Exp $
- *
- */
-
-package com.sun.identity.policy;
-
-import com.iplanet.sso.SSOToken;
-import com.iplanet.sso.SSOTokenManager;
-import com.sun.identity.authentication.AuthContext;
-import com.sun.identity.authentication.internal.AuthPrincipal;
-
-import java.util.Iterator;
-import java.security.Principal;
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.LoginException;
-
-public class TokenUtils {
-
- public static SSOToken getToken(String orgName, String userId,
- String password) throws Exception {
- return getSessionToken(orgName, userId, password);
- }
-
- public static SSOToken getLocalToken(String orgName, String userId,
- String password) throws Exception
- {
- SSOTokenManager tm = SSOTokenManager.getInstance();
- SSOToken token
- = tm.createSSOToken(new AuthPrincipal(userId), password);
- return token;
- }
-
- public static SSOToken getSessionToken(String orgName, String userId,
- String password) throws Exception {
- return getSessionToken(orgName,userId, password, null, -1);
- }
-
- public static SSOToken getSessionToken(String orgName, String userId,
- String password, String module, int level)
- throws Exception
- {
- AuthContext ac = null;
- try {
- //System.out.println("TokenUtils:orgName=" + orgName);
- ac = new AuthContext(orgName);
- if (module != null) {
- ac.login(AuthContext.IndexType.MODULE_INSTANCE, module);
- } else if (level != -1) {
- ac.login(AuthContext.IndexType.LEVEL, String.valueOf(level));
- } else {
- //System.out.println("TokenUtils:calling login()");
- ac.login();
- }
- //System.out.println("TokenUtils:after ac.login()");
- } catch (LoginException le) {
- le.printStackTrace();
- return null;
- }
-
- try {
- Callback[] callbacks = null;
- // Get the information requested by the plug-ins
- if (ac.hasMoreRequirements()) {
- callbacks = ac.getRequirements();
-
- if (callbacks != null) {
- addLoginCallbackMessage(callbacks, userId, password);
- ac.submitRequirements(callbacks);
-
- if (ac.getStatus() == AuthContext.Status.SUCCESS) {
- //System.out.println("Auth success");
- Subject authSubject = ac.getSubject();
- if ( authSubject != null) {
- Iterator principals =
- (authSubject.getPrincipals()).iterator();
- Principal principal;
- while (principals.hasNext()) {
- principal = (Principal) principals.next();
- }
- }
- } else if (ac.getStatus() == AuthContext.Status.FAILED) {
- //System.out.println("Authentication has FAILED");
- } else {
- }
- } else {
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- //SSOTokenManager.getInstance().validateToken(ac.getSSOToken());
- //System.out.println(ac.getSSOToken().getPrincipal().getName());
- return ac.getSSOToken();
- }
-
-
- static void addLoginCallbackMessage(Callback[] callbacks, String userId,
- String password)
- throws UnsupportedCallbackException
- {
- int i = 0;
- try {
- for (i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
-
- // prompt the user for a username
- NameCallback nc = (NameCallback) callbacks[i];
-
- //System.out.println("userName=" + userId);
- nc.setName(userId);
-
- } else if (callbacks[i] instanceof PasswordCallback) {
-
- // prompt the user for sensitive information
- PasswordCallback pc = (PasswordCallback) callbacks[i];
-
- //System.out.println("password=" + password);
- pc.setPassword(password.toCharArray());
-
- } else {
- }
- }
- } catch (Exception e) {
- //throw new UnsupportedCallbackException(callbacks[i],
- //"Callback exception: " + e);
- }
- }
-
-}
diff --git a/openam-test/src/test/java/com/sun/identity/policy/client/AMIdentityMembershipConditionTest.java b/openam-test/src/test/java/com/sun/identity/policy/client/AMIdentityMembershipConditionTest.java
deleted file mode 100644
index 912c5e127b..0000000000
--- a/openam-test/src/test/java/com/sun/identity/policy/client/AMIdentityMembershipConditionTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: AMIdentityMembershipConditionTest.java,v 1.3 2008/06/25 05:44:20 qcheng Exp $
- *
- */
-
-package com.sun.identity.policy.client;
-import com.iplanet.sso.SSOToken;
-import com.iplanet.sso.SSOTokenManager;
-
-import com.sun.identity.shared.test.UnitTestBase;
-
-import com.sun.identity.policy.PolicyDecision;
-import com.sun.identity.policy.client.PolicyEvaluator;
-import com.sun.identity.policy.client.PolicyEvaluatorFactory;
-import com.sun.identity.policy.TokenUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.Set;
-
-import java.util.logging.Level;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.Parameters;
-
-public class AMIdentityMembershipConditionTest extends UnitTestBase {
-
- public AMIdentityMembershipConditionTest() {
- super("OpenSSO-AMIdentityMembershipConditionTest");
- }
-
- @Test(groups={"policy-client"})
- @Parameters({"orgName", "userName", "password", "serviceName",
- "resourceName", "actionName", "invocatorUuid"})
- public void testGetPolicyDecision(String orgName,
- String userName, String password,
- String serviceName, String resourceName, String actionName,
- String invocatorUuid) throws Exception {
- entering("testGetPolicyDecision()", null);
- log(Level.INFO, "orgName:", orgName);
- log(Level.INFO, "userName:", userName);
- log(Level.INFO, "password:", password);
- log(Level.INFO, "serviceName:", serviceName);
- log(Level.INFO, "resourceName:", resourceName);
- log(Level.INFO, "actionName:", actionName);
- log(Level.INFO, "invocatorUuid:", invocatorUuid);
- SSOToken token = TokenUtils.getSessionToken(orgName,
- userName, password);
- log(Level.INFO, "Created ssoToken", "\n");
-
- PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().
- getPolicyEvaluator(serviceName);
-
- Map env = new HashMap();
- Set attrSet = new HashSet();
- attrSet.add(invocatorUuid);
- env.put("invocatorPrincipalUuid", attrSet);
- log(Level.INFO, "env Map:" + env, "\n");
-
- Set actions = new HashSet();
- actions.add(actionName);
- PolicyDecision pd = pe.getPolicyDecision(token, resourceName,
- actions, env);
- log(Level.INFO, "PolicyDecision XML:", pd.toXML());
- entering("testGetPolicyDecision()", null);
- }
-
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/policy/client/Issue619Test.java b/openam-test/src/test/java/com/sun/identity/policy/client/Issue619Test.java
deleted file mode 100644
index 391b3c2bce..0000000000
--- a/openam-test/src/test/java/com/sun/identity/policy/client/Issue619Test.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: Issue619Test.java,v 1.2 2008/06/25 05:44:20 qcheng Exp $
- *
- */
-
-package com.sun.identity.policy.client;
-import com.iplanet.sso.SSOToken;
-import com.iplanet.sso.SSOTokenManager;
-
-import com.sun.identity.shared.test.UnitTestBase;
-
-import com.sun.identity.policy.PolicyDecision;
-import com.sun.identity.policy.client.PolicyEvaluator;
-import com.sun.identity.policy.client.PolicyEvaluatorFactory;
-import com.sun.identity.policy.TokenUtils;
-
-import com.sun.identity.policy.interfaces.Condition;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.Set;
-
-import java.util.logging.Level;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.Parameters;
-
-
-/**
- * Test to verify fix for
- * Issue 619 unable to set the relam qualified auth level in policy env map
- */
-public class Issue619Test extends UnitTestBase {
-
- public Issue619Test() {
- super("OpenSSO-client Issue619Test");
- }
-
- @Test(groups={"policy-client"})
- @Parameters({"orgName", "userName", "password", "serviceName",
- "resourceName", "actionName"})
- public void testGetPolicyDecision(String orgName,
- String userName, String password,
- String serviceName, String resourceName, String actionName)
- throws Exception {
- entering("testGetPolicyDecision()", null);
- log(Level.INFO, "orgName:", orgName);
- log(Level.INFO, "userName:", userName);
- log(Level.INFO, "password:", password);
- log(Level.INFO, "serviceName:", serviceName);
- log(Level.INFO, "resourceName:", resourceName);
- log(Level.INFO, "actionName:", actionName);
- SSOToken token = TokenUtils.getSessionToken(orgName,
- userName, password);
- log(Level.INFO, "Created ssoToken", "\n");
-
- PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().
- getPolicyEvaluator(serviceName);
-
- Map env = new HashMap();
- Set attrSet = new HashSet();
- //attrSet.add(invocatorUuid);
- log(Level.INFO, "set auth level in envMap as a set containing "
- + "/:1, /:2", "\n");
- attrSet.add("/:1");
- attrSet.add("/:2");
- env.put(Condition.REQUEST_AUTH_LEVEL, attrSet);
- log(Level.INFO, "env Map:" + env, "\n");
-
- Set actions = new HashSet();
- actions.add(actionName);
- PolicyDecision pd = pe.getPolicyDecision(token, resourceName,
- actions, env);
- log(Level.INFO, "PolicyDecision XML:", pd.toXML());
- entering("testGetPolicyDecision()", null);
- }
-
-
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/policy/client/Issue736Test.java b/openam-test/src/test/java/com/sun/identity/policy/client/Issue736Test.java
deleted file mode 100644
index 0b20dc243d..0000000000
--- a/openam-test/src/test/java/com/sun/identity/policy/client/Issue736Test.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: Issue736Test.java,v 1.2 2008/06/25 05:44:20 qcheng Exp $
- *
- */
-
-package com.sun.identity.policy.client;
-import com.iplanet.sso.SSOToken;
-import com.iplanet.sso.SSOTokenManager;
-
-import com.sun.identity.shared.test.UnitTestBase;
-
-import com.sun.identity.policy.PolicyDecision;
-import com.sun.identity.policy.client.PolicyEvaluator;
-import com.sun.identity.policy.client.PolicyEvaluatorFactory;
-import com.sun.identity.policy.TokenUtils;
-
-import com.sun.identity.policy.interfaces.Condition;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import java.util.logging.Level;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.Parameters;
-
-
-/**
- * Test to verify fix for
- * Issue 736 Realm Alias Referrals enabled at the root org throws error for the
- * root org policy evaluation
- *
- * Test set up:
- *
- * Enable Realm Alias Referral in Policy Config Service global properites
- * Define an allow policy for http://host1.sample.com:80/banner.html allowing
- * access to all authenticated users.
- *
- * There should not be any realm with realm alias value of host1.sample.com
- *
- */
-public class Issue736Test extends UnitTestBase {
-
- public Issue736Test() {
- super("OpenSSO-client Issue736Test");
- }
-
- @Test(groups={"policy-client"})
- @Parameters({"orgName", "userName", "password", "serviceName",
- "actionName"})
- public void testGetPolicyDecision(String orgName,
- String userName, String password,
- String serviceName, String actionName)
- throws Exception {
- entering("Issue736Test.testGetPolicyDecision()", null);
- String resourceName = "http://host1.sample.com:80/banner.html";
- log(Level.INFO, "orgName:", orgName);
- log(Level.INFO, "userName:", userName);
- log(Level.INFO, "password:", password);
- log(Level.INFO, "serviceName:", serviceName);
- log(Level.INFO, "resourceName:", resourceName);
- log(Level.INFO, "actionName:", actionName);
- SSOToken token = TokenUtils.getSessionToken(orgName,
- userName, password);
- log(Level.INFO, "Created ssoToken", "\n");
-
- PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().
- getPolicyEvaluator(serviceName);
-
- Set actions = new HashSet();
- actions.add(actionName);
- PolicyDecision pd = pe.getPolicyDecision(token, resourceName,
- actions, null); //null envMap
- log(Level.INFO, "PolicyDecision XML:", pd.toXML());
- entering("testGetPolicyDecision()", null);
- }
-
-
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/policy/client/PolicyEvaluatorTest.java b/openam-test/src/test/java/com/sun/identity/policy/client/PolicyEvaluatorTest.java
deleted file mode 100644
index f4f68ed73b..0000000000
--- a/openam-test/src/test/java/com/sun/identity/policy/client/PolicyEvaluatorTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: PolicyEvaluatorTest.java,v 1.2 2008/06/25 05:44:20 qcheng Exp $
- *
- */
-
-package com.sun.identity.policy.client;
-import com.iplanet.sso.SSOToken;
-import com.iplanet.sso.SSOTokenManager;
-
-import com.sun.identity.shared.test.UnitTestBase;
-
-import com.sun.identity.policy.PolicyDecision;
-import com.sun.identity.policy.client.PolicyEvaluator;
-import com.sun.identity.policy.client.PolicyEvaluatorFactory;
-import com.sun.identity.policy.TokenUtils;
-
-import com.sun.identity.policy.plugins.AuthenticateToRealmCondition;
-import com.sun.identity.policy.plugins.AuthenticateToServiceCondition;
-import com.sun.identity.policy.plugins.AuthLevelCondition;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.HashSet;
-import java.util.Set;
-
-import java.util.logging.Level;
-
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-public class PolicyEvaluatorTest extends UnitTestBase {
-
- public PolicyEvaluatorTest() {
- super("OpenSSO-clientPolicyEvaluatorTest");
- }
-
- @Test(groups={"policy-client"})
- @Parameters({"orgName", "userName", "password", "serviceName",
- "resourceName", "actionName"})
- public void testGetPolicyDecision(String orgName,
- String userName, String password,
- String serviceName, String resourceName, String actionName)
- throws Exception {
- entering("testGetPolicyDecision()", null);
- log(Level.INFO, "orgName:", orgName);
- log(Level.INFO, "userName:", userName);
- log(Level.INFO, "password:", password);
- log(Level.INFO, "serviceName:", serviceName);
- log(Level.INFO, "resourceName:", resourceName);
- log(Level.INFO, "actionName:", actionName);
- SSOToken token = TokenUtils.getSessionToken(orgName,
- userName, password);
- log(Level.INFO, "Created ssoToken", "\n");
-
- PolicyEvaluator pe = PolicyEvaluatorFactory.getInstance().
- getPolicyEvaluator(serviceName);
-
- Map env = new HashMap();
- Set attrSet = new HashSet();
- //attrSet.add(invocatorUuid);
- env.put("invocatorPrincipalUuid", attrSet);
- log(Level.INFO, "env Map:" + env, "\n");
-
- Set actions = new HashSet();
- actions.add(actionName);
- PolicyDecision pd = pe.getPolicyDecision(token, resourceName,
- actions, env);
- log(Level.INFO, "PolicyDecision XML:", pd.toXML());
- entering("testGetPolicyDecision()", null);
- }
-
-
-}
-
diff --git a/openam-test/src/test/java/com/sun/identity/setup/TestInstaller.java b/openam-test/src/test/java/com/sun/identity/setup/TestInstaller.java
deleted file mode 100644
index 0a63be3fe3..0000000000
--- a/openam-test/src/test/java/com/sun/identity/setup/TestInstaller.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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]"
- *
- * Portions Copyrighted 2025 3A Systems LLC
- *
- * $Id: TestInstaller.java,v 1.5 2008/08/19 19:09:34 veiming Exp $
- *
- */
-
-package com.sun.identity.setup;
-
-import com.iplanet.services.util.Crypt;
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-import com.iplanet.am.util.SystemProperties;
-import com.sun.identity.authentication.UI.LoginLogoutMapping;
-import com.sun.identity.authentication.config.AMAuthenticationManager;
-import com.sun.identity.idm.AMIdentityRepository;
-import com.sun.identity.policy.PolicyException;
-import com.sun.identity.security.AdminTokenAction;
-import com.sun.identity.shared.encode.Hash;
-import com.sun.identity.sm.ServiceManager;
-import com.sun.identity.sm.SMSException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.StringTokenizer;
-import java.security.AccessController;
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
-/**
- * This class is the first class to get loaded by the Servlet container.
- * It has helper methods to determine the status of OpenSSO
- * configuration when deployed as a single web-application. If
- * OpenSSO server is not deployed as single web-application then the
- * configured status returned is always true.
- */
-public class TestInstaller {
- private ServletConfig config = null;
- private static ServletContext servletCtx = null;
- private final static String AMCONFIG = "AMConfig";
- private final static String SMS_STR = "sms";
- private final static String AMCONFIG_PROPERTIES = "AMConfig.properties";
- private static SSOToken adminToken = null;
-
-
- void install() {
- setServiceDefaultValues();
-
- try {
- initializeConfigProperties();
- reInitConfigProperties();
- SSOToken adminSSOToken = getAdminSSOToken();
-
- RegisterServices regService = new RegisterServices();
- regService.registers(adminSSOToken, true);
- Map map = ServicesDefaultValues.getDefaultValues();
- String hostname = (String)map.get("SERVER_HOST");
- ConfigureData configData = new ConfigureData(
- "config/template/sms", null, hostname, adminSSOToken);
- configData.configure();
- } catch (FileNotFoundException e) {
- System.err.println("TestInstaller.processRequest: " +
- "File not found Exception occured");
- e.printStackTrace();
- } catch (SecurityException e) {
- System.err.println("TestInstaller.processRequest");
- e.printStackTrace();
- } catch (IOException e) {
- System.err.println("TestInstaller.processRequest");
- e.printStackTrace();
- } catch (SMSException e) {
- System.err.println("TestInstaller.processRequest");
- e.printStackTrace();
- } catch (PolicyException e) {
- System.err.println("TestInstaller.processRequest");
- e.printStackTrace();
- } catch (SSOException e) {
- System.err.println("TestInstaller.processRequest");
- e.printStackTrace();
- }
- }
-
- private static void setServiceDefaultValues() {
- ResourceBundle res = ResourceBundle.getBundle("defaultProperties");
-
- String hostname = res.getString("host.name");
- int portnum = Integer.parseInt(res.getString("port"));
- String protocol = res.getString("protocol");
- String deployuri = res.getString("deploy.uri");
- String basedir = System.getProperty("java.io.tmpdir") +
- "/openssounittest";
- String cookieDomain = res.getString("cookie.domain");
- String adminPwd = res.getString("admin.password");
- String platformLocale = res.getString("locale");
-
- String encryptAdminPwd = Crypt.encrypt(adminPwd);
- String hashAdminPwd = Hash.hash(adminPwd);
-
- Map map = ServicesDefaultValues.getDefaultValues();
- ServicesDefaultValues.setDeployURI(deployuri, map);
-
- String port = Integer.toString(portnum);
- map.put("SERVER_PROTO", protocol);
- map.put("SERVER_HOST", hostname);
- map.put("SERVER_PORT", port);
-
- map.put("IS_INSTALL_VARDIR", basedir);
- map.put("BASE_DIR", basedir);
- map.put("COOKIE_DOMAIN", cookieDomain);
- map.put("SUCCESS_REDIRECT_URL", protocol + "://" + hostname + ":" +
- port + deployuri + "/base/AMAdminFrame");
-
- map.put("HASHADMINPASSWD", hashAdminPwd);
- map.put("HASHLDAPUSERPASSWD", hashAdminPwd);
- map.put("ENCADMINPASSWD", encryptAdminPwd);
- map.put("OUTPUT_DIR", basedir + "/" + deployuri);
-
- if (platformLocale != null) {
- map.put("PLATFORM_LOCALE", platformLocale);
- map.put("CURRENT_PLATFORM_LOCALE", platformLocale);
- map.put("AVAILABLE_LOCALES", platformLocale);
- }
- }
-
- private static void reInitConfigProperties()
- throws FileNotFoundException, IOException {
- Map map = ServicesDefaultValues.getDefaultValues();
- String basedir = map.get("BASE_DIR");
- reInitConfigProperties(basedir, true);
- }
-
- /**
- * Reinitializes the system with the new properties values.
- *
- * @throws FileNotFoundException if config file is missing.
- * @throws IOException if config file cannot be read.
- */
- private static void reInitConfigProperties(
- String basedir,
- boolean initAMConfig
- ) throws FileNotFoundException, IOException
- {
- if (initAMConfig) {
- reInitAMConfigProperties(basedir);
- }
- }
-
- private static void reInitAMConfigProperties(String baseDir)
- throws FileNotFoundException, IOException
- {
- // Read config file and initialize
- String fileName = baseDir + "/" + AMCONFIG_PROPERTIES;
- try {
- FileInputStream FInpStr = new FileInputStream(fileName);
- if (FInpStr != null) {
- Properties oprops = new Properties();
- oprops.load(FInpStr);
- SystemProperties.initializeProperties(oprops);
- FInpStr.close();
- } else {
- System.err.println(
- "TestInstaller.reInitAMConfigProperties: Unable to open: " +
- fileName);
- }
- } catch (FileNotFoundException e) {
- System.err.println("TestInstaller.reInitAMConfigProperties: " +
- "Unable to re-initialize properties");
- throw e;
- } catch (IOException e) {
- System.err.println("TestInstaller.reInitAMConfigProperties: " +
- "Unable to load properties");
- throw e;
- }
- }
-
- /**
- * Helper method to return Admin token
- * @return Admin Token
- */
- private static SSOToken getAdminSSOToken() {
- if (adminToken == null) {
- adminToken = (SSOToken)AccessController.doPrivileged(
- AdminTokenAction.getInstance());
- }
- return adminToken;
- }
-
- /**
- * Initialize AMConfig.propeties with host specific values
- */
- private static void initializeConfigProperties()
- throws SecurityException, IOException {
- List dataFiles = getTagSwapConfigFiles();
-
- String origpath = "@BASE_DIR@";
- Map map = ServicesDefaultValues.getDefaultValues();
- String basedir = (String)map.get("BASE_DIR");
- String deployuri = (String)map.get("SERVER_URI");
- String newpath = basedir;
-
- try {
- File fhm = new File(basedir + deployuri + "/" + SMS_STR);
- fhm.mkdirs();
- } catch (SecurityException e){
- System.err.println("TestInstaller.initializeConfigProperties");
- throw e;
- }
-
- for (String file : dataFiles) {
- InputStreamReader fin = new InputStreamReader(
- new FileInputStream(file));
-
- StringBuffer sbuf = new StringBuffer();
- char[] cbuf = new char[1024];
- int len;
- while ((len = fin.read(cbuf)) > 0) {
- sbuf.append(cbuf, 0, len);
- }
- FileWriter fout = null;
-
- int idx = file.lastIndexOf("/");
- String absFile = (idx != -1) ? file.substring(idx+1) : file;
-
- try {
- fout = new FileWriter(basedir + "/" + absFile);
- String inpStr = sbuf.toString();
- fout.write(ServicesDefaultValues.tagSwap(inpStr));
- } catch (IOException e) {
- System.err.println("TestInstaller.initializeConfigProperties");
- throw e;
- } finally {
- if (fin != null) {
- try {
- fin.close();
- } catch (Exception ex) {
- //No handling requried
- }
- }
- if (fout != null) {
- try {
- fout.close();
- } catch (Exception ex) {
- //No handling requried
- }
- }
- }
- }
- }
-
- private static List getTagSwapConfigFiles()
- throws MissingResourceException
- {
- List fileNames = new ArrayList();
- ResourceBundle rb = ResourceBundle.getBundle("configuratorTagSwap");
- String strFiles = rb.getString("tagswap.files");
- StringTokenizer st = new StringTokenizer(strFiles);
- while (st.hasMoreTokens()) {
- String f = st.nextToken();
- fileNames.add(f.replaceAll("WEB-INF/", "config/"));
- }
- return fileNames;
- }
-
- public static void main(String[] args) {
- TestInstaller installer = new TestInstaller();
- installer.install();
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/sm/RealmTest.java b/openam-test/src/test/java/com/sun/identity/sm/RealmTest.java
deleted file mode 100644
index 731119430f..0000000000
--- a/openam-test/src/test/java/com/sun/identity/sm/RealmTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: RealmTest.java,v 1.3 2008/06/25 05:44:22 qcheng Exp $
- *
- */
-
-package com.sun.identity.sm;
-
-import com.iplanet.sso.SSOException;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.test.common.TestBase;
-import java.util.Collections;
-import java.util.Set;
-import org.testng.annotations.Test;
-
-/**
- * Tests for creation and deletion of realms using OrganizationConfigManager.
- */
-public class RealmTest extends TestBase {
-
- public RealmTest() {
- super("SMS");
- }
-
- /**
- * Test case for Issue #181. When a realm is deleted and created
- * again, it fails with "Realm already exists".
- */
- @Test(groups = {"api"}) //, expectedExceptions={SMSException.class})
- public void createRealmTwice() throws SMSException, SSOException {
- SSOToken adminToken = getAdminSSOToken();
- OrganizationConfigManager ocm = new OrganizationConfigManager(
- adminToken, "/");
- String realm = "sm-issue181-create-realm-twice";
- ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
- ocm.deleteSubOrganization(realm, true);
- ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
- ocm.deleteSubOrganization(realm, true);
- ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
- ocm.deleteSubOrganization(realm, true);
- }
-
- /**
- * Test case of creating a new with the same name. Should throw
- * an SMSException that realm already exists.
- */
- @Test(groups = ("api"), expectedExceptions={SMSException.class})
- public void createRealmWithSameName() throws SMSException,
- SSOException {
- OrganizationConfigManager ocm = null;
- String realm = "sm-noissue-create-realm-with-same-name";
- try {
- SSOToken token = getAdminSSOToken();
- ocm = new OrganizationConfigManager(token, "/");
- ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
- ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
- } finally {
- if (ocm != null) {
- ocm.deleteSubOrganization(realm, true);
- }
- }
- }
-
- /**
- * Test case for Issue #230. Unable to get sub realms using remote
- */
- @Test(groups = {"api"})
- public void verifyJAXRPC() throws SMSException, SSOException {
- String realm = "sm-issue-230-for-remote";
- OrganizationConfigManager ocm =
- new OrganizationConfigManager(getAdminSSOToken(), "/");
- try {
- // Create an organization
- ocm.createSubOrganization(realm, Collections.EMPTY_MAP);
- // Search for sub-organizations
- Set realms = ocm.getSubOrganizationNames();
- // Check if the realm exists
- if (!realms.contains(realm)) {
- throw (new SMSException("issue 230 failed"));
- }
- } finally {
- if (ocm != null) {
- ocm.deleteSubOrganization(realm, true);
- }
- }
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/test/common/Bootstrap.java b/openam-test/src/test/java/com/sun/identity/test/common/Bootstrap.java
deleted file mode 100644
index a81d82c84b..0000000000
--- a/openam-test/src/test/java/com/sun/identity/test/common/Bootstrap.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: Bootstrap.java,v 1.2 2008/06/25 05:44:23 qcheng Exp $
- *
- */
-
-package com.sun.identity.test.common;
-
-import com.iplanet.am.util.SystemProperties;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.cli.FormatUtils;
-import com.sun.identity.common.configuration.ServerConfiguration;
-import com.sun.identity.security.AdminTokenAction;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.security.AccessController;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * This is to create AMConfig.properties in file system to
- * enable unittest.
- */
-public class Bootstrap {
- private Bootstrap() {
- }
-
- public static void main(String[] args) {
- String basedir = args[0];
- try {
- com.sun.identity.setup.Bootstrap.load();
- SSOToken token = (SSOToken) AccessController.doPrivileged(
- AdminTokenAction.getInstance());
-
-
- String serverName = SystemProperties.getServerInstanceName();
- Properties prop = ServerConfiguration.getServerInstance(
- token, serverName);
- Map defProp = ServerConfiguration.getServerInstance(
- token, ServerConfiguration.DEFAULT_SERVER_CONFIG);
- defProp.putAll(prop);
- defProp.put(SystemProperties.CONFIG_PATH, basedir);
-
- writeToFile(basedir + "/AMConfig.properties",
- FormatUtils.formatProperties(defProp));
-
- String xml = ServerConfiguration.getServerConfigXML(
- token, serverName);
- writeToFile(basedir + "/serverconfig.xml", xml);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-
- private static void writeToFile(String outfile, String content)
- throws FileNotFoundException, SecurityException {
- FileOutputStream fout = null;
- PrintWriter pwout = null;
-
- try {
- fout = new FileOutputStream(outfile, true);
- pwout = new PrintWriter(fout, true);
- pwout.write(content);
- pwout.flush();
- } finally {
- try {
- if (fout != null) {
- fout.close();
- }
- if (pwout != null) {
- pwout.close();
- }
- } catch (IOException ex) {
- //do nothing
- }
- }
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/test/common/FileHelper.java b/openam-test/src/test/java/com/sun/identity/test/common/FileHelper.java
deleted file mode 100644
index bb8e77b768..0000000000
--- a/openam-test/src/test/java/com/sun/identity/test/common/FileHelper.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: FileHelper.java,v 1.2 2008/06/25 05:44:23 qcheng Exp $
- *
- */
-
-package com.sun.identity.test.common;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * This class provides helper methods for file related operations.
- */
-public class FileHelper {
-
- /**
- * Creates a new instance of FileHelper
- */
- private FileHelper() {
- }
-
- /**
- * Returns byte array that contains the content of a file.
- *
- * @param fileName Name of file.
- * @return byte array that contains the content of a file.
- * @throws IOException if file is not found; or content cannot be read.
- */
- public static byte[] getBinary(String fileName)
- throws IOException
- {
- byte[] content = null;
- InputStream in = null;
- try {
- File f = new File(fileName);
- in = new FileInputStream(fileName);
- content = new byte[(int)f.length()];
- in.read(content);
- } finally {
- if (in != null) {
- in.close();
- }
- }
- return content;
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/test/common/TestBase.java b/openam-test/src/test/java/com/sun/identity/test/common/TestBase.java
deleted file mode 100644
index 48590ba1cf..0000000000
--- a/openam-test/src/test/java/com/sun/identity/test/common/TestBase.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2006 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: TestBase.java,v 1.5 2008/11/20 17:53:01 veiming Exp $
- *
- */
-
-/**
- * Portions Copyrighted 2012 ForgeRock Inc
- */
-package com.sun.identity.test.common;
-
-import com.iplanet.services.util.Crypt;
-import com.iplanet.sso.SSOToken;
-import com.sun.identity.security.AdminTokenAction;
-import com.sun.identity.setup.Bootstrap;
-import com.sun.identity.setup.ConfiguratorException;
-import com.sun.identity.shared.test.UnitTestBase;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * This class is the base for all OpenAM unit testcases.
- * It has commonly used methods; and hopefully we can grow this class
- * to support more methods in future.
- */
-public abstract class TestBase extends UnitTestBase {
- static {
- bootstrap();
- }
-
- private static void bootstrap() {
- try {
- Bootstrap.load();
- AdminTokenAction.getInstance().authenticationInitialized();
- Crypt.checkCaller();
- } catch (ConfiguratorException e) {
- e.printStackTrace();
- System.exit(1);
- } catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
-
- protected TestBase(String componentName) {
- super(componentName);
- }
-
- /**
- * Returns super administrator single sign on token.
- *
- * @return super administrator single sign on token.
- */
- protected SSOToken getAdminSSOToken() {
- return AccessController.doPrivileged(
- AdminTokenAction.getInstance());
- }
-}
diff --git a/openam-test/src/test/java/com/sun/identity/workflow/SAML2Test.java b/openam-test/src/test/java/com/sun/identity/workflow/SAML2Test.java
deleted file mode 100644
index 100579ca13..0000000000
--- a/openam-test/src/test/java/com/sun/identity/workflow/SAML2Test.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2008 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
- * https://opensso.dev.java.net/public/CDDLv1.0.html or
- * opensso/legal/CDDLv1.0.txt
- * 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: SAML2Test.java,v 1.3 2008/06/25 05:50:17 qcheng Exp $
- *
- */
-
-package com.sun.identity.workflow;
-
-import com.sun.identity.test.common.TestBase;
-import com.sun.identity.test.common.FileHelper;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-public class SAML2Test extends TestBase {
- public SAML2Test() {
- super("Workflow");
- }
-
- @BeforeTest(groups = {"saml2"})
- public void suiteSetup() {
- }
-
- @Test(groups = {"samlv2"})
- public void createHostedIDP()
- throws IOException, WorkflowException {
- entering("createHostedIDP", null);
- CreateHostedIDP task = new CreateHostedIDP();
- Map map = new HashMap();
- map.put(ParameterKeys.P_REALM, "/");
- map.put(ParameterKeys.P_COT, "cottest");
- map.put(ParameterKeys.P_ENTITY_ID, "http://test.com/samples");
- map.put(ParameterKeys.P_IDP_E_CERT, "test");
- map.put(ParameterKeys.P_IDP_S_CERT, "test");
- exiting("createHostedIDP");
- }
-
- @Test(groups = {"samlv2"})
- public void createHostedIDPWithFile()
- throws IOException, WorkflowException {
- entering("createHostedIDPWithFile", null);
- createHostedIDPWithFileEx();
- exiting("createHostedIDPWithFile");
- }
-
- @Test(
- groups = {"samlv2"},
- expectedExceptions = {WorkflowException.class},
- dependsOnMethods = {"createHostedIDPWithFile"}
- )
- public void createHostedIDPWithFileDup()
- throws IOException, WorkflowException {
- entering("createHostedIDPWithFileDup", null);
- createHostedIDPWithFileEx();
- exiting("createHostedIDPWithFileDup");
- }
-
- private void createHostedIDPWithFileEx()
- throws IOException, WorkflowException {
- String meta = getFileContent("mock/workflow/saml2meta.xml");
- String extended = getFileContent("mock/workflow/saml2extended.xml");
-
- CreateHostedIDP task = new CreateHostedIDP();
- Map map = new HashMap();
- map.put(ParameterKeys.P_META_DATA, meta);
- map.put(ParameterKeys.P_EXENDED_DATA, extended);
- map.put(ParameterKeys.P_COT, "cottest");
- map.put(ParameterKeys.P_ATTR_MAPPING,
- "samplesasset1=localattr1|samplesasset2=localattr2");
- task.execute(Locale.getDefault(), map);
- }
-
- protected String getFileContent(String filename)
- throws IOException {
- StringBuffer buff = new StringBuffer();
- FileReader input = new FileReader(filename);
- BufferedReader bufRead = new BufferedReader(input);
- String line = bufRead.readLine();
- while (line != null) {
- buff.append(line).append("\n");
- line = bufRead.readLine();
- }
- return buff.toString();
- }
-}