diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2017-01-26 01:03:16 +0100 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2017-02-19 20:04:40 -0400 |
commit | 5e8e2179b218ede7d14b69dc5149b0691b5859cf (patch) | |
tree | b8519d77c5371a582f2c434a9ec83676fa9bfc77 /org.eclipse.jgit.junit.http | |
parent | 0a4cf573d345e9509b689af141f4dbfa1f63dc3b (diff) | |
download | jgit-5e8e2179b218ede7d14b69dc5149b0691b5859cf.tar.gz jgit-5e8e2179b218ede7d14b69dc5149b0691b5859cf.zip |
Update Jetty to 9.4.1.v20170120
MappedLoginService is no longer available in Jetty 9.4 therefore base
TestLoginService on AbstractLoginService.
Apparently Jetty now uses slf4j hence adapt RecordingLogger accordingly
so we can log error messages containing slf4j style formatting anchors
"{}".
Change-Id: Ibb36aba8782882936849b6102001a88b699bb65c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit.http')
4 files changed, 23 insertions, 21 deletions
diff --git a/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF b/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF index 9a0a6c8dd5..09ecf91a8c 100644 --- a/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF @@ -28,7 +28,8 @@ Import-Package: javax.servlet;version="[2.5.0,3.2.0)", org.eclipse.jgit.revwalk;version="[4.7.0,4.8.0)", org.eclipse.jgit.transport;version="[4.7.0,4.8.0)", org.eclipse.jgit.transport.resolver;version="[4.7.0,4.8.0)", - org.junit;version="[4.0.0,5.0.0)" + org.junit;version="[4.0.0,5.0.0)", + org.slf4j.helpers;version="[1.7.2,2.0.0)" Export-Package: org.eclipse.jgit.junit.http;version="4.7.0"; uses:="org.eclipse.jgit.transport, org.eclipse.jgit.junit, diff --git a/org.eclipse.jgit.junit.http/pom.xml b/org.eclipse.jgit.junit.http/pom.xml index 6a9464498b..abfe04380f 100644 --- a/org.eclipse.jgit.junit.http/pom.xml +++ b/org.eclipse.jgit.junit.http/pom.xml @@ -93,6 +93,11 @@ <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-servlet</artifactId> </dependency> + + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-security</artifactId> + </dependency> </dependencies> <build> diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java index 44c1977171..09754317ed 100644 --- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java +++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/AppServer.java @@ -46,7 +46,6 @@ package org.eclipse.jgit.junit.http; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.io.IOException; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; @@ -54,21 +53,21 @@ import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; +import org.eclipse.jetty.security.AbstractLoginService; import org.eclipse.jetty.security.Authenticator; import org.eclipse.jetty.security.ConstraintMapping; import org.eclipse.jetty.security.ConstraintSecurityHandler; -import org.eclipse.jetty.security.MappedLoginService; import org.eclipse.jetty.security.authentication.BasicAuthenticator; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.UserIdentity; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.security.Constraint; -import org.eclipse.jetty.util.security.Password; +import org.eclipse.jetty.util.security.Credential; +import org.eclipse.jetty.util.security.Credential.Crypt; import org.eclipse.jgit.transport.URIish; /** @@ -168,36 +167,30 @@ public class AppServer { return ctx; } - static class TestMappedLoginService extends MappedLoginService { + static class TestLoginService extends AbstractLoginService { + private String role; - TestMappedLoginService(String role) { + TestLoginService(String role) { this.role = role; } - @Override - protected UserIdentity loadUser(String who) { - return null; + protected String[] loadRoleInfo(UserPrincipal user) { + return new String[] { role }; } @Override - protected void loadUsers() throws IOException { - putUser(username, new Password(password), new String[] { role }); + protected UserPrincipal loadUserInfo(String name) { + return new UserPrincipal(username, + Credential.getCredential(Crypt.crypt(username, password))); } - protected String[] loadRoleInfo(KnownUser user) { - return null; - } - - protected KnownUser loadUserInfo(String usrname) { - return null; - } } private void auth(ServletContextHandler ctx, Authenticator authType) { final String role = "can-access"; - MappedLoginService users = new TestMappedLoginService(role); + TestLoginService users = new TestLoginService(role); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(new Constraint()); cm.getConstraint().setAuthenticate(true); @@ -237,6 +230,7 @@ public class AppServer { public void tearDown() throws Exception { RecordingLogger.clear(); log.clear(); + server.setStopTimeout(0); server.stop(); } diff --git a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java index 7600843d23..c7545a94b4 100644 --- a/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java +++ b/org.eclipse.jgit.junit.http/src/org/eclipse/jgit/junit/http/RecordingLogger.java @@ -49,6 +49,7 @@ import java.util.Collections; import java.util.List; import org.eclipse.jetty.util.log.Logger; +import org.slf4j.helpers.MessageFormatter; /** Logs warnings into an array for later inspection. */ public class RecordingLogger implements Logger { @@ -154,7 +155,8 @@ public class RecordingLogger implements Logger { public void warn(String msg, Object... args) { synchronized (warnings) { - warnings.add(new Warning(MessageFormat.format(msg, args))); + warnings.add(new Warning( + MessageFormatter.format(msg, args).getMessage())); } } |