Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 81E4017D4E for ; Fri, 23 Jan 2015 16:41:23 +0000 (UTC) Received: (qmail 23573 invoked by uid 500); 23 Jan 2015 16:41:23 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 23534 invoked by uid 500); 23 Jan 2015 16:41:23 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 23519 invoked by uid 99); 23 Jan 2015 16:41:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jan 2015 16:41:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 768ABE0393; Fri, 23 Jan 2015 16:41:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: ilgrosso@apache.org To: commits@syncope.apache.org Date: Fri, 23 Jan 2015 16:41:23 -0000 Message-Id: <6d41d270a10c4c5abe1407b34b5bcf47@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/15] syncope git commit: [SYNCOPE-629] Format + safely delete role Repository: syncope Updated Branches: refs/heads/2_0_X 8e45a8e67 -> 4e1ae7ac9 [SYNCOPE-629] Format + safely delete role Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/4efca7c3 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/4efca7c3 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/4efca7c3 Branch: refs/heads/2_0_X Commit: 4efca7c3ec3973ab4b774a1f43e4403daf3354b7 Parents: f2d45fd Author: Francesco Chicchiriccò Authored: Wed Jan 21 06:54:34 2015 +0100 Committer: Francesco Chicchiriccò Committed: Wed Jan 21 06:54:34 2015 +0100 ---------------------------------------------------------------------- .../core/rest/ConfigurationTestITCase.java | 79 +++++++++++--------- 1 file changed, 42 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/4efca7c3/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java b/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java index cbe13d5..1f981ac 100644 --- a/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java +++ b/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java @@ -151,22 +151,22 @@ public class ConfigurationTestITCase extends AbstractTest { assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name())); } } - + @Test - public void issueSYNCOPE629() throws IOException{ + public void issueSYNCOPE629() throws IOException { SchemaTO membershipKey = new SchemaTO(); - membershipKey.setName("membershipKey"+getUUIDString()); + membershipKey.setName("membershipKey" + getUUIDString()); membershipKey.setType(AttributeSchemaType.String); createSchema(AttributableType.MEMBERSHIP, SchemaType.NORMAL, membershipKey); - + SchemaTO roleKey = new SchemaTO(); - roleKey.setName("roleKey"+getUUIDString()); + roleKey.setName("roleKey" + getUUIDString()); roleKey.setType(AttributeSchemaType.String); - createSchema(AttributableType.ROLE, SchemaType.NORMAL, roleKey); - + createSchema(AttributableType.ROLE, SchemaType.NORMAL, roleKey); + RoleTO roleTO = new RoleTO(); roleTO.setName("aRole" + getUUIDString()); - roleTO.setParent(8L); + roleTO.setParent(8L); // verify inheritance password and account policies roleTO.setInheritAccountPolicy(false); // not inherited so setter execution shouldn't be ignored @@ -176,39 +176,44 @@ public class ConfigurationTestITCase extends AbstractTest { roleTO.setPasswordPolicy(2L); roleTO.getRAttrTemplates().add("icon"); roleTO.getAttrs().add(attributeTO("icon", "anIcon")); - roleTO.getResources().add(RESOURCE_NAME_LDAP); + roleTO.getResources().add(RESOURCE_NAME_LDAP); roleTO.getMAttrTemplates().add(membershipKey.getName()); roleTO.getRAttrTemplates().add(roleKey.getName()); RoleTO testRole = createRole(roleTO); - - 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); - - String[] result = StringUtils.substringsBetween(configExport, ""); - boolean rattrExists = false; - for(String entry : result){ - if(entry.contains(roleKey.getName())) rattrExists = true; - } - assertTrue(rattrExists); - - result = StringUtils.substringsBetween(configExport, ""); - boolean mattrExists = false; - for(String entry : result){ - if(entry.contains(membershipKey.getName())) mattrExists = true; + try { + 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); + + String[] result = StringUtils.substringsBetween(configExport, ""); + boolean rattrExists = false; + for (String entry : result) { + if (entry.contains(roleKey.getName())) { + rattrExists = true; + } + } + assertTrue(rattrExists); + + result = StringUtils.substringsBetween(configExport, ""); + boolean mattrExists = false; + for (String entry : result) { + if (entry.contains(membershipKey.getName())) { + mattrExists = true; + } + } + assertTrue(mattrExists); + } finally { + deleteRole(testRole.getId()); } - assertTrue(mattrExists); - - deleteRole(testRole.getId()); - } }