コード例 #1
0
        private void SendAndValidateCancelRequest(CancelAuthenticationRequest cancelAuthenticationRequest)
        {
            CancelAuthenticationRequest expectedCancelRequest = CancelAuthenticationRequest.Create(REFERENCE);
            String responseString = jsonService.SerializeToJson(new EmptyFrejaResponse());

            StartMockServer(expectedCancelRequest, (int)HttpStatusCode.OK, responseString);

            authenticationClient.Cancel(cancelAuthenticationRequest);
        }
コード例 #2
0
        private void CancelAuthentication(CancelAuthenticationRequest cancelAuthenticationRequest, TransactionContext transactionContext, string RelyingPartyId)
        {
            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 <EmptyFrejaResponse>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <CancelAuthenticationRequest>(), It.IsAny <string>())).Returns(new EmptyFrejaResponse());
            authenticationClient.Cancel(cancelAuthenticationRequest);
            if (transactionContext.Equals(TransactionContext.PERSONAL))
            {
                CommonTestData.HttpServiceMock.Verify(x => x.Send <EmptyFrejaResponse>(new Uri(FrejaEnvironment.TEST + MethodUrl.AUTHENTICATION_CANCEL), RequestTemplate.CANCEL_AUTHENTICATION_TEMPLATE, cancelAuthenticationRequest, RelyingPartyId));
            }
            else
            {
                CommonTestData.HttpServiceMock.Verify(x => x.Send <EmptyFrejaResponse>(new Uri(FrejaEnvironment.TEST + MethodUrl.ORGANISATION_AUTHENTICATION_CANCEL), RequestTemplate.CANCEL_AUTHENTICATION_TEMPLATE, cancelAuthenticationRequest, RelyingPartyId));
            }
        }
コード例 #3
0
        public void InvalidReference_expectInvalidReferenceError()
        {
            CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE, CommonTestData.RELYING_PARTY_ID);

            try
            {
                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>();

                CommonTestData.HttpServiceMock.Setup(x => x.Send <EmptyFrejaResponse>(It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <CancelAuthenticationRequest>(), It.IsAny <string>())).Throws(new FrejaEidException(INVALID_REFERENCE_ERROR_MESSAGE, INVALID_REFERENCE_ERROR_CODE));
                authenticationClient.Cancel(cancelAuthenticationRequest);
                Assert.Fail("Test should throw exception!");
            }
            catch (FrejaEidException rpEx)
            {
                CommonTestData.HttpServiceMock.Verify(x => x.Send <EmptyFrejaResponse>(new Uri(FrejaEnvironment.TEST + MethodUrl.AUTHENTICATION_CANCEL), RequestTemplate.CANCEL_AUTHENTICATION_TEMPLATE, cancelAuthenticationRequest, CommonTestData.RELYING_PARTY_ID));
                Assert.AreEqual(INVALID_REFERENCE_ERROR_CODE, rpEx.ErrorCode);
                Assert.AreEqual(INVALID_REFERENCE_ERROR_MESSAGE, rpEx.Message);
            }
        }
コード例 #4
0
        public void CancelAuth_sendRequestWithoutRelyingPartyId_success()
        {
            CancelAuthenticationRequest cancelRequest = CancelAuthenticationRequest.Create(REFERENCE);

            SendAndValidateCancelRequest(cancelRequest);
        }
コード例 #5
0
        public void CancelRequest_relyingPartyIdEmpty_expectError()
        {
            CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(REFERENCE, "");

            ValidateRequest_expectError("RelyingPartyId cannot be empty.", () => authenticationClient.Cancel(cancelAuthenticationRequest));
        }
コード例 #6
0
        public void CancelRequest_referenceNull_expectError()
        {
            CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(null);

            ValidateRequest_expectError("Reference cannot be null or empty.", () => authenticationClient.Cancel(cancelAuthenticationRequest));
        }
コード例 #7
0
 public void Cancel(CancelAuthenticationRequest cancelAuthenticationRequest)
 {
     RequestValidationService.ValidateCancelRequest(cancelAuthenticationRequest);
     authenticationService.Cancel(cancelAuthenticationRequest);
 }
コード例 #8
0
 public static void ValidateCancelRequest(CancelAuthenticationRequest cancelRequest)
 {
     ValidateRequest(cancelRequest);
     ValidateReference(cancelRequest.AuthRef);
     ValidateRelyingPartyIdIsEmpty(cancelRequest.RelyingPartyId);
 }
コード例 #9
0
        public void OrganisationlContext_success()
        {
            CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE, CommonTestData.RELYING_PARTY_ID);

            CancelAuthentication(cancelAuthenticationRequest, TransactionContext.ORGANISATIONAL, CommonTestData.RELYING_PARTY_ID);
        }
コード例 #10
0
        public void PersonalContext_success()
        {
            CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE, CommonTestData.RELYING_PARTY_ID);

            CancelAuthentication(cancelAuthenticationRequest, TransactionContext.PERSONAL, CommonTestData.RELYING_PARTY_ID);
        }
コード例 #11
0
        public void RelyingPartyIdNull_success()
        {
            CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE);

            CancelAuthentication(cancelAuthenticationRequest, TransactionContext.PERSONAL, null);
        }
コード例 #12
0
        public EmptyFrejaResponse Cancel(CancelAuthenticationRequest cancelAuthenticationRequest)
        {
            string methodUri = transactionContext == TransactionContext.ORGANISATIONAL ? MethodUrl.ORGANISATION_AUTHENTICATION_CANCEL : MethodUrl.AUTHENTICATION_CANCEL;

            return(httpService.Send <EmptyFrejaResponse>(GetUri(serverAddress, methodUri), RequestTemplate.CANCEL_AUTHENTICATION_TEMPLATE, cancelAuthenticationRequest, cancelAuthenticationRequest.RelyingPartyId));
        }