aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 14:32:20 +0100
committerChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 14:32:20 +0100
commitc5d36685c294a383baecf4e12aaeda5be1f13529 (patch)
treef4ead86870350186a02d2c86d00f739876065838 /eidas_modules/authmodule-eIDAS-v2/src/test
parentb9bc937ff9471c60ced2ef9ed7df526cf31059db (diff)
downloadNational_eIDAS_Gateway-c5d36685c294a383baecf4e12aaeda5be1f13529.tar.gz
National_eIDAS_Gateway-c5d36685c294a383baecf4e12aaeda5be1f13529.tar.bz2
National_eIDAS_Gateway-c5d36685c294a383baecf4e12aaeda5be1f13529.zip
Refactor ErnpData to make it immutable
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTest.java60
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java36
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java24
3 files changed, 60 insertions, 60 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 cf4ed95c..208a008b 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
@@ -67,7 +67,7 @@ import com.skjolberg.mockito.soap.SoapServiceRule;
import at.asitplus.eidas.specific.connector.test.config.dummy.MsConnectorDummyConfigMap;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnbEidData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
@@ -103,7 +103,7 @@ public class SzrClientTest {
@Autowired MsConnectorDummyConfigMap basicConfig;
private static ObjectMapper mapper = new ObjectMapper();
-
+
private static final String givenName = "Franz";
private static final String familyName = "Mustermann";
private static final String dateOfBirth = "1989-05-05";
@@ -111,7 +111,7 @@ public class SzrClientTest {
private static final String DUMMY_TARGET = EaafConstants.URN_PREFIX_CDID + "ZP";
private SZR szrMock = null;
- ErnbEidData eidData = null;
+ ErnpEidData eidData = null;
@Rule
public SoapServiceRule soap = SoapServiceRule.newInstance();
@@ -125,16 +125,16 @@ public class SzrClientTest {
szrMock = soap.mock(SZR.class, "http://localhost:1234/demoszr");
}
-
- eidData = new ErnbEidData();
- eidData.setFamilyName(familyName);
- eidData.setGivenName(givenName);
- eidData.setDateOfBirth(new DateTime());
- eidData.setCitizenCountryCode("IS");
- eidData.setPseudonym("1234sdgsdfg56789ABCDEF");
-
+
+ eidData = ErnpEidData.builder()
+ .familyName(familyName)
+ .givenName(givenName)
+ .dateOfBirth(new DateTime())
+ .citizenCountryCode("IS")
+ .pseudonym("1234sdgsdfg56789ABCDEF").build();
+
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.eidasbind.mds.inject", "false");
-
+
}
@@ -181,40 +181,40 @@ public class SzrClientTest {
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 {
+
+ try {
szrClient
.getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10), eidData);
} 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
.getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10), eidData);
} 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();
@@ -222,19 +222,19 @@ public class SzrClientTest {
result2.setKey("bcBindReq");
result2.setValue("");
when(szrMock.signContent(any(), anyList(), anyList())).thenReturn(content1);
-
+
try {
szrClient
.getEidsaBind(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAlphabetic(10),
RandomStringUtils.randomAlphabetic(10), eidData);
} catch (SzrCommunicationException e) {
Assert.assertTrue("Not correct error", e.getMessage().contains("ernb.01"));
-
- }
+
+ }
}
-
+
@Test
- public void eidasBindValid() throws SZRException_Exception, SzrCommunicationException, JsonMappingException,
+ public void eidasBindValid() throws SZRException_Exception, SzrCommunicationException, JsonMappingException,
JsonProcessingException, JoseException {
final SignContentResponse szrResponse = new SignContentResponse();
final SignContentEntry result1 = new SignContentEntry();
@@ -253,14 +253,14 @@ public class SzrClientTest {
Assert.assertNotNull("bcBind is null", bcBind);
Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
-
+
}
@Test
- public void eidasBindValidWithMds() throws SZRException_Exception, SzrCommunicationException, JoseException,
+ public void eidasBindValidWithMds() throws SZRException_Exception, SzrCommunicationException, JoseException,
JsonMappingException, JsonProcessingException {
basicConfig.putConfigValue("eidas.ms.auth.eIDAS.szrclient.eidasbind.mds.inject", "true");
-
+
final SignContentResponse szrResponse = new SignContentResponse();
final SignContentEntry result1 = new SignContentEntry();
final SignContentResponseType content = new SignContentResponseType();
@@ -280,7 +280,7 @@ public class SzrClientTest {
Assert.assertEquals("bcBind not match", result1.getValue(), bcBind);
}
-
+
@Test
public void getIdentityLinkRawModeValidResponse()
throws SZRException_Exception, EaafParserException, NoSuchProviderException, IOException, InvalidKeyException,
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
index 1e7ff369..eff56ffd 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/SzrClientTestProduction.java
@@ -48,7 +48,7 @@ import org.springframework.util.Base64Utils;
import org.w3c.dom.Element;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnbEidData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasSAuthenticationException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.szr.SzrClient;
@@ -98,32 +98,32 @@ public class SzrClientTestProduction {
}
@Test
- public void getVsz() throws SzrCommunicationException, EidasSAuthenticationException {
- String vsz = szrClient.getEncryptedStammzahl(getPersonInfo());
+ public void getVsz() throws SzrCommunicationException, EidasSAuthenticationException {
+ String vsz = szrClient.getEncryptedStammzahl(getPersonInfo());
Assert.assertNotNull("vsz", vsz);
-
+
}
@Test
- public void getEidasBind() throws SzrCommunicationException, EidasSAuthenticationException {
+ public void getEidasBind() throws SzrCommunicationException, EidasSAuthenticationException {
String vsz = RandomStringUtils.randomAlphanumeric(10);
String bindingPubKey = Base64.toBase64String(RandomStringUtils.random(20).getBytes());
String eidStatus = "urn:eidgvat:eid.status.eidas";
- ErnbEidData eidData = new ErnbEidData();
- eidData.setFamilyName(familyName);
- eidData.setGivenName(givenName);
- eidData.setDateOfBirth(new DateTime());
- eidData.setCitizenCountryCode("IS");
- eidData.setPseudonym("1234sdgsdfg56789ABCDEF");
-
-
- String eidasBind = szrClient.getEidsaBind(vsz, bindingPubKey, eidStatus, eidData);
-
+ ErnpEidData eidData = ErnpEidData.builder()
+ .familyName(familyName)
+ .givenName(givenName)
+ .dateOfBirth(new DateTime())
+ .citizenCountryCode("IS")
+ .pseudonym("1234sdgsdfg56789ABCDEF").build();
+
+
+ String eidasBind = szrClient.getEidsaBind(vsz, bindingPubKey, eidStatus, eidData);
+
Assert.assertNotNull("eidasBind", eidasBind);
-
+
}
-
-
+
+
@Test
public void getIdentityLinkRawMode() throws SZRException_Exception, EaafParserException,
NoSuchProviderException, IOException, InvalidKeyException, EidasSAuthenticationException {
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
index 9bb51cd9..381406d2 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/validation/EidasAttributePostProcessingTest.java
@@ -41,7 +41,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants;
-import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnbEidData;
+import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData;
import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.CcSpecificEidProcessingService;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -116,7 +116,7 @@ public class EidasAttributePostProcessingTest {
/**
* jUnit class initializer.
- *
+ *
* @throws IOException In case of an error
*/
@BeforeClass
@@ -129,7 +129,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void deWithHexLowerCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P1_eIDASID,
P1_FAMILYNAME,
@@ -156,7 +156,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void deWithHexMixedCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P3_eIDASID,
P3_FAMILYNAME,
@@ -183,7 +183,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void deWithHexUpperCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P4_eIDASID,
P4_FAMILYNAME,
@@ -270,7 +270,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void eeTestCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P2_eIDASID,
P2_FAMILYNAME,
@@ -297,7 +297,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void eeTestFamilyNameMissingCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P2_eIDASID,
null,
@@ -326,7 +326,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void eeTestGivenNameMissingCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P2_eIDASID,
P2_FAMILYNAME,
@@ -355,7 +355,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void eeTestDateOfBirthMissingCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
P2_eIDASID,
P2_FAMILYNAME,
@@ -384,7 +384,7 @@ public class EidasAttributePostProcessingTest {
@Test
public void eeTestIdMissingCase() throws Exception {
try {
- final ErnbEidData result = postProcessor.postProcess(
+ final ErnpEidData result = postProcessor.postProcess(
generateInputData(
null,
P2_FAMILYNAME,
@@ -423,8 +423,8 @@ public class EidasAttributePostProcessingTest {
}
- private void validate(ErnbEidData result, String id, String familyName, String givenName,
- DateTime dateOfBirth, String placeOfBirth, String birthName) {
+ private void validate(ErnpEidData result, String id, String familyName, String givenName,
+ DateTime dateOfBirth, String placeOfBirth, String birthName) {
if (!result.getPseudonym().equals(id)) {
fail(result.getPseudonym() + "is not equal to " + id);
}