diff options
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/test/java/at')
2 files changed, 69 insertions, 8 deletions
| diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java index 0c6ec95d..028c0359 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/AlternativeSearchTaskWithRegisterTest.java @@ -35,7 +35,7 @@ import org.junit.Test;  import org.junit.runner.RunWith;  import org.mockito.ArgumentCaptor;  import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import org.mockito.Mockito;  import org.springframework.beans.factory.annotation.Autowired;  import org.springframework.mock.web.MockHttpServletRequest;  import org.springframework.mock.web.MockHttpServletResponse; @@ -49,6 +49,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;  import com.github.skjolber.mockito.soap.SoapServiceRule;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.ErnpRestClient.ErnpRegisterResult;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.ernp.IErnpClient;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.IZmrClient;  import at.asitplus.eidas.specific.modules.auth.eidas.v2.clients.zmr.ZmrSoapClient.ZmrRegisterResult; @@ -407,7 +408,10 @@ public class AlternativeSearchTaskWithRegisterTest {      when(zmrMock.service(zmrReq.capture(), any()))          .thenReturn(loadResponseFromFile("/data/zmr/seq_1-8_search_with_personalId_only_resp.xml"))          .thenThrow(new RuntimeException("This request is not needed any more")); - +     +    Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +          // execute task      TaskExecutionException exception = assertThrows(TaskExecutionException.class,          () -> task.execute(pendingReq, executionContext)); @@ -470,6 +474,13 @@ public class AlternativeSearchTaskWithRegisterTest {          .thenReturn(loadResponseFromFile("/data/zmr/seq_3-8_kitt_get_latest_version_resp.xml"))          .thenThrow(new RuntimeException("This request is not needed any more")); +    Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.update(any(), any())) +        .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); +          // execute task      task.execute(pendingReq, executionContext); @@ -549,6 +560,15 @@ public class AlternativeSearchTaskWithRegisterTest {          .thenReturn(loadResponseFromFile("/data/zmr/seq_3-10_kitt_update_resp.xml"))          .thenThrow(new RuntimeException("This request is not needed any more")); +    Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.searchCountrySpecific(any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.update(any(), any())) +        .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); +          // execute task      task.execute(pendingReq, executionContext); @@ -636,6 +656,9 @@ public class AlternativeSearchTaskWithRegisterTest {          .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml"))          .thenThrow(new RuntimeException("This request is not needed any more")); +    Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +          // execute task      task.execute(pendingReq, executionContext); @@ -697,6 +720,13 @@ public class AlternativeSearchTaskWithRegisterTest {          .thenReturn(loadResponseFromFile("/data/zmr/search_with_personalId_only_resp_moreThanOne.xml"))          .thenThrow(new RuntimeException("This request is not needed any more")); +    Mockito.when(ernpClient.searchWithPersonIdentifier(any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.searchWithMds(any(), any(), any(), any())) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.update(any(), any())) +        .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); +          // execute task      TaskExecutionException exception = assertThrows(TaskExecutionException.class,          () -> task.execute(pendingReq, executionContext)); @@ -769,6 +799,14 @@ public class AlternativeSearchTaskWithRegisterTest {          .thenReturn(loadResponseFromFile("/data/zmr/empty_zmr_result.xml"))          .thenThrow(new RuntimeException("This request is not needed any more")); +    Mockito.when(ernpClient.searchWithPersonIdentifier("7cEYasdfsafsaf4CDVzNT4E7cjkU4VqForjUnit", "DE")) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.searchWithMds("XXXKlaus - Maria", "XXXvon Brandenburg", "1994-12-31","DE")) +        .thenReturn(emptyErnpRegisterResult()); +    Mockito.when(ernpClient.update(any(), any())) +        .thenThrow(new IllegalStateException("ERnP update should not be neccessary")); +     +          // execute task      task.execute(pendingReq, executionContext); @@ -970,6 +1008,10 @@ public class AlternativeSearchTaskWithRegisterTest {    } +  @NotNull +  private ErnpRegisterResult emptyErnpRegisterResult() { +    return new ErnpRegisterResult(Collections.emptyList()); +  }  } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java index ea84c39c..565efe09 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskWithRegistersTest.java @@ -47,6 +47,7 @@ import javax.xml.namespace.QName;  import org.apache.commons.lang3.RandomStringUtils;  import org.jetbrains.annotations.NotNull; +import org.junit.AfterClass;  import org.junit.Assert;  import org.junit.Before;  import org.junit.BeforeClass; @@ -54,8 +55,6 @@ import org.junit.Rule;  import org.junit.Test;  import org.junit.runner.RunWith;  import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations;  import org.springframework.beans.factory.annotation.Autowired;  import org.springframework.mock.web.MockHttpServletRequest;  import org.springframework.mock.web.MockHttpServletResponse; @@ -103,6 +102,8 @@ import eu.eidas.auth.commons.attribute.PersonType;  import eu.eidas.auth.commons.light.impl.LightRequest;  import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse;  import lombok.SneakyThrows; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer;  @RunWith(SpringJUnit4ClassRunner.class)  @ContextConfiguration(locations = { @@ -119,14 +120,16 @@ public class InitialSearchTaskWithRegistersTest {    @Rule    public SoapServiceRule soap = SoapServiceRule.newInstance(); -  @Mock private IErnpClient ernpClient; - -  @Autowired private IZmrClient zmrClient; -  @Autowired private List<CountrySpecificDetailSearchProcessor> handlers; +  @Autowired IErnpClient ernpClient;    +  @Autowired IZmrClient zmrClient; +  @Autowired List<CountrySpecificDetailSearchProcessor> handlers; +      private RegisterSearchService registerSearchService;    private ServicePort zmrMock = null; +  private static MockWebServer mockWebServer; +      private final ICcSpecificEidProcessingService eidPostProcessor = createEidPostProcessor();    private InitialSearchTask task; @@ -144,13 +147,24 @@ public class InitialSearchTaskWithRegistersTest {          at.gv.bmi.namespace.zmr_su.zmr._20040201.ObjectFactory.class,          at.gv.bmi.namespace.zmr_su.gis._20070725.ObjectFactory.class,          at.gv.bmi.namespace.zmr_su.base._20040201.ObjectFactory.class); +     +    mockWebServer = new MockWebServer(); +    mockWebServer.start(1718); +        } +  @AfterClass +  @SneakyThrows +  public static void resetTestEnviroment() { +    mockWebServer.shutdown(); + +  }    /**     * jUnit test set-up.     */    @Before +  @SneakyThrows    public void setUp() throws URISyntaxException, EaafStorageException {      if (zmrMock == null) {        zmrMock = soap.mock(ServicePort.class, "http://localhost:1234/demozmr"); @@ -167,6 +181,11 @@ public class InitialSearchTaskWithRegistersTest {      pendingReq = new TestRequestImpl(); +     +    mockWebServer.enqueue(new MockResponse().setResponseCode(200) +        .setBody("{}") +        .setHeader("Content-Type", "application/json;charset=utf-8")); +        }    /** | 
