Ejemplo n.º 1
0
        public void PollForResultRequestTimeout_expectTimeoutError()
        {
            IAuthenticationClient authenticationClient = AuthenticationClient.Create(SslSettings.Create(TestKeystoreUtil.GetKeystorePath(TestKeystoreUtil.KEYSTORE_PATH_PKCS12), TestKeystoreUtil.KEYSTORE_PASSWORD, TestKeystoreUtil.GetKeystorePath(TestKeystoreUtil.CERTIFICATE_PATH)), FrejaEnvironment.TEST)
                                                         .SetHttpService(CommonTestData.HttpServiceMock.Object)
                                                         .SetTransactionContext(TransactionContext.PERSONAL).Build <AuthenticationClient>();
            AuthenticationResultRequest authenticationResultRequest = AuthenticationResultRequest.Create(CommonTestData.REFERENCE);

            try
            {
                CommonTestData.HttpServiceMock.Setup(x => x.Send <AuthenticationResult>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <AuthenticationResultRequest>(), It.IsAny <string>())).Throws(new FrejaEidClientPollingException(POLLING_TIMEOUT_ERROR_MESSAGE));
                AuthenticationResult response = authenticationClient.PollForResult(authenticationResultRequest, WAITING_TIME_IN_SEC);
                Assert.Fail("Test should throw exception!");
            }
            catch (FrejaEidClientPollingException ex)
            {
                CommonTestData.HttpServiceMock.Verify(x => x.Send <AuthenticationResult>(new Uri(FrejaEnvironment.TEST + MethodUrl.AUTHENTICATION_GET_RESULT), RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE, authenticationResultRequest, null));
                Assert.AreEqual(POLLING_TIMEOUT_ERROR_MESSAGE, ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void PollForResultFinalResponseRejected(AuthenticationResultRequest authenticationResultRequest, TransactionContext transactionContext, string relyingPartyId)
        {
            AuthenticationResult  expectedResponse     = new AuthenticationResult(CommonTestData.DETAILS, TransactionStatus.REJECTED, CommonTestData.DETAILS, null);
            IAuthenticationClient authenticationClient = AuthenticationClient.Create(SslSettings.Create(TestKeystoreUtil.GetKeystorePath(TestKeystoreUtil.KEYSTORE_PATH_PKCS12), TestKeystoreUtil.KEYSTORE_PASSWORD, TestKeystoreUtil.GetKeystorePath(TestKeystoreUtil.CERTIFICATE_PATH)), FrejaEnvironment.TEST)
                                                         .SetHttpService(CommonTestData.HttpServiceMock.Object)
                                                         .SetTransactionContext(transactionContext).Build <AuthenticationClient>();

            CommonTestData.HttpServiceMock.Setup(x => x.Send <AuthenticationResult>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <AuthenticationResultRequest>(), It.IsAny <string>())).Returns(expectedResponse);
            AuthenticationResult response = authenticationClient.PollForResult(authenticationResultRequest, WAITING_TIME_IN_SEC);

            if (transactionContext.Equals(TransactionContext.PERSONAL))
            {
                CommonTestData.HttpServiceMock.Verify(x => x.Send <AuthenticationResult>(new Uri(FrejaEnvironment.TEST + MethodUrl.AUTHENTICATION_GET_RESULT), RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE, authenticationResultRequest, relyingPartyId));
            }
            else
            {
                CommonTestData.HttpServiceMock.Verify(x => x.Send <AuthenticationResult>(new Uri(FrejaEnvironment.TEST + MethodUrl.ORGANISATION_AUTHENTICATION_GET_ONE_RESULT), RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE, authenticationResultRequest, relyingPartyId));
            }
            Assert.AreEqual(expectedResponse.Status, response.Status);
        }