This is an automated email from the ASF dual-hosted git repository. jbonofre pushed a commit to branch karaf-4.1.x in repository https://gitbox.apache.org/repos/asf/karaf.git
commit bb5a525ecd63c81f7906e5eb2a138659066ceccb Author: Jean-Baptiste Onofré <[email protected]> AuthorDate: Sun Dec 10 06:55:56 2017 +0100 [KARAF-5418] Fix LDAPPubkeyLoginModuleTest --- .../modules/ldap/LDAPPubkeyLoginModuleTest.java | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LDAPPubkeyLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LDAPPubkeyLoginModuleTest.java index b5a1d40..fdaddb6 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LDAPPubkeyLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LDAPPubkeyLoginModuleTest.java @@ -7,8 +7,14 @@ package org.apache.karaf.jaas.modules.ldap; import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.security.Principal; +import java.util.Collection; +import java.util.List; +import java.util.function.Function; import javax.security.auth.Subject; import javax.security.auth.login.LoginException; import org.apache.directory.server.annotations.CreateLdapServer; @@ -17,16 +23,15 @@ import org.apache.directory.server.core.annotations.ApplyLdifFiles; import org.apache.directory.server.core.annotations.CreateDS; import org.apache.directory.server.core.annotations.CreatePartition; import org.apache.directory.server.core.integ.AbstractLdapTestUnit; -import static org.apache.directory.server.core.integ.AbstractLdapTestUnit.getLdapServer; import org.apache.directory.server.core.integ.FrameworkRunner; import org.apache.felix.utils.properties.Properties; import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; import org.apache.karaf.jaas.modules.NamePubkeyCallbackHandler; -import static org.apache.karaf.jaas.modules.PrincipalHelper.names; -import static org.apache.karaf.jaas.modules.ldap.LdapPropsUpdater.ldapProps; import org.apache.log4j.Level; import org.hamcrest.Matchers; + +import static java.util.stream.Collectors.toList; import static org.hamcrest.Matchers.containsInAnyOrder; import org.junit.After; import static org.junit.Assert.assertEquals; @@ -158,4 +163,21 @@ public class LDAPPubkeyLoginModuleTest extends AbstractLdapTestUnit { return new Properties(file); } + private static void ldapProps(String propsPath, Function<String, String> mapFunction) throws IOException { + String basedir = System.getProperty("basedir"); + if (basedir == null) { + basedir = new File(".").getCanonicalPath(); + } + Path inPath = new File(basedir + "/src/test/resources/" + propsPath).toPath(); + List<String> lines = Files.lines(inPath, Charset.forName("UTF-8")) + .map(mapFunction) + .collect(toList()); + Path outPath = new File(basedir + "/target/test-classes/" + propsPath).toPath(); + Files.write(outPath, lines, Charset.forName("UTF-8")); + } + + public static List<String> names(Collection<? extends Principal> principals) { + return principals.stream().map(r->r.getName()).collect(toList()); + } + } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
