You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/01/26 13:04:42 UTC
[11/21] syncope git commit: [SYNCOPE-152] Moving console IT under
fit/core-reference in order to speed-up the total build time
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
deleted file mode 100644
index 746459f..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.SystemUtils;
-import org.apache.syncope.client.cli.Command;
-import org.apache.syncope.client.cli.commands.connector.ConnectorCommand;
-import org.apache.syncope.client.cli.commands.entitlement.EntitlementCommand;
-import org.apache.syncope.client.cli.commands.group.GroupCommand;
-import org.apache.syncope.client.cli.commands.install.InstallCommand;
-import org.apache.syncope.client.cli.commands.policy.PolicyCommand;
-import org.apache.syncope.client.cli.commands.report.ReportCommand;
-import org.apache.syncope.client.cli.commands.role.RoleCommand;
-import org.apache.syncope.client.cli.commands.user.UserCommand;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class CLIITCase extends AbstractITCase {
-
- private static final String SCRIPT_FILENAME = "syncopeadm";
-
- private static ProcessBuilder PROCESS_BUILDER;
-
- @BeforeClass
- public static void install() {
- Properties props = new Properties();
- InputStream propStream = null;
- try {
- propStream = ExceptionMapperITCase.class.getResourceAsStream("/cli-test.properties");
- props.load(propStream);
-
- File workDir = new File(props.getProperty("cli-work.dir"));
- PROCESS_BUILDER = new ProcessBuilder();
- PROCESS_BUILDER.directory(workDir);
-
- PROCESS_BUILDER.command(getCommand(
- new InstallCommand().getClass().getAnnotation(Command.class).name(),
- InstallCommand.Options.SETUP_DEBUG.getOptionName()));
- Process process = PROCESS_BUILDER.start();
- process.waitFor();
-
- File cliPropertiesFile = new File(workDir + File.separator + "cli.properties");
- assertTrue(cliPropertiesFile.exists());
- } catch (IOException | InterruptedException e) {
- fail(e.getMessage());
- } finally {
- IOUtils.closeQuietly(propStream);
- }
- }
-
- private static String[] getCommand(final String... arguments) {
- List<String> command = new ArrayList<>();
-
- if (SystemUtils.IS_OS_WINDOWS) {
- command.add("cmd");
- command.add(SCRIPT_FILENAME + ".bat");
- } else {
- command.add("/bin/bash");
- command.add(SCRIPT_FILENAME + ".sh");
- }
-
- CollectionUtils.addAll(command, arguments);
-
- return command.toArray(new String[command.size()]);
- }
-
- @Test
- public void runScriptWithoutOptions() {
- try {
- PROCESS_BUILDER.command(getCommand());
- Process process = PROCESS_BUILDER.start();
-
- String result = IOUtils.toString(process.getInputStream());
- assertTrue(result.startsWith("\nUsage: Main [options]"));
- assertTrue(result.contains(
- new EntitlementCommand().getClass().getAnnotation(Command.class).name()
- + " "
- + EntitlementCommand.EntitlementOptions.HELP.getOptionName()));
- assertTrue(result.contains(
- new GroupCommand().getClass().getAnnotation(Command.class).name()
- + " "
- + GroupCommand.GroupOptions.HELP.getOptionName()));
- process.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void entitlementCount() {
- try {
- PROCESS_BUILDER.command(getCommand(
- new EntitlementCommand().getClass().getAnnotation(Command.class).name(),
- EntitlementCommand.EntitlementOptions.LIST.getOptionName()));
- Process process = PROCESS_BUILDER.start();
-
- long entitlements = IterableUtils.countMatches(IOUtils.readLines(process.getInputStream()),
- new Predicate<String>() {
-
- @Override
- public boolean evaluate(final String line) {
- return line.startsWith("-");
- }
- });
- assertEquals(syncopeService.info().getEntitlements().size(), entitlements);
-
- process.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void connectorCount() {
- try {
- PROCESS_BUILDER.command(getCommand(
- new ConnectorCommand().getClass().getAnnotation(Command.class).name(),
- ConnectorCommand.ConnectorOptions.LIST_BUNDLES.getOptionName()));
- Process process = PROCESS_BUILDER.start();
-
- long bundles = IterableUtils.countMatches(IOUtils.readLines(process.getInputStream()),
- new Predicate<String>() {
-
- @Override
- public boolean evaluate(final String line) {
- return line.startsWith(" > BUNDLE NAME:");
- }
- });
- assertEquals(connectorService.getBundles(null).size(), bundles);
-
- process.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void userRead() {
- final long userId1 = 1;
- final long userId2 = 2;
- final long userId3 = 3;
- final long userId4 = 4;
- final long userId5 = 5;
- try {
- PROCESS_BUILDER.command(getCommand(
- new UserCommand().getClass().getAnnotation(Command.class).name(),
- UserCommand.UserOptions.READ_BY_ID.getOptionName(),
- String.valueOf(userId1)));
- Process process = PROCESS_BUILDER.start();
- String result = IOUtils.toString(process.getInputStream());
- assertTrue(result.contains("username: " + userService.read(userId1).getUsername()));
- process.destroy();
-
- PROCESS_BUILDER.command(getCommand(
- new UserCommand().getClass().getAnnotation(Command.class).name(),
- UserCommand.UserOptions.READ_BY_ID.getOptionName(),
- String.valueOf(userId1), String.valueOf(userId2),
- String.valueOf(userId3), String.valueOf(userId4), String.valueOf(userId5)));
- Process process2 = PROCESS_BUILDER.start();
- long users = IterableUtils.countMatches(IOUtils.readLines(process2.getInputStream()),
- new Predicate<String>() {
-
- @Override
- public boolean evaluate(final String line) {
- return line.startsWith(" > USER ID:");
- }
- });
- assertEquals(5, users);
-
- process2.destroy();
-
- PROCESS_BUILDER.command(getCommand(
- new UserCommand().getClass().getAnnotation(Command.class).name(),
- UserCommand.UserOptions.READ_BY_ID.getOptionName(),
- String.valueOf(userId1), String.valueOf(userId2),
- String.valueOf(userId3), String.valueOf(userId4), String.valueOf(userId5)));
- Process process3 = PROCESS_BUILDER.start();
- String result3 = IOUtils.toString(process3.getInputStream());
- assertTrue(
- result3.contains("username: " + userService.read(userId1).getUsername())
- && result3.contains("username: " + userService.read(userId2).getUsername())
- && result3.contains("username: " + userService.read(userId3).getUsername())
- && result3.contains("username: " + userService.read(userId4).getUsername())
- && result3.contains("username: " + userService.read(userId5).getUsername()));
- process3.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void roleRead() {
- final String roleId = "Search for realm evenTwo";
- try {
- PROCESS_BUILDER.command(getCommand(
- new RoleCommand().getClass().getAnnotation(Command.class).name(),
- RoleCommand.RoleOptions.READ.getOptionName(),
- roleId));
- final Process process = PROCESS_BUILDER.start();
- final String result = IOUtils.toString(process.getInputStream());
- assertTrue(result.contains(roleService.read(roleId).getEntitlements().iterator().next()));
-
- process.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void reportNotExists() {
- try {
- PROCESS_BUILDER.command(getCommand(
- new ReportCommand().getClass().getAnnotation(Command.class).name(),
- ReportCommand.ReportOptions.READ.getOptionName(),
- "2"));
- final Process process = PROCESS_BUILDER.start();
- final String result = IOUtils.toString(process.getInputStream());
- assertTrue(result.contains("- Report 2 doesn't exist"));
-
- process.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void policyError() {
- try {
- PROCESS_BUILDER.command(getCommand(
- new PolicyCommand().getClass().getAnnotation(Command.class).name(),
- PolicyCommand.PolicyOptions.READ.getOptionName(),
- "wrong"));
- final Process process = PROCESS_BUILDER.start();
- final String result = IOUtils.toString(process.getInputStream());
- assertTrue(result.contains(
- "- Error reading wrong. It isn't a valid policy value because it isn't a boolean value"));
-
- process.destroy();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java
deleted file mode 100644
index 0021922..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelDetector.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import org.apache.syncope.common.rest.api.service.SyncopeService;
-
-public class CamelDetector {
-
- public static boolean isCamelEnabledForUsers(final SyncopeService syncopeService) {
- return syncopeService.info().getUserProvisioningManager().indexOf("Camel") != -1;
- }
-
- public static boolean isCamelEnabledForGroups(final SyncopeService syncopeService) {
- return syncopeService.info().getGroupProvisioningManager().indexOf("Camel") != -1;
- }
-
- public static boolean isCamelEnabledForAnyObjects(final SyncopeService syncopeService) {
- return syncopeService.info().getAnyObjectProvisioningManager().indexOf("Camel") != -1;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
deleted file mode 100644
index 0ef0dd5..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.List;
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.to.CamelRouteTO;
-import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.junit.Assume;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class CamelRouteITCase extends AbstractITCase {
-
- @Test
- public void userRoutes() {
- Assume.assumeTrue(CamelDetector.isCamelEnabledForUsers(syncopeService));
-
- List<CamelRouteTO> userRoutes = camelRouteService.list(AnyTypeKind.USER);
- assertNotNull(userRoutes);
- assertEquals(16, userRoutes.size());
- for (CamelRouteTO route : userRoutes) {
- assertNotNull(route.getContent());
- }
- }
-
- @Test
- public void groupRoutes() {
- Assume.assumeTrue(CamelDetector.isCamelEnabledForGroups(syncopeService));
-
- List<CamelRouteTO> groupRoutes = camelRouteService.list(AnyTypeKind.GROUP);
- assertNotNull(groupRoutes);
- assertEquals(8, groupRoutes.size());
- for (CamelRouteTO route : groupRoutes) {
- assertNotNull(route.getContent());
- }
- }
-
- private CamelRouteTO doUpdate(final String key, final String content) {
- CamelRouteTO route = camelRouteService.read(key);
- route.setContent(content);
- camelRouteService.update(route);
- // getting new route definition
- return camelRouteService.read(key);
- }
-
- @Test
- public void update() {
- Assume.assumeTrue(CamelDetector.isCamelEnabledForUsers(syncopeService));
-
- CamelRouteTO oldRoute = camelRouteService.read("createUser");
- assertNotNull(oldRoute);
- String routeContent = "<route id=\"createUser\">\n"
- + " <from uri=\"direct:createUser\"/>\n"
- + " <setProperty propertyName=\"actual\">\n"
- + " <simple>${body}</simple>\n"
- + " </setProperty>\n"
- + " <doTry>\n"
- + " <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n"
- + " ${property.enabled},${property.storePassword})\"/>\n"
- + " <process ref=\"userCreateProcessor\" />\n"
- + " <to uri=\"direct:createPort\"/>\n"
- + " <to uri=\"log:myLog\"/>\n"
- + " <doCatch> \n"
- + " <exception>java.lang.RuntimeException</exception>\n"
- + " <handled>\n"
- + " <constant>false</constant>\n"
- + " </handled>\n"
- + " <to uri=\"direct:createPort\"/>\n"
- + " </doCatch>\n"
- + " </doTry>\n"
- + "</route>";
- try {
- CamelRouteTO route = doUpdate("createUser", routeContent);
- assertEquals(routeContent, route.getContent());
- } finally {
- doUpdate(oldRoute.getKey(), oldRoute.getContent());
- }
- }
-
- @Test
- public void scriptingUpdate() {
- Assume.assumeTrue(CamelDetector.isCamelEnabledForUsers(syncopeService));
-
- CamelRouteTO oldRoute = camelRouteService.read("createUser");
- // updating route content including new attribute management
-
- String routeContent = ""
- + " <route id=\"createUser\">\n"
- + " <from uri=\"direct:createUser\"/>\n"
- + " <setProperty propertyName=\"actual\">\n"
- + " <simple>${body}</simple>\n"
- + " </setProperty>\n"
- + " <setBody>\n"
- + " <groovy>\n"
- + " org.apache.commons.collections4."
- + "CollectionUtils.get(request.body.getPlainAttrs(), 3).getValues().set(0,\"true\")\n"
- + " return request.body\n"
- + " </groovy>\n"
- + " </setBody>\n"
- + " <doTry>\n"
- + " <bean ref=\"uwfAdapter\" method=\"create(${body},${property.disablePwdPolicyCheck},\n"
- + " ${property.enabled},${property.storePassword})\"/>\n"
- + " <process ref=\"userCreateProcessor\"/>\n"
- + " <to uri=\"direct:createPort\"/>\n"
- + " <doCatch> \n"
- + " <exception>java.lang.RuntimeException</exception>\n"
- + " <handled>\n"
- + " <constant>false</constant>\n"
- + " </handled>\n"
- + " <to uri=\"direct:createPort\"/>\n"
- + " </doCatch>\n"
- + " </doTry>\n"
- + " </route> ";
- try {
- doUpdate("createUser", routeContent);
-
- // creating new schema attribute for user
- PlainSchemaTO schemaTO = new PlainSchemaTO();
- schemaTO.setKey("camelAttribute");
- schemaTO.setType(AttrSchemaType.String);
- createSchema(SchemaType.PLAIN, schemaTO);
-
- AnyTypeClassTO typeClass = new AnyTypeClassTO();
- typeClass.setKey("camelAttribute");
- typeClass.getPlainSchemas().add(schemaTO.getKey());
- anyTypeClassService.create(typeClass);
-
- UserTO userTO = new UserTO();
- userTO.setRealm(SyncopeConstants.ROOT_REALM);
- userTO.getAuxClasses().add(typeClass.getKey());
- String userId = getUUIDString() + "camelUser@syncope.apache.org";
- userTO.setUsername(userId);
- userTO.setPassword("password123");
- userTO.getPlainAttrs().add(attrTO("userId", userId));
- userTO.getPlainAttrs().add(attrTO("fullname", userId));
- userTO.getPlainAttrs().add(attrTO("surname", userId));
- userTO.getPlainAttrs().add(attrTO("camelAttribute", "false"));
-
- userTO = createUser(userTO).getAny();
- assertNotNull(userTO);
- assertEquals("true", IterableUtils.get(userTO.getPlainAttrs(), 3).getValues().get(0));
- } finally {
- doUpdate(oldRoute.getKey(), oldRoute.getContent());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
deleted file mode 100644
index 1fb3221..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import org.apache.commons.io.IOUtils;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.AttrTO;
-import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.EntityViolationType;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class ConfigurationITCase extends AbstractITCase {
-
- @Test
- public void create() {
- PlainSchemaTO testKey = new PlainSchemaTO();
- testKey.setKey("testKey" + getUUIDString());
- testKey.setType(AttrSchemaType.String);
- createSchema(SchemaType.PLAIN, testKey);
-
- AttrTO conf = new AttrTO.Builder().schema(testKey.getKey()).value("testValue").build();
-
- configurationService.set(conf);
-
- AttrTO actual = configurationService.get(conf.getSchema());
- assertEquals(actual, conf);
- }
-
- @Test
- public void createRequired() {
- PlainSchemaTO testKey = new PlainSchemaTO();
- testKey.setKey("testKey" + getUUIDString());
- testKey.setType(AttrSchemaType.String);
- testKey.setMandatoryCondition("true");
- createSchema(SchemaType.PLAIN, testKey);
-
- AttrTO conf = new AttrTO.Builder().schema(testKey.getKey()).build();
- try {
- configurationService.set(conf);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
- }
-
- conf.getValues().add("testValue");
- configurationService.set(conf);
-
- AttrTO actual = configurationService.get(conf.getSchema());
- assertEquals(actual, conf);
- }
-
- @Test
- public void delete() throws UnsupportedEncodingException {
- try {
- configurationService.delete("nonExistent");
- fail("The delete operation should throw an exception because of nonExistent schema");
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
- }
-
- AttrTO tokenLength = configurationService.get("token.length");
-
- configurationService.delete("token.length");
-
- AttrTO actual = configurationService.get(tokenLength.getSchema());
- assertNotEquals(actual, tokenLength);
-
- configurationService.set(tokenLength);
-
- actual = configurationService.get(tokenLength.getSchema());
- assertEquals(actual, tokenLength);
- }
-
- @Test
- public void list() {
- List<AttrTO> wholeConf = configurationService.list();
- assertNotNull(wholeConf);
- for (AttrTO conf : wholeConf) {
- assertNotNull(conf);
- }
- }
-
- @Test
- public void read() {
- AttrTO conf = configurationService.get("token.expireTime");
- assertNotNull(conf);
- }
-
- @Test
- public void update() {
- AttrTO expireTime = configurationService.get("token.expireTime");
- int value = Integer.parseInt(expireTime.getValues().get(0));
- value++;
- expireTime.getValues().set(0, value + "");
-
- configurationService.set(expireTime);
-
- AttrTO newConfigurationTO = configurationService.get(expireTime.getSchema());
- assertEquals(expireTime, newConfigurationTO);
- }
-
- @Test
- public void dbExport() throws IOException {
- Response response = configurationService.export();
- assertNotNull(response);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode());
- assertTrue(response.getMediaType().toString().startsWith(MediaType.TEXT_XML));
- String contentDisposition = response.getHeaderString(HttpHeaders.CONTENT_DISPOSITION);
- assertNotNull(contentDisposition);
-
- Object entity = response.getEntity();
- assertTrue(entity instanceof InputStream);
- String configExport = IOUtils.toString((InputStream) entity, SyncopeConstants.DEFAULT_ENCODING);
- assertFalse(configExport.isEmpty());
- assertTrue(configExport.length() > 1000);
- }
-
- @Test
- public void issueSYNCOPE418() {
- PlainSchemaTO failing = new PlainSchemaTO();
- failing.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
- failing.setType(AttrSchemaType.String);
-
- try {
- createSchema(SchemaType.PLAIN, failing);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
-
- assertNotNull(e.getElements());
- assertEquals(1, e.getElements().size());
- assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
deleted file mode 100644
index 82f6f02..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
+++ /dev/null
@@ -1,746 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import javax.ws.rs.core.Response;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.Transformer;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.BulkAction;
-import org.apache.syncope.common.lib.to.ConnBundleTO;
-import org.apache.syncope.common.lib.to.ConnIdObjectClassTO;
-import org.apache.syncope.common.lib.to.ConnInstanceTO;
-import org.apache.syncope.common.lib.to.ConnPoolConfTO;
-import org.apache.syncope.common.lib.to.MappingItemTO;
-import org.apache.syncope.common.lib.to.MappingTO;
-import org.apache.syncope.common.lib.to.ProvisionTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.ConnConfPropSchema;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.common.lib.types.ConnectorCapability;
-import org.apache.syncope.common.lib.types.IntMappingType;
-import org.apache.syncope.common.rest.api.service.ConnectorService;
-import org.apache.syncope.common.rest.api.service.ResourceService;
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class ConnectorITCase extends AbstractITCase {
-
- private static String connectorServerLocation;
-
- private static String connidSoapVersion;
-
- private static String connidDbTableVersion;
-
- private static String testJDBCURL;
-
- @BeforeClass
- public static void setUpConnIdBundles() throws IOException {
- InputStream propStream = null;
- try {
- Properties props = new Properties();
- propStream = ConnectorITCase.class.getResourceAsStream("/connid.properties");
- props.load(propStream);
-
- for (String location : props.getProperty("connid.locations").split(",")) {
- if (!location.startsWith("file")) {
- connectorServerLocation = location;
- }
- }
-
- connidSoapVersion = props.getProperty("connid.soap.version");
- connidDbTableVersion = props.getProperty("connid.database.version");
-
- testJDBCURL = props.getProperty("testdb.url");
- } catch (Exception e) {
- LOG.error("Could not load /connid.properties", e);
- } finally {
- IOUtils.closeQuietly(propStream);
- }
- assertNotNull(connectorServerLocation);
- assertNotNull(connidSoapVersion);
- assertNotNull(connidDbTableVersion);
- assertNotNull(testJDBCURL);
- }
-
- @Test(expected = SyncopeClientException.class)
- public void createWithException() {
- ConnInstanceTO connectorTO = new ConnInstanceTO();
-
- Response response = connectorService.create(connectorTO);
- if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
- throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
- }
- }
-
- @Test
- public void create() {
- ConnInstanceTO connectorTO = new ConnInstanceTO();
- connectorTO.setLocation(connectorService.read(100L, Locale.ENGLISH.getLanguage()).getLocation());
- connectorTO.setVersion(connidSoapVersion);
- connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
- connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
- connectorTO.setDisplayName("Display name");
- connectorTO.setConnRequestTimeout(15);
-
- // set the connector configuration using PropertyTO
- Set<ConnConfProperty> conf = new HashSet<>();
-
- ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
- endpointSchema.setName("endpoint");
- endpointSchema.setType(String.class.getName());
- endpointSchema.setRequired(true);
- ConnConfProperty endpoint = new ConnConfProperty();
- endpoint.setSchema(endpointSchema);
- endpoint.getValues().add("http://localhost:8888/wssample/services");
- endpoint.getValues().add("Provisioning");
- conf.add(endpoint);
-
- ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
- servicenameSchema.setName("servicename");
- servicenameSchema.setType(String.class.getName());
- servicenameSchema.setRequired(true);
- ConnConfProperty servicename = new ConnConfProperty();
- servicename.setSchema(servicenameSchema);
- conf.add(servicename);
-
- // set connector configuration
- connectorTO.getConf().addAll(conf);
-
- // set connector capabilities
- connectorTO.getCapabilities().add(ConnectorCapability.CREATE);
- connectorTO.getCapabilities().add(ConnectorCapability.UPDATE);
-
- // set connector pool conf
- ConnPoolConfTO cpc = new ConnPoolConfTO();
- cpc.setMaxObjects(1534);
- connectorTO.setPoolConf(cpc);
-
- Response response = connectorService.create(connectorTO);
- if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
- throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
- }
-
- ConnInstanceTO actual = getObject(
- response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
- assertNotNull(actual);
-
- assertEquals(actual.getBundleName(), connectorTO.getBundleName());
- assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
- assertEquals(actual.getVersion(), connectorTO.getVersion());
- assertEquals("Display name", actual.getDisplayName());
- assertEquals(Integer.valueOf(15), actual.getConnRequestTimeout());
- assertEquals(connectorTO.getCapabilities(), actual.getCapabilities());
- assertNotNull(actual.getPoolConf());
- assertEquals(1534, actual.getPoolConf().getMaxObjects(), 0);
- assertEquals(10, actual.getPoolConf().getMaxIdle(), 0);
-
- Throwable t = null;
-
- // check update
- actual.getCapabilities().remove(ConnectorCapability.UPDATE);
- actual.getPoolConf().setMaxObjects(null);
-
- try {
- connectorService.update(actual);
- actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
- } catch (SyncopeClientException e) {
- LOG.error("update failed", e);
- t = e;
- }
-
- assertNull(t);
- assertNotNull(actual);
- assertEquals(EnumSet.of(ConnectorCapability.CREATE), actual.getCapabilities());
- assertEquals(10, actual.getPoolConf().getMaxObjects(), 0);
-
- // check also for the deletion of the created object
- try {
- connectorService.delete(actual.getKey());
- } catch (SyncopeClientException e) {
- LOG.error("delete failed", e);
- t = e;
- }
-
- assertNull(t);
-
- // check the non existence
- try {
- connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
- }
- }
-
- @Test
- public void update() {
- ConnInstanceTO connectorTO = new ConnInstanceTO();
-
- // set connector instance id
- connectorTO.setKey(103L);
-
- // set connector version
- connectorTO.setVersion(connidSoapVersion);
-
- // set connector name
- connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
-
- // set bundle name
- connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
-
- connectorTO.setConnRequestTimeout(20);
-
- // set the connector configuration using PropertyTO
- Set<ConnConfProperty> conf = new HashSet<>();
-
- ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
- endpointSchema.setName("endpoint");
- endpointSchema.setType(String.class.getName());
- endpointSchema.setRequired(true);
- ConnConfProperty endpoint = new ConnConfProperty();
- endpoint.setSchema(endpointSchema);
- endpoint.getValues().add("http://localhost:8888/wssample/services");
- conf.add(endpoint);
-
- ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
- servicenameSchema.setName("servicename");
- servicenameSchema.setType(String.class.getName());
- servicenameSchema.setRequired(true);
- ConnConfProperty servicename = new ConnConfProperty();
- servicename.setSchema(servicenameSchema);
- servicename.getValues().add("Provisioning");
- conf.add(servicename);
-
- // set connector configuration
- connectorTO.getConf().addAll(conf);
-
- connectorService.update(connectorTO);
- ConnInstanceTO actual = connectorService.read(connectorTO.getKey(), Locale.ENGLISH.getLanguage());
-
- assertNotNull(actual);
-
- actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
-
- assertNotNull(actual);
- assertEquals(actual.getBundleName(), connectorTO.getBundleName());
- assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
- assertEquals(actual.getVersion(), connectorTO.getVersion());
- assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
- }
-
- private List<ResourceTO> filter(final List<ResourceTO> input, final Long connectorKey) {
- List<ResourceTO> result = new ArrayList<>();
-
- for (ResourceTO resource : input) {
- if (connectorKey.equals(resource.getConnector())) {
- result.add(resource);
- }
- }
-
- return result;
- }
-
- @Test
- public void issueSYNCOPE10() {
- // ----------------------------------
- // Copy resource and connector in order to create new objects.
- // ----------------------------------
- // Retrieve a connector instance template.
- ConnInstanceTO connInstanceTO = connectorService.read(103L, Locale.ENGLISH.getLanguage());
- assertNotNull(connInstanceTO);
-
- // check for resource
- List<ResourceTO> resources = filter(resourceService.list(), 103L);
- assertEquals(4, resources.size());
-
- // Retrieve a resource TO template.
- ResourceTO resourceTO = resources.get(0);
-
- // Make it new.
- resourceTO.setKey("newAbout103" + getUUIDString());
-
- // Make it new.
- connInstanceTO.setKey(0L);
- connInstanceTO.setDisplayName("newDisplayName" + getUUIDString());
- // ----------------------------------
-
- // ----------------------------------
- // Create a new connector instance.
- // ----------------------------------
- Response response = connectorService.create(connInstanceTO);
- if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
- throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
- }
-
- connInstanceTO = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
- assertNotNull(connInstanceTO);
- assertFalse(connInstanceTO.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
-
- long connId = connInstanceTO.getKey();
-
- // Link resourceTO to the new connector instance.
- resourceTO.setConnector(connId);
- // ----------------------------------
-
- // ----------------------------------
- // Check for connector instance update after resource creation.
- // ----------------------------------
- response = resourceService.create(resourceTO);
- resourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
-
- assertNotNull(resourceTO);
-
- resources = filter(resourceService.list(), connId);
- assertEquals(1, resources.size());
- // ----------------------------------
-
- // ----------------------------------
- // Check for spring bean.
- // ----------------------------------
- ConnInstanceTO connInstanceBean = connectorService.readByResource(
- resourceTO.getKey(), Locale.ENGLISH.getLanguage());
- assertNotNull(connInstanceBean);
- assertFalse(connInstanceBean.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
- // ----------------------------------
-
- // ----------------------------------
- // Check for spring bean update after connector instance update.
- // ----------------------------------
- connInstanceTO.getCapabilities().add(ConnectorCapability.AUTHENTICATE);
-
- connectorService.update(connInstanceTO);
- ConnInstanceTO actual = connectorService.read(connInstanceTO.getKey(), Locale.ENGLISH.getLanguage());
- assertNotNull(actual);
- assertTrue(connInstanceTO.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
-
- // check for spring bean update
- connInstanceBean = connectorService.readByResource(resourceTO.getKey(), Locale.ENGLISH.getLanguage());
- assertTrue(connInstanceBean.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
- // ----------------------------------
- }
-
- @Test
- public void deleteWithException() {
- try {
- connectorService.delete(0L);
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
- }
- }
-
- @Test
- public void list() {
- List<ConnInstanceTO> connectorInstanceTOs = connectorService.list(null);
- assertNotNull(connectorInstanceTOs);
- assertFalse(connectorInstanceTOs.isEmpty());
- for (ConnInstanceTO instance : connectorInstanceTOs) {
- assertNotNull(instance);
- }
- }
-
- @Test
- public void read() {
- ConnInstanceTO connectorInstanceTO = connectorService.read(100L, Locale.ENGLISH.getLanguage());
- assertNotNull(connectorInstanceTO);
- }
-
- @Test
- public void getBundles() {
- List<ConnBundleTO> bundles = connectorService.getBundles(Locale.ENGLISH.getLanguage());
- assertNotNull(bundles);
- assertFalse(bundles.isEmpty());
- for (ConnBundleTO bundle : bundles) {
- assertNotNull(bundle);
- }
- }
-
- @Test
- public void getConnectorConfiguration() {
- Set<ConnConfProperty> props = connectorService.read(104L, Locale.ENGLISH.getLanguage()).getConf();
- assertNotNull(props);
- assertFalse(props.isEmpty());
- }
-
- @Test
- public void checkHiddenProperty() {
- ConnInstanceTO connInstanceTO = connectorService.read(100L, Locale.ENGLISH.getLanguage());
-
- boolean check = false;
-
- for (ConnConfProperty prop : connInstanceTO.getConf()) {
- if ("receiveTimeout".equals(prop.getSchema().getName())) {
- check = true;
- }
- }
- assertTrue(check);
- }
-
- @Test
- public void checkSelectedLanguage() {
- // 1. Check Italian
- List<ConnInstanceTO> connectorInstanceTOs = connectorService.list("it");
-
- Map<String, ConnConfProperty> instanceConfMap;
- for (ConnInstanceTO instance : connectorInstanceTOs) {
- if ("net.tirasa.connid.bundles.db.table".equals(instance.getBundleName())) {
- instanceConfMap = instance.getConfMap();
- assertEquals("Utente", instanceConfMap.get("user").getSchema().getDisplayName());
- }
- }
-
- // 2. Check English (default)
- connectorInstanceTOs = connectorService.list(null);
-
- for (ConnInstanceTO instance : connectorInstanceTOs) {
- if ("net.tirasa.connid.bundles.db.table".equals(instance.getBundleName())) {
- instanceConfMap = instance.getConfMap();
- assertEquals("User", instanceConfMap.get("user").getSchema().getDisplayName());
- }
- }
- }
-
- @Test
- public void validate() {
- ConnInstanceTO connectorTO = new ConnInstanceTO();
- connectorTO.setLocation(connectorServerLocation);
- connectorTO.setVersion(connidDbTableVersion);
- connectorTO.setConnectorName("net.tirasa.connid.bundles.db.table.DatabaseTableConnector");
- connectorTO.setBundleName("net.tirasa.connid.bundles.db.table");
- connectorTO.setDisplayName("H2Test");
-
- // set the connector configuration using PropertyTO
- Set<ConnConfProperty> conf = new HashSet<>();
-
- ConnConfPropSchema jdbcDriverSchema = new ConnConfPropSchema();
- jdbcDriverSchema.setName("jdbcDriver");
- jdbcDriverSchema.setType(String.class.getName());
- jdbcDriverSchema.setRequired(true);
- ConnConfProperty jdbcDriver = new ConnConfProperty();
- jdbcDriver.setSchema(jdbcDriverSchema);
- jdbcDriver.getValues().add("org.h2.Driver");
- conf.add(jdbcDriver);
-
- ConnConfPropSchema jdbcUrlTemplateSchema = new ConnConfPropSchema();
- jdbcUrlTemplateSchema.setName("jdbcUrlTemplate");
- jdbcUrlTemplateSchema.setType(String.class.getName());
- jdbcUrlTemplateSchema.setRequired(true);
- ConnConfProperty jdbcUrlTemplate = new ConnConfProperty();
- jdbcUrlTemplate.setSchema(jdbcUrlTemplateSchema);
- jdbcUrlTemplate.getValues().add(testJDBCURL);
- conf.add(jdbcUrlTemplate);
-
- ConnConfPropSchema userSchema = new ConnConfPropSchema();
- userSchema.setName("user");
- userSchema.setType(String.class.getName());
- userSchema.setRequired(false);
- ConnConfProperty user = new ConnConfProperty();
- user.setSchema(userSchema);
- user.getValues().add("sa");
- conf.add(user);
-
- ConnConfPropSchema passwordSchema = new ConnConfPropSchema();
- passwordSchema.setName("password");
- passwordSchema.setType(GuardedString.class.getName());
- passwordSchema.setRequired(true);
- ConnConfProperty password = new ConnConfProperty();
- password.setSchema(passwordSchema);
- password.getValues().add("sa");
- conf.add(password);
-
- ConnConfPropSchema tableSchema = new ConnConfPropSchema();
- tableSchema.setName("table");
- tableSchema.setType(String.class.getName());
- tableSchema.setRequired(true);
- ConnConfProperty table = new ConnConfProperty();
- table.setSchema(tableSchema);
- table.getValues().add("test");
- conf.add(table);
-
- ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
- keyColumnSchema.setName("keyColumn");
- keyColumnSchema.setType(String.class.getName());
- keyColumnSchema.setRequired(true);
- ConnConfProperty keyColumn = new ConnConfProperty();
- keyColumn.setSchema(keyColumnSchema);
- keyColumn.getValues().add("id");
- conf.add(keyColumn);
-
- ConnConfPropSchema passwordColumnSchema = new ConnConfPropSchema();
- passwordColumnSchema.setName("passwordColumn");
- passwordColumnSchema.setType(String.class.getName());
- passwordColumnSchema.setRequired(true);
- ConnConfProperty passwordColumn = new ConnConfProperty();
- passwordColumn.setSchema(passwordColumnSchema);
- passwordColumn.getValues().add("password");
- conf.add(passwordColumn);
-
- // set connector configuration
- connectorTO.getConf().addAll(conf);
-
- try {
- connectorService.check(connectorTO);
- } catch (Exception e) {
- fail(ExceptionUtils.getStackTrace(e));
- }
-
- conf.remove(password);
- password.getValues().clear();
- password.getValues().add("password");
- conf.add(password);
-
- try {
- connectorService.check(connectorTO);
- fail();
- } catch (Exception e) {
- assertNotNull(e);
- }
- }
-
- @Test
- public void buildObjectClassInfo() {
- ConnInstanceTO ws = connectorService.read(102L, Locale.ENGLISH.getLanguage());
- assertNotNull(ws);
-
- List<ConnIdObjectClassTO> objectClassInfo = connectorService.buildObjectClassInfo(ws, true);
- assertNotNull(objectClassInfo);
- assertEquals(1, objectClassInfo.size());
- assertEquals(ObjectClass.ACCOUNT_NAME, objectClassInfo.get(0).getType());
- assertTrue(objectClassInfo.get(0).getAttributes().contains("promoThirdPartyDisclaimer"));
-
- ConnInstanceTO ldap = connectorService.read(105L, Locale.ENGLISH.getLanguage());
- assertNotNull(ldap);
-
- objectClassInfo = connectorService.buildObjectClassInfo(ldap, true);
- assertNotNull(objectClassInfo);
- assertEquals(2, objectClassInfo.size());
-
- Collection<String> objectClasses = CollectionUtils.collect(objectClassInfo,
- new Transformer<ConnIdObjectClassTO, String>() {
-
- @Override
- public String transform(final ConnIdObjectClassTO info) {
- return info.getType();
- }
-
- });
- assertEquals(2, objectClasses.size());
- assertTrue(objectClasses.contains(ObjectClass.ACCOUNT_NAME));
- assertTrue(objectClasses.contains(ObjectClass.GROUP_NAME));
- }
-
- @Test
- public void issueSYNCOPE112() {
- // ----------------------------------------
- // Create a new connector
- // ----------------------------------------
- ConnInstanceTO connectorTO = new ConnInstanceTO();
-
- connectorTO.setLocation(connectorService.read(100L, Locale.ENGLISH.getLanguage()).getLocation());
-
- // set connector version
- connectorTO.setVersion(connidSoapVersion);
-
- // set connector name
- connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
-
- // set bundle name
- connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
-
- // set display name
- connectorTO.setDisplayName("WSSoap");
-
- // set the connector configuration using PropertyTO
- Set<ConnConfProperty> conf = new HashSet<>();
-
- ConnConfPropSchema userSchema = new ConnConfPropSchema();
- userSchema.setName("endpoint");
- userSchema.setType(String.class.getName());
- userSchema.setRequired(true);
- ConnConfProperty endpoint = new ConnConfProperty();
- endpoint.setSchema(userSchema);
- endpoint.getValues().add("http://localhost:9080/does_not_work");
- endpoint.setOverridable(true);
-
- ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
- keyColumnSchema.setName("servicename");
- keyColumnSchema.setType(String.class.getName());
- keyColumnSchema.setRequired(true);
- ConnConfProperty servicename = new ConnConfProperty();
- servicename.setSchema(keyColumnSchema);
- servicename.getValues().add("net.tirasa.connid.bundles.soap.provisioning.interfaces.Provisioning");
- servicename.setOverridable(false);
-
- conf.add(endpoint);
- conf.add(servicename);
-
- // set connector configuration
- connectorTO.getConf().addAll(conf);
-
- try {
- try {
- connectorService.check(connectorTO);
- fail();
- } catch (Exception e) {
- assertNotNull(e);
- }
-
- Response response = connectorService.create(connectorTO);
- if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
- throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
- }
-
- connectorTO = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
- assertNotNull(connectorTO);
- // ----------------------------------------
-
- // ----------------------------------------
- // create a resourceTO
- // ----------------------------------------
- String resourceName = "checkForPropOverriding";
- ResourceTO resourceTO = new ResourceTO();
-
- resourceTO.setKey(resourceName);
- resourceTO.setConnector(connectorTO.getKey());
-
- conf = new HashSet<>();
- endpoint.getValues().clear();
- endpoint.getValues().add("http://localhost:9080/wssample/services/provisioning");
- conf.add(endpoint);
-
- resourceTO.getConfOverride().addAll(conf);
-
- ProvisionTO provisionTO = new ProvisionTO();
- provisionTO.setAnyType(AnyTypeKind.USER.name());
- provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
- resourceTO.getProvisions().add(provisionTO);
-
- MappingTO mapping = new MappingTO();
- provisionTO.setMapping(mapping);
-
- MappingItemTO mapItem = new MappingItemTO();
- mapItem.setExtAttrName("uid");
- mapItem.setIntAttrName("userId");
- mapItem.setIntMappingType(IntMappingType.UserPlainSchema);
- mapItem.setConnObjectKey(true);
- mapping.setConnObjectKeyItem(mapItem);
- // ----------------------------------------
-
- // ----------------------------------------
- // Check connection without saving the resource ....
- // ----------------------------------------
- try {
- resourceService.check(resourceTO);
- } catch (Exception e) {
- fail(ExceptionUtils.getStackTrace(e));
- }
- // ----------------------------------------
- } finally {
- // Remove connector from db to make test re-runnable
- connectorService.delete(connectorTO.getKey());
- }
- }
-
- @Test
- public void reload() {
- connectorService.reload();
- }
-
- @Test
- public void bulkAction() {
- BulkAction bulkAction = new BulkAction();
- bulkAction.setType(BulkAction.Type.DELETE);
-
- ConnInstanceTO conn = connectorService.read(101L, Locale.ENGLISH.getLanguage());
-
- conn.setKey(0L);
- conn.setDisplayName("forBulk1");
-
- bulkAction.getTargets().add(String.valueOf(getObject(
- connectorService.create(conn).getLocation(), ConnectorService.class, ConnInstanceTO.class).getKey()));
-
- conn.setDisplayName("forBulk2");
-
- bulkAction.getTargets().add(String.valueOf(getObject(
- connectorService.create(conn).getLocation(), ConnectorService.class, ConnInstanceTO.class).getKey()));
-
- Iterator<String> iter = bulkAction.getTargets().iterator();
-
- assertNotNull(connectorService.read(Long.valueOf(iter.next()), Locale.ENGLISH.getLanguage()));
- assertNotNull(connectorService.read(Long.valueOf(iter.next()), Locale.ENGLISH.getLanguage()));
-
- connectorService.bulk(bulkAction);
-
- iter = bulkAction.getTargets().iterator();
-
- try {
- connectorService.read(Long.valueOf(iter.next()), Locale.ENGLISH.getLanguage());
- fail();
- } catch (SyncopeClientException e) {
- assertNotNull(e);
- }
-
- try {
- connectorService.read(Long.valueOf(iter.next()), Locale.ENGLISH.getLanguage());
- fail();
- } catch (SyncopeClientException e) {
- assertNotNull(e);
- }
- }
-
- @Test
- public void issueSYNCOPE605() {
- ConnInstanceTO connectorInstanceTO = connectorService.read(103L, Locale.ENGLISH.getLanguage());
- assertTrue(connectorInstanceTO.getCapabilities().isEmpty());
-
- connectorInstanceTO.getCapabilities().add(ConnectorCapability.SEARCH);
- connectorService.update(connectorInstanceTO);
-
- ConnInstanceTO updatedCapabilities = connectorService.read(
- connectorInstanceTO.getKey(), Locale.ENGLISH.getLanguage());
- assertNotNull(updatedCapabilities.getCapabilities());
- assertTrue(updatedCapabilities.getCapabilities().size() == 1);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
deleted file mode 100644
index 6221f45..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DerSchemaITCase.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import javax.ws.rs.core.Response;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.DerSchemaTO;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.apache.syncope.common.lib.types.EntityViolationType;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.syncope.common.rest.api.beans.SchemaQuery;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class DerSchemaITCase extends AbstractITCase {
-
- @Test
- public void list() {
- List<DerSchemaTO> derSchemas = schemaService.list(new SchemaQuery.Builder().type(SchemaType.DERIVED).build());
- assertFalse(derSchemas.isEmpty());
- for (DerSchemaTO derivedSchemaTO : derSchemas) {
- assertNotNull(derivedSchemaTO);
- }
- }
-
- @Test
- public void read() {
- DerSchemaTO derivedSchemaTO = schemaService.read(SchemaType.DERIVED, "cn");
- assertNotNull(derivedSchemaTO);
- }
-
- @Test
- public void create() {
- DerSchemaTO schema = new DerSchemaTO();
- schema.setKey("derived");
- schema.setExpression("derived_sx + '_' + derived_dx");
-
- DerSchemaTO actual = createSchema(SchemaType.DERIVED, schema);
- assertNotNull(actual);
-
- actual = schemaService.read(SchemaType.DERIVED, actual.getKey());
- assertNotNull(actual);
- assertEquals(actual.getExpression(), "derived_sx + '_' + derived_dx");
- }
-
- @Test
- public void delete() {
- DerSchemaTO schema = schemaService.read(SchemaType.DERIVED, "rderiveddata");
- assertNotNull(schema);
-
- schemaService.delete(SchemaType.DERIVED, schema.getKey());
-
- try {
- schemaService.read(SchemaType.DERIVED, "rderiveddata");
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.NotFound, e.getType());
- } finally {
- // Recreate schema to make test re-runnable
- schema = createSchema(SchemaType.DERIVED, schema);
- assertNotNull(schema);
- }
- }
-
- @Test
- public void update() {
- DerSchemaTO schema = schemaService.read(SchemaType.DERIVED, "mderiveddata");
- assertNotNull(schema);
- assertEquals("mderived_sx + '-' + mderived_dx", schema.getExpression());
- try {
- schema.setExpression("mderived_sx + '.' + mderived_dx");
-
- schemaService.update(SchemaType.DERIVED, schema);
-
- schema = schemaService.read(SchemaType.DERIVED, "mderiveddata");
- assertNotNull(schema);
- assertEquals("mderived_sx + '.' + mderived_dx", schema.getExpression());
- } finally {
- // Set updated back to make test re-runnable
- schema.setExpression("mderived_sx + '-' + mderived_dx");
- schemaService.update(SchemaType.DERIVED, schema);
- }
- }
-
- @Test
- public void issueSYNCOPE323() {
- DerSchemaTO actual = schemaService.read(SchemaType.DERIVED, "rderiveddata");
- assertNotNull(actual);
-
- try {
- createSchema(SchemaType.DERIVED, actual);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus());
- assertEquals(ClientExceptionType.EntityExists, e.getType());
- }
-
- actual.setKey(null);
- try {
- createSchema(SchemaType.DERIVED, actual);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus());
- assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
- }
- }
-
- @Test
- public void issueSYNCOPE418() {
- DerSchemaTO schema = new DerSchemaTO();
- schema.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
- schema.setExpression("derived_sx + '_' + derived_dx");
-
- try {
- createSchema(SchemaType.DERIVED, schema);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.InvalidDerSchema, e.getType());
- assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
deleted file mode 100644
index 728379a..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/DomainITCase.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.security.AccessControlException;
-import java.util.List;
-import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
-import org.apache.syncope.common.lib.SyncopeClientException;
-import org.apache.syncope.common.lib.to.DomainTO;
-import org.apache.syncope.common.lib.types.CipherAlgorithm;
-import org.apache.syncope.common.lib.types.ClientExceptionType;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class DomainITCase extends AbstractITCase {
-
- @Test
- public void list() {
- List<DomainTO> domains = domainService.list();
- assertNotNull(domains);
- assertFalse(domains.isEmpty());
- for (DomainTO domain : domains) {
- assertNotNull(domain);
- }
- }
-
- @Test
- public void create() {
- DomainTO domain = new DomainTO();
- domain.setKey("last");
- domain.setAdminCipherAlgorithm(CipherAlgorithm.SSHA512);
- domain.setAdminPwd("password");
-
- try {
- domainService.create(domain);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.NotFound, e.getType());
- }
- }
-
- private void restoreTwo() {
- DomainTO two = new DomainTO();
- two.setKey("Two");
- two.setAdminCipherAlgorithm(CipherAlgorithm.SHA);
- two.setAdminPwd("password2");
- domainService.create(two);
- }
-
- @Test
- public void update() {
- DomainTO two = domainService.read("Two");
- assertNotNull(two);
-
- try {
- // 1. change admin pwd for domain Two
- two.setAdminCipherAlgorithm(CipherAlgorithm.AES);
- two.setAdminPwd("password3");
- domainService.update(two);
-
- // 2. attempt to access with old pwd -> fail
- try {
- new SyncopeClientFactoryBean().
- setAddress(ADDRESS).setDomain("Two").setContentType(clientFactory.getContentType()).
- create(ADMIN_UNAME, "password2").self();
- } catch (AccessControlException e) {
- assertNotNull(e);
- }
-
- // 3. access with new pwd -> succeed
- new SyncopeClientFactoryBean().
- setAddress(ADDRESS).setDomain("Two").setContentType(clientFactory.getContentType()).
- create(ADMIN_UNAME, "password3").self();
- } finally {
- restoreTwo();
- }
- }
-
- @Test
- public void delete() {
- DomainTO two = domainService.read("Two");
- assertNotNull(two);
-
- try {
- domainService.delete(two.getKey());
-
- try {
- domainService.read(two.getKey());
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.NotFound, e.getType());
- }
- } finally {
- restoreTwo();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/17d5d892/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
deleted file mode 100644
index 2679196..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core.reference;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-import org.apache.commons.io.IOUtils;
-import org.apache.syncope.common.lib.SyncopeClientCompositeException;
-import org.apache.syncope.common.lib.SyncopeConstants;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runners.MethodSorters;
-
-@FixMethodOrder(MethodSorters.JVM)
-public class ExceptionMapperITCase extends AbstractITCase {
-
- private static final Properties ERROR_MESSAGES = new Properties();
-
- @BeforeClass
- public static void setUpErrorMessages() throws IOException {
- InputStream propStream = null;
- try {
- propStream = ExceptionMapperITCase.class.getResourceAsStream("/errorMessages.properties");
- ERROR_MESSAGES.load(propStream);
- } catch (Exception e) {
- LOG.error("Could not load /errorMessages.properties", e);
- } finally {
- IOUtils.closeQuietly(propStream);
- }
- }
-
- @Test
- public void uniqueSchemaConstraint() {
- // 1. create an user schema with unique constraint
- PlainSchemaTO schemaTO = new PlainSchemaTO();
- String schemaUID = getUUIDString();
- schemaTO.setKey("unique" + schemaUID);
- schemaTO.setType(AttrSchemaType.String);
- schemaTO.setUniqueConstraint(true);
- createSchema(SchemaType.PLAIN, schemaTO);
-
- AnyTypeClassTO typeClass = new AnyTypeClassTO();
- typeClass.setKey("camelAttribute" + getUUIDString());
- typeClass.getPlainSchemas().add(schemaTO.getKey());
- anyTypeClassService.create(typeClass);
-
- // 2. create an user with mandatory attributes and unique
- UserTO userTO1 = new UserTO();
- userTO1.setRealm(SyncopeConstants.ROOT_REALM);
- userTO1.getAuxClasses().add(typeClass.getKey());
- String userId1 = getUUIDString() + "issue654_1@syncope.apache.org";
- userTO1.setUsername(userId1);
- userTO1.setPassword("password123");
-
- userTO1.getPlainAttrs().add(attrTO("userId", userId1));
- userTO1.getPlainAttrs().add(attrTO("fullname", userId1));
- userTO1.getPlainAttrs().add(attrTO("surname", userId1));
- userTO1.getPlainAttrs().add(attrTO("unique" + schemaUID, "unique" + schemaUID));
-
- createUser(userTO1);
-
- // 3. create an other user with mandatory attributes and unique with the same value of userTO1
- UserTO userTO2 = new UserTO();
- userTO2.setRealm(SyncopeConstants.ROOT_REALM);
- userTO2.getAuxClasses().add(typeClass.getKey());
- String userId2 = getUUIDString() + "issue654_2@syncope.apache.org";
- userTO2.setUsername(userId2);
- userTO2.setPassword("password123");
-
- userTO2.getPlainAttrs().add(attrTO("userId", userId2));
- userTO2.getPlainAttrs().add(attrTO("fullname", userId2));
- userTO2.getPlainAttrs().add(attrTO("surname", userId2));
- userTO2.getPlainAttrs().add(attrTO("unique" + schemaUID, "unique" + schemaUID));
-
- try {
- createUser(userTO2);
- fail();
- } catch (Exception e) {
- String message = ERROR_MESSAGES.getProperty("errMessage.UniqueConstraintViolation");
- assertEquals("EntityExists [" + message + "]", e.getMessage());
- }
- }
-
- @Test
- public void sameGroupName() {
- String groupUUID = getUUIDString();
-
- // Create the first group
- GroupTO groupTO1 = new GroupTO();
- groupTO1.setName("child1" + groupUUID);
- groupTO1.setRealm(SyncopeConstants.ROOT_REALM);
- createGroup(groupTO1);
-
- // Create the second group, with the same name of groupTO1
- GroupTO groupTO2 = new GroupTO();
- groupTO2.setName("child1" + groupUUID);
- groupTO2.setRealm(SyncopeConstants.ROOT_REALM);
- try {
- createGroup(groupTO2);
- fail();
- } catch (Exception e) {
- String message = ERROR_MESSAGES.getProperty("errMessage.UniqueConstraintViolation");
- assertEquals(e.getMessage(), "DataIntegrityViolation [" + message + "]");
- }
- }
-
- @Test
- public void headersMultiValue() {
- UserTO userTO = new UserTO();
- userTO.setRealm(SyncopeConstants.ROOT_REALM);
- String userId = getUUIDString() + "issue654@syncope.apache.org";
- userTO.setUsername(userId);
- userTO.setPassword("password123");
-
- userTO.getPlainAttrs().add(attrTO("userId", "issue654"));
- userTO.getPlainAttrs().add(attrTO("fullname", userId));
- userTO.getPlainAttrs().add(attrTO("surname", userId));
-
- try {
- createUser(userTO);
- fail();
- } catch (SyncopeClientCompositeException e) {
- assertEquals(2, e.getExceptions().size());
- }
- }
-}