Search in sources :

Example 1 with DigiDocServicePortType

use of com.codeborne.security.digidoc.DigiDocServicePortType in project mobileid by codeborne.

the class MobileIDAuthenticatorTest method mockError.

private DigiDocServicePortType mockError(int errorCode) throws RemoteException {
    DigiDocServicePortType service = mock(DigiDocServicePortType.class);
    doThrow(new RemoteException(valueOf(errorCode))).when(service).mobileAuthenticate(anyString(), anyString(), eq("37255667788"), anyString(), anyString(), anyString(), anyString(), anyString(), anyInt(), anyBoolean(), anyBoolean(), any(IntHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class));
    return service;
}
Also used : StringHolder(javax.xml.rpc.holders.StringHolder) DigiDocServicePortType(com.codeborne.security.digidoc.DigiDocServicePortType) IntHolder(javax.xml.rpc.holders.IntHolder) RemoteException(java.rmi.RemoteException)

Example 2 with DigiDocServicePortType

use of com.codeborne.security.digidoc.DigiDocServicePortType in project mobileid by codeborne.

the class MobileIDAuthenticatorTest method mockStatus.

private DigiDocServicePortType mockStatus(final Code status) throws RemoteException {
    DigiDocServicePortType service = mock(DigiDocServicePortType.class);
    doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            ((StringHolder) invocation.getArguments()[2]).value = status.toString();
            return null;
        }
    }).when(service).getMobileAuthenticateStatus(anyInt(), eq(false), any(StringHolder.class), any(StringHolder.class));
    return service;
}
Also used : StringHolder(javax.xml.rpc.holders.StringHolder) DigiDocServicePortType(com.codeborne.security.digidoc.DigiDocServicePortType) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 3 with DigiDocServicePortType

use of com.codeborne.security.digidoc.DigiDocServicePortType in project mobileid by codeborne.

the class MobileIDAuthenticatorTest method mockAuthentication.

private DigiDocServicePortType mockAuthentication(String result, String firstName, String lastName, String personalCode, String challenge, int sessCode) throws RemoteException {
    DigiDocServicePortType service = mock(DigiDocServicePortType.class);
    doAnswer((Answer<Object>) invocation -> {
        ((IntHolder) invocation.getArguments()[11]).value = sessCode;
        ((StringHolder) invocation.getArguments()[12]).value = result;
        ((StringHolder) invocation.getArguments()[13]).value = personalCode;
        ((StringHolder) invocation.getArguments()[14]).value = firstName;
        ((StringHolder) invocation.getArguments()[15]).value = lastName;
        ((StringHolder) invocation.getArguments()[19]).value = challenge;
        return null;
    }).when(service).mobileAuthenticate(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyInt(), anyBoolean(), anyBoolean(), any(IntHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class), any(StringHolder.class));
    return service;
}
Also used : DigiDocServicePortType(com.codeborne.security.digidoc.DigiDocServicePortType) IntHolder(javax.xml.rpc.holders.IntHolder) StringHolder(javax.xml.rpc.holders.StringHolder) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Matchers(org.mockito.Matchers) Test(org.junit.Test) RemoteException(java.rmi.RemoteException) Answer(org.mockito.stubbing.Answer) Mockito(org.mockito.Mockito) InvocationOnMock(org.mockito.invocation.InvocationOnMock) String.valueOf(java.lang.String.valueOf) Code(com.codeborne.security.AuthenticationException.Code) AuthenticationException(com.codeborne.security.AuthenticationException) Assert(org.junit.Assert) Before(org.junit.Before) StringHolder(javax.xml.rpc.holders.StringHolder) DigiDocServicePortType(com.codeborne.security.digidoc.DigiDocServicePortType) IntHolder(javax.xml.rpc.holders.IntHolder)

Aggregations

DigiDocServicePortType (com.codeborne.security.digidoc.DigiDocServicePortType)3 StringHolder (javax.xml.rpc.holders.StringHolder)3 RemoteException (java.rmi.RemoteException)2 IntHolder (javax.xml.rpc.holders.IntHolder)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 AuthenticationException (com.codeborne.security.AuthenticationException)1 Code (com.codeborne.security.AuthenticationException.Code)1 String.valueOf (java.lang.String.valueOf)1 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Matchers (org.mockito.Matchers)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1