[cxf] branch master updated: cxf-services-sts-systests-basic: consolidate checks (2)

2019-09-27 Thread buhhunyx
This is an automated email from the ASF dual-hosted git repository.

buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
 new c9a2275  cxf-services-sts-systests-basic: consolidate checks (2)
c9a2275 is described below

commit c9a2275276c6f8099585519372c24fda1cd7c3e0
Author: Alexey Markevich 
AuthorDate: Fri Sep 27 13:36:54 2019 +0300

cxf-services-sts-systests-basic: consolidate checks (2)
---
 .../apache/cxf/systest/sts/rest/STSRESTTest.java   | 195 +++--
 1 file changed, 64 insertions(+), 131 deletions(-)

diff --git 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
index cf1ed67..0ff15f1 100644
--- 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
+++ 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.security.KeyStore;
-import java.security.cert.Certificate;
 import java.security.cert.X509Certificate;
 import java.util.List;
 
@@ -59,6 +58,7 @@ import 
org.apache.cxf.ws.security.sts.provider.model.RequestedSecurityTokenType;
 import org.apache.cxf.ws.security.sts.provider.model.StatusType;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.crypto.CryptoFactory;
+import org.apache.wss4j.common.crypto.CryptoType;
 import org.apache.wss4j.common.saml.OpenSAMLUtil;
 import org.apache.wss4j.common.saml.SAMLKeyInfo;
 import org.apache.wss4j.common.saml.SamlAssertionWrapper;
@@ -92,6 +92,7 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 "https://localhost:8081/doubleit/services/doubleittransportsaml1";;
 
 private static TLSClientParameters tlsClientParameters = new 
TLSClientParameters();
+private static Crypto serviceCrypto;
 
 private WebClient webClient;
 
@@ -105,12 +106,16 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 );
 
 tlsClientParameters = getTLSClientParameters();
+serviceCrypto = 
CryptoFactory.getInstance("serviceKeystore.properties");
 }
 
 @org.junit.AfterClass
 public static void cleanup() throws Exception {
 SecurityTestUtil.cleanup();
 stopAllServers();
+
+tlsClientParameters = null;
+serviceCrypto = null;
 }
 
 @org.junit.After
@@ -127,10 +132,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 .accept(MediaType.APPLICATION_XML);
 
 Document assertionDoc = client.get(Document.class);
-assertNotNull(assertionDoc);
 
-// Process the token
-SamlAssertionWrapper assertion = processToken(assertionDoc);
+SamlAssertionWrapper assertion = validateSAMLToken(assertionDoc);
 assertTrue(assertion.getSaml2() != null && assertion.getSaml1() == 
null);
 }
 
@@ -141,10 +144,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 .accept(MediaType.APPLICATION_XML);
 
 Document assertionDoc = client.get(Document.class);
-assertNotNull(assertionDoc);
 
-// Process the token
-SamlAssertionWrapper assertion = processToken(assertionDoc);
+SamlAssertionWrapper assertion = validateSAMLToken(assertionDoc);
 assertTrue(assertion.getSaml2() == null && assertion.getSaml1() != 
null);
 }
 
@@ -156,10 +157,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 .accept(MediaType.APPLICATION_XML);
 
 Document assertionDoc = client.get(Document.class);
-assertNotNull(assertionDoc);
 
-// Process the token
-SamlAssertionWrapper assertion = processToken(assertionDoc);
+SamlAssertionWrapper assertion = validateSAMLToken(assertionDoc);
 assertTrue(assertion.getSaml2() == null && assertion.getSaml1() != 
null);
 
 List methods = assertion.getConfirmationMethods();
@@ -180,10 +179,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 .accept(MediaType.APPLICATION_XML);
 
 Document assertionDoc = client.get(Document.class);
-assertNotNull(assertionDoc);
 
-// Process the token
-SamlAssertionWrapper assertion = processToken(assertionDoc);
+SamlAssertionWrapper assertion = validateSAMLToken(assertionDoc);
 assertTrue(assertion.getSaml2() == null && assertion.getSaml1() != 
null);
 
 List methods = assertion.getConfirmationMethods();
