tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-1889 ensuring complex uri work with basic auth for openejb-client http connection
Date Wed, 05 Oct 2016 21:24:09 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 2493f404f -> 446c57843


TOMEE-1889 ensuring complex uri work with basic auth for openejb-client http connection


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/446c5784
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/446c5784
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/446c5784

Branch: refs/heads/master
Commit: 446c5784300da33266be0bc79afb2b883c87d5d5
Parents: 2493f40
Author: rmannibucau <rmannibucau@apache.org>
Authored: Wed Oct 5 23:24:01 2016 +0200
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Wed Oct 5 23:24:01 2016 +0200

----------------------------------------------------------------------
 .../client/FailoverConnectionFactory.java       |  4 +--
 .../openejb/client/HttpConnectionTest.java      | 31 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/446c5784/server/openejb-client/src/main/java/org/apache/openejb/client/FailoverConnectionFactory.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/main/java/org/apache/openejb/client/FailoverConnectionFactory.java
b/server/openejb-client/src/main/java/org/apache/openejb/client/FailoverConnectionFactory.java
index 22fd8a9..47c8ff5 100644
--- a/server/openejb-client/src/main/java/org/apache/openejb/client/FailoverConnectionFactory.java
+++ b/server/openejb-client/src/main/java/org/apache/openejb/client/FailoverConnectionFactory.java
@@ -57,12 +57,12 @@ public class FailoverConnectionFactory implements ConnectionFactory {
         // failover:sticky:ejbd://foo:4201,ejbd://bar:4202
 
         // trim off the "failover:"
-        final String remainder = failoverUri.getSchemeSpecificPart();
+        final String remainder = failoverUri.getRawSchemeSpecificPart();
 
         final URI uri = URI.create(remainder);
 
         String strategy = uri.getScheme();
-        String servers = uri.getSchemeSpecificPart();
+        String servers = uri.getRawSchemeSpecificPart();
 
         if (servers.startsWith("//")) {
             strategy = "default";

http://git-wip-us.apache.org/repos/asf/tomee/blob/446c5784/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
b/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
index 565ce56..a37d8d3 100644
--- a/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
+++ b/server/openejb-client/src/test/java/org/apache/openejb/client/HttpConnectionTest.java
@@ -32,6 +32,8 @@ import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import static org.junit.Assert.fail;
+
 public class HttpConnectionTest {
     private HttpServer server;
 
@@ -124,4 +126,33 @@ public class HttpConnectionTest {
             Assert.assertTrue("should contain", sb.toString().contains("secure pageBasic
token"));
         }
     }
+
+    @Test
+    public void complexURIAuthorization() throws IOException, URISyntaxException {
+        final String baseHttp = "http://localhost:" + server.getAddress().getPort() + "/e?authorization=";
+        final String uri = "failover:sticky+random:" + baseHttp + "Basic%20ABCD&" + baseHttp
+ "Basic%20EFG";
+        final Connection connection = ConnectionManager.getConnection(new URI(uri));
+        BufferedReader br = null;
+        final StringBuilder sb = new StringBuilder();
+        String line;
+        try {
+            br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            while ((line = br.readLine()) != null) {
+                sb.append(line);
+            }
+        } catch (final IOException e) {
+            fail(e.getMessage());
+        } finally {
+            if (br != null) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            connection.close();
+        }
+        final String out = sb.toString();
+        Assert.assertTrue(out, out.contains("secure pageBasic ABCD"));
+    }
 }


Mime
View raw message