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); }
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)); } }
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); } }
public void CancelRequest_missingReference_expectError() { CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(""); ValidateRequest_expectError("Reference cannot be null or empty.", () => authenticationClient.Cancel(cancelAuthenticationRequest)); }