@@ -204,10 +201,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 .accept(MediaType.APPLICATION_XML);
 
 Document assertionDoc = client.get(Document.cla

[cxf] branch master updated: cxf-services-sts-systests-basic: consolidate checks

2019-09-25 Thread buhhunyx
This is an automated email from the ASF dual-hosted git repository.

buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
 new 11de1e0  cxf-services-sts-systests-basic: consolidate checks
11de1e0 is described below

commit 11de1e0dfff9a8f9b157e23983c8e25f8503f868
Author: Alexey Markevich 
AuthorDate: Wed Sep 25 13:22:00 2019 +0300

cxf-services-sts-systests-basic: consolidate checks
---
 .../apache/cxf/systest/sts/rest/STSRESTTest.java   | 226 ++---
 1 file changed, 65 insertions(+), 161 deletions(-)

diff --git 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
index dc68013..cf1ed67 100644
--- 
a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
+++ 
b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/rest/STSRESTTest.java
@@ -122,8 +122,7 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 
 @org.junit.Test
 public void testIssueSAML2Token() throws Exception {
-String address = "https://localhost:"; + STSPORT + 
"/SecurityTokenService/token";
-WebClient client = webClient(address)
+WebClient client = webClient()
 .path("saml2.0")
 .accept(MediaType.APPLICATION_XML);
 
@@ -131,20 +130,13 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 assertNotNull(assertionDoc);
 
 // Process the token
-List results = 
processToken(assertionDoc.getDocumentElement());
-
-assertTrue(results != null && results.size() == 1);
-SamlAssertionWrapper assertion =
-
(SamlAssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
-assertNotNull(assertion);
+SamlAssertionWrapper assertion = processToken(assertionDoc);
 assertTrue(assertion.getSaml2() != null && assertion.getSaml1() == 
null);
-assertTrue(assertion.isSigned());
 }
 
 @org.junit.Test
 public void testIssueSAML1Token() throws Exception {
-String address = "https://localhost:"; + STSPORT + 
"/SecurityTokenService/token";
-WebClient client = webClient(address)
+WebClient client = webClient()
 .path("saml1.1")
 .accept(MediaType.APPLICATION_XML);
 
@@ -152,20 +144,13 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 assertNotNull(assertionDoc);
 
 // Process the token
-List results = 
processToken(assertionDoc.getDocumentElement());
-
-assertTrue(results != null && results.size() == 1);
-SamlAssertionWrapper assertion =
-
(SamlAssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
-assertNotNull(assertion);
+SamlAssertionWrapper assertion = processToken(assertionDoc);
 assertTrue(assertion.getSaml2() == null && assertion.getSaml1() != 
null);
-assertTrue(assertion.isSigned());
 }
 
 @org.junit.Test
 public void testIssueSymmetricKeySaml1() throws Exception {
-String address = "https://localhost:"; + STSPORT + 
"/SecurityTokenService/token";
-WebClient client = webClient(address)
+WebClient client = webClient()
 .path("saml1.1")
 .query("keyType", STSConstants.SYMMETRIC_KEY_KEYTYPE)
 .accept(MediaType.APPLICATION_XML);
@@ -174,14 +159,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 assertNotNull(assertionDoc);
 
 // Process the token
-List results = 
processToken(assertionDoc.getDocumentElement());
-
-assertTrue(results != null && results.size() == 1);
-SamlAssertionWrapper assertion =
-
(SamlAssertionWrapper)results.get(0).get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
-assertNotNull(assertion);
+SamlAssertionWrapper assertion = processToken(assertionDoc);
 assertTrue(assertion.getSaml2() == null && assertion.getSaml1() != 
null);
-assertTrue(assertion.isSigned());
 
 List methods = assertion.getConfirmationMethods();
 String confirmMethod = null;
@@ -195,8 +174,7 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 
 @org.junit.Test
 public void testIssueSymmetricKeySaml1ShortKeyType() throws Exception {
-String address = "https://localhost:"; + STSPORT + 
"/SecurityTokenService/token";
-WebClient client = webClient(address)
+WebClient client = webClient()
 .path("saml1.1")
 .query("keyType", "SymmetricKey")
 .accept(MediaType.APPLICATION_XML);
@@ -205,14 +183,8 @@ public class STSRESTTest extends 
AbstractBusClientServerTestBase {
 assertNotNull(assertionDoc