aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/test/java/at
diff options
context:
space:
mode:
authorChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 15:04:08 +0100
committerChristian Kollmann <christian.kollmann@a-sit.at>2021-03-04 15:04:08 +0100
commit20fcdf7cd830af9f23645c71f536af95418ad1be (patch)
treee9837d42665b3172b09bda45617e61568fe1dd3d /eidas_modules/authmodule-eIDAS-v2/src/test/java/at
parentc5d36685c294a383baecf4e12aaeda5be1f13529 (diff)
downloadNational_eIDAS_Gateway-20fcdf7cd830af9f23645c71f536af95418ad1be.tar.gz
National_eIDAS_Gateway-20fcdf7cd830af9f23645c71f536af95418ad1be.tar.bz2
National_eIDAS_Gateway-20fcdf7cd830af9f23645c71f536af95418ad1be.zip
Refactor SimpleEidasData to make it immutable
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java11
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java23
2 files changed, 17 insertions, 17 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java
index 38693f49..d9405251 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveAustrianResidenceGuiResponseTaskTest.java
@@ -175,11 +175,12 @@ public class ReceiveAustrianResidenceGuiResponseTaskTest {
@NotNull
private SimpleEidasData setupEidasData() throws EaafStorageException {
- SimpleEidasData result = new SimpleEidasData();
- result.setPseudonym(RandomStringUtils.randomAlphabetic(8));
- result.setFamilyName(RandomStringUtils.randomAlphabetic(8));
- result.setGivenName(RandomStringUtils.randomAlphabetic(8));
- result.setDateOfBirth("1970-01-01");
+ SimpleEidasData result = SimpleEidasData.builder()
+ .pseudonym(RandomStringUtils.randomAlphabetic(8))
+ .familyName(RandomStringUtils.randomAlphabetic(8))
+ .givenName(RandomStringUtils.randomAlphabetic(8))
+ .dateOfBirth("1970-01-01")
+ .build();
AuthProcessDataWrapper authProcessDataWrapper = pendingReq.getSessionData(AuthProcessDataWrapper.class);
authProcessDataWrapper.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, result);
return result;
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java
index 01688214..77b87264 100644
--- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java
+++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/ReceiveMobilePhoneSignatureResponseTaskTest.java
@@ -314,8 +314,9 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
setupMetadataResolver();
initResponse("/data/Response_with_EID.xml", true);
AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class);
- SimpleEidasData eidData = createEidasDataMatchingToSamlResponse();
- eidData.setFamilyName(eidData.getFamilyName() + "notmatching");
+ SimpleEidasData eidData = createEidasDataMatchingToSamlResponse()
+ .familyName("notmatching")
+ .build();
authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData);
TaskExecutionException e = assertThrows(TaskExecutionException.class,
@@ -331,7 +332,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
setupMetadataResolver();
initResponse("/data/Response_with_EID.xml", true);
AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class);
- SimpleEidasData eidData = createEidasDataMatchingToSamlResponse();
+ SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build();
authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData);
MergedRegisterSearchResult registerSearchResult = new MergedRegisterSearchResult(Collections.emptyList(), Collections.emptyList());
Mockito.when(registerSearchService.searchWithBpkZp(eq(BPK_FROM_ID_AUSTRIA))).thenReturn(registerSearchResult);
@@ -350,7 +351,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
setupMetadataResolver();
initResponse("/data/Response_with_EID.xml", true);
AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class);
- SimpleEidasData eidData = createEidasDataMatchingToSamlResponse();
+ SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build();
authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData);
MergedRegisterSearchResult registerSearchResult = buildResultWithOneMatch();
Mockito.when(registerSearchService.searchWithBpkZp(eq(BPK_FROM_ID_AUSTRIA))).thenReturn(registerSearchResult);
@@ -370,7 +371,7 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
setupMetadataResolver();
initResponse("/data/Response_with_EID.xml", true);
AuthProcessDataWrapper authProcessData = pendingReq.getSessionData(AuthProcessDataWrapper.class);
- SimpleEidasData eidData = createEidasDataMatchingToSamlResponse();
+ SimpleEidasData eidData = createEidasDataMatchingToSamlResponse().build();
authProcessData.setGenericDataToSession(Constants.DATA_SIMPLE_EIDAS, eidData);
MergedRegisterSearchResult registerSearchResult = buildResultWithTwoMatches();
Mockito.when(registerSearchService.searchWithBpkZp(eq(BPK_FROM_ID_AUSTRIA))).thenReturn(registerSearchResult);
@@ -400,14 +401,12 @@ public class ReceiveMobilePhoneSignatureResponseTaskTest {
return new MergedRegisterSearchResult(results, Collections.emptyList());
}
- @NotNull
- private SimpleEidasData createEidasDataMatchingToSamlResponse() {
+ private SimpleEidasData.SimpleEidasDataBuilder createEidasDataMatchingToSamlResponse() {
// data from "/data/Response_with_EID.xml"
- SimpleEidasData result = new SimpleEidasData();
- result.setFamilyName("Mustermann");
- result.setGivenName("Max");
- result.setDateOfBirth("1940-01-01");
- return result;
+ return SimpleEidasData.builder()
+ .familyName("Mustermann")
+ .givenName("Max")
+ .dateOfBirth("1940-01-01");
}
private void addSamlResponseToHttpReq(Response response) throws TransformerException, IOException, MarshallingException {