public async Task ProcessResponse_PasswordAcceptedAfterUserNameInInitialRequest() { TestMocks mocks = new TestMocks(); mocks.ServerBehaviour.Setup(sb => sb.ValidateAuthenticationCredentials(It.IsAny <IConnection>(), It.IsAny <IAuthenticationCredentials>())).Returns(Task.FromResult(AuthenticationResult.Success)); LoginMechanismProcessor processor = this.Setup(mocks); AuthMechanismProcessorStatus result = await processor.ProcessResponse(EncodeBase64("rob")).ConfigureAwait(false); Assert.Equal(AuthMechanismProcessorStatus.Continue, result); mocks.Connection.Verify(c => c.WriteResponse( It.Is <SmtpResponse>(r => VerifyBase64Response(r.Message, "Password:"******"password")).ConfigureAwait(false); Assert.Equal(AuthMechanismProcessorStatus.Success, result); }
public void ProcessResponse_Response_BadBase64() { Mocks mocks = new Mocks(); LoginMechanismProcessor processor = Setup(mocks); processor.ProcessResponse(null); processor.ProcessResponse("rob blah"); }
public async Task ProcessResponse_Response_BadBase64() { await Assert.ThrowsAsync <BadBase64Exception>(async() => { Mocks mocks = new Mocks(); LoginMechanismProcessor processor = Setup(mocks); await processor.ProcessResponseAsync(null); await processor.ProcessResponseAsync("rob blah"); }); }
public async Task ProcessResponse_Response_BadBase64() { await Assert.ThrowsAsync <BadBase64Exception>(async() => { TestMocks mocks = new TestMocks(); LoginMechanismProcessor processor = this.Setup(mocks); await processor.ProcessResponse(null).ConfigureAwait(false); await processor.ProcessResponse("rob blah").ConfigureAwait(false); }).ConfigureAwait(false); }
public void ProcessRepsonse_NoUsername_GetUsernameChallenge() { Mocks mocks = new Mocks(); LoginMechanismProcessor processor = Setup(mocks); AuthMechanismProcessorStatus result = processor.ProcessResponse(null); Assert.AreEqual(AuthMechanismProcessorStatus.Continue, result); mocks.Connection.Verify(c => c.WriteResponse( It.Is <SmtpResponse>(r => r.Code == (int)StandardSmtpResponseCode.AuthenticationContinue && VerifyBase64Response(r.Message, "Username:") ) ) ); }
public async Task ProcessRepsonse_NoUsername_GetUsernameChallenge() { TestMocks mocks = new TestMocks(); LoginMechanismProcessor processor = this.Setup(mocks); AuthMechanismProcessorStatus result = await processor.ProcessResponse(null).ConfigureAwait(false); Assert.Equal(AuthMechanismProcessorStatus.Continue, result); mocks.Connection.Verify(c => c.WriteResponse( It.Is <SmtpResponse>(r => r.Code == (int)StandardSmtpResponseCode.AuthenticationContinue && VerifyBase64Response(r.Message, "Username:") ) ) ); }
public async Task ProcessRepsonse_Username_GetPasswordChallenge() { Mocks mocks = new Mocks(); LoginMechanismProcessor processor = Setup(mocks); AuthMechanismProcessorStatus result = await processor.ProcessResponseAsync(EncodeBase64("rob")); Assert.Equal(AuthMechanismProcessorStatus.Continue, result); mocks.Connection.Verify(c => c.WriteResponseAsync( It.Is <SmtpResponse>(r => VerifyBase64Response(r.Message, "Password:") && r.Code == (int)StandardSmtpResponseCode.AuthenticationContinue ) ) ); }
public async Task ProcessResponse_PasswordAcceptedAfterUserNameInInitialRequest() { Mocks mocks = new Mocks(); LoginMechanismProcessor processor = Setup(mocks); AuthMechanismProcessorStatus result = await processor.ProcessResponseAsync(EncodeBase64("rob")); Assert.Equal(AuthMechanismProcessorStatus.Continue, result); mocks.Connection.Verify(c => c.WriteResponseAsync( It.Is <SmtpResponse>(r => VerifyBase64Response(r.Message, "Password:"******"password")); Assert.Equal(AuthMechanismProcessorStatus.Success, result); }