aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java61
1 files changed, 51 insertions, 10 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
index b54b8800..3bb7ee06 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java
@@ -39,6 +39,7 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.ws.soap.SOAPFaultException;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.binding.soap.SoapFault;
@@ -146,7 +147,7 @@ public class SzrClientTest {
}
@Test
- public void getBcBindValid() throws SZRException_Exception, SzrCommunicationException {
+ public void getEidasBindRealSzrResponse() throws SZRException_Exception, SzrCommunicationException, IOException {
final SignContentResponse szrResponse = new SignContentResponse();
final SignContentEntry result1 = new SignContentEntry();
final SignContentResponseType content = new SignContentResponseType();
@@ -154,48 +155,88 @@ public class SzrClientTest {
szrResponse.setSignContentResponse(content);
result1.setKey("bcBindReq");
- result1.setValue(RandomStringUtils.randomAlphanumeric(100));
+ result1.setValue(IOUtils.toString(SzrClient.class.getResourceAsStream("/data/szr/signed_eidasBind.jws")));
when(szrMock.signContent(any(), anyList(), anyList())).thenReturn(content);
final String bcBind = szrClient
- .getBcBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
+ .getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10));
Assert.assertNotNull("bcBind is null", bcBind);
Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
+
+ }
+ @Test
+ public void eidasBindNull() throws SZRException_Exception {
when(szrMock.signContent(any(), anyList(), anyList())).thenReturn(null);
+
try {
szrClient
- .getBcBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
+ .getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10));
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
- }
-
+
+ }
+ }
+
+ @Test
+ public void eidasBindInvalidResponse() throws SZRException_Exception {
final SignContentEntry result2 = new SignContentEntry();
final SignContentResponseType content1 = new SignContentResponseType();
content1.getOut().add(result2);
when(szrMock.signContent(any(), anyList(), anyList())).thenReturn(content1);
+
try {
szrClient
- .getBcBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
+ .getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10));
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
+
}
-
+ }
+
+ public void eidasBindEmptyResponse() throws SZRException_Exception {
+ final SignContentEntry result2 = new SignContentEntry();
+ final SignContentResponseType content1 = new SignContentResponseType();
+ content1.getOut().add(result2);
result2.setKey("bcBindReq");
result2.setValue("");
when(szrMock.signContent(any(), anyList(), anyList())).thenReturn(content1);
+
try {
szrClient
- .getBcBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
+ .getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10));
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
- }
+
+ }
+ }
+
+ @Test
+ public void eidasBindValid() throws SZRException_Exception, SzrCommunicationException {
+ final SignContentResponse szrResponse = new SignContentResponse();
+ final SignContentEntry result1 = new SignContentEntry();
+ final SignContentResponseType content = new SignContentResponseType();
+ content.getOut().add(result1);
+ szrResponse.setSignContentResponse(content);
+
+ result1.setKey("bcBindReq");
+ result1.setValue(RandomStringUtils.randomAlphanumeric(100));
+
+ when(szrMock.signContent(any(), anyList(), anyList())).thenReturn(content);
+
+ final String bcBind = szrClient
+ .getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
+ RandomStringUtils.randomAlphabetic(10));
+
+ Assert.assertNotNull("bcBind is null", bcBind);
+ Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
+
}
@Test