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 CancelAuth_sendRequestWithoutRelyingPartyId_success() { CancelAuthenticationRequest cancelRequest = CancelAuthenticationRequest.Create(REFERENCE); SendAndValidateCancelRequest(cancelRequest); }
public void CancelRequest_relyingPartyIdEmpty_expectError() { CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(REFERENCE, ""); ValidateRequest_expectError("RelyingPartyId cannot be empty.", () => authenticationClient.Cancel(cancelAuthenticationRequest)); }
public void CancelRequest_referenceNull_expectError() { CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(null); ValidateRequest_expectError("Reference cannot be null or empty.", () => authenticationClient.Cancel(cancelAuthenticationRequest)); }
public void Cancel(CancelAuthenticationRequest cancelAuthenticationRequest) { RequestValidationService.ValidateCancelRequest(cancelAuthenticationRequest); authenticationService.Cancel(cancelAuthenticationRequest); }
public static void ValidateCancelRequest(CancelAuthenticationRequest cancelRequest) { ValidateRequest(cancelRequest); ValidateReference(cancelRequest.AuthRef); ValidateRelyingPartyIdIsEmpty(cancelRequest.RelyingPartyId); }
public void OrganisationlContext_success() { CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE, CommonTestData.RELYING_PARTY_ID); CancelAuthentication(cancelAuthenticationRequest, TransactionContext.ORGANISATIONAL, CommonTestData.RELYING_PARTY_ID); }
public void PersonalContext_success() { CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE, CommonTestData.RELYING_PARTY_ID); CancelAuthentication(cancelAuthenticationRequest, TransactionContext.PERSONAL, CommonTestData.RELYING_PARTY_ID); }
public void RelyingPartyIdNull_success() { CancelAuthenticationRequest cancelAuthenticationRequest = CancelAuthenticationRequest.Create(CommonTestData.REFERENCE); CancelAuthentication(cancelAuthenticationRequest, TransactionContext.PERSONAL, null); }
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)); }