You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/07/03 14:01:35 UTC
cxf-fediz git commit: Fixing system test to always send Basic Auth
creds to the token endpoint
Repository: cxf-fediz
Updated Branches:
refs/heads/master c059ba8bf -> 245c592d7
Fixing system test to always send Basic Auth creds to the token endpoint
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/245c592d
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/245c592d
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/245c592d
Branch: refs/heads/master
Commit: 245c592d728db3d88d7d5a6d078e141609348342
Parents: c059ba8
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Mon Jul 3 15:01:16 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Mon Jul 3 15:01:16 2017 +0100
----------------------------------------------------------------------
.../org/apache/cxf/fediz/systests/oidc/OIDCTest.java | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/245c592d/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
----------------------------------------------------------------------
diff --git a/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java b/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
index d7dceb0..241e1b6 100644
--- a/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
+++ b/systests/oidc/src/test/java/org/apache/cxf/fediz/systests/oidc/OIDCTest.java
@@ -25,6 +25,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@@ -62,6 +63,7 @@ import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.cxf.fediz.tomcat8.FederationAuthenticator;
import org.apache.cxf.rs.security.jose.jwa.SignatureAlgorithm;
@@ -88,6 +90,7 @@ public class OIDCTest {
private static String storedClientId;
private static String storedClient2Id;
+ private static String storedClientPassword;
@BeforeClass
public static void init() throws Exception {
@@ -240,6 +243,11 @@ public class OIDCTest {
storedClientId = table.getCellAt(1, 1).asText().trim();
Assert.assertNotNull(storedClientId);
+ // Get the password
+ registeredClientPage = webClient.getPage(url + "/" + storedClientId);
+ table = registeredClientPage.getHtmlElementById("client");
+ storedClientPassword = table.getCellAt(1, 2).asText().trim();
+
// Try to register another new client
registeredClientPage =
registerNewClient(webClient, url, "new-client2", "https://127.0.1.1",
@@ -812,6 +820,9 @@ public class OIDCTest {
// Now use the code to get an IdToken
WebClient webClient2 = setupWebClient(user, password, getIdpHttpsPort());
+ String data = storedClientId + ":" + storedClientPassword;
+ String authorizationHeader = "Basic " + Base64.encodeBase64String(data.getBytes(StandardCharsets.UTF_8));
+ webClient2.addRequestHeader("Authorization", authorizationHeader);
String tokenUrl = "https://localhost:" + getRpHttpsPort() + "/fediz-oidc/oauth2/token";
WebRequest request = new WebRequest(new URL(tokenUrl), HttpMethod.POST);