public void AuthenticatorSendsDetailsToHello() { WampClientPlayground playground = new WampClientPlayground(); CustomAuthenticator authenticator = new CustomAuthenticator { AuthenticationId = "peter", AuthenticationMethods = new string[] { "ticket" } }; HelloMock mock = new HelloMock(); JTokenJsonBinding jsonBinding = new JTokenJsonBinding(); IWampChannel channel = playground.GetChannel (mock, "realm1", jsonBinding, authenticator); channel.Open(); IDictionary <string, ISerializedValue> deserializedDetails = mock.Details.OriginalValue.Deserialize <IDictionary <string, ISerializedValue> > (); Assert.That(deserializedDetails["authmethods"].Deserialize <string[]>(), Is.EquivalentTo(authenticator.AuthenticationMethods)); Assert.That(deserializedDetails["authid"].Deserialize <string>(), Is.EquivalentTo(authenticator.AuthenticationId)); }
public void AuthenticatorAuthenticateResultCallsAuthenticate() { WampClientPlayground playground = new WampClientPlayground(); CustomAuthenticator authenticator = new CustomAuthenticator (delegate { return(new AuthenticationResponse() { Extra = new MyAuthenticateExtraData() { Secret1 = 3 }, Signature = "secretsignature" }); }) { AuthenticationId = "peter", AuthenticationMethods = new string[] { "ticket" } }; AuthenticateMock mock = new AuthenticateMock("ticket"); JTokenJsonBinding jsonBinding = new JTokenJsonBinding(); IWampChannel channel = playground.GetChannel (mock, "realm1", jsonBinding, authenticator); channel.Open(); Assert.That(mock.Signature, Is.EqualTo("secretsignature")); IDictionary <string, ISerializedValue> deserializedExtra = mock.Extra.OriginalValue.Deserialize <IDictionary <string, ISerializedValue> >(); Assert.That(deserializedExtra["secret1"].Deserialize <int>(), Is.EqualTo(3)); }
public void AuthenticatorAuthenticateExceptionCallsAbort() { WampClientPlayground playground = new WampClientPlayground(); MyAbortDetails myAbortDetails = new MyAbortDetails() { Message = "My message", User = "******" }; CustomAuthenticator authenticator = new CustomAuthenticator (delegate { throw new WampAuthenticationException(myAbortDetails, "some reason"); }) { AuthenticationId = "peter", AuthenticationMethods = new string[] { "ticket" } }; AbortMock mock = new AbortMock("ticket"); JTokenJsonBinding jsonBinding = new JTokenJsonBinding(); IWampChannel channel = playground.GetChannel (mock, "realm1", jsonBinding, authenticator); channel.Open(); Assert.That(mock.Reason, Is.EqualTo("some reason")); MyAbortDetails deserializedDetails = mock.Details.OriginalValue.Deserialize <MyAbortDetails>(); Assert.That(deserializedDetails, Is.EqualTo(myAbortDetails)); }
public void AuthenticatorGetsChallengeMessage() { WampClientPlayground playground = new WampClientPlayground(); CustomAuthenticator authenticator = new CustomAuthenticator { AuthenticationId = "peter", AuthenticationMethods = new string[] { "ticket" } }; MyChallengeDetails myChallengeDetails = new MyChallengeDetails() { MyNumber = 3 }; ChallengeMock mock = new ChallengeMock("ticket", myChallengeDetails); JTokenJsonBinding jsonBinding = new JTokenJsonBinding(); IWampChannel channel = playground.GetChannel (mock, "realm1", jsonBinding, authenticator); channel.Open(); Assert.That(authenticator.AuthMethod, Is.EqualTo("ticket")); Assert.That(authenticator.Extra.OriginalValue.Deserialize <MyChallengeDetails>(), Is.EqualTo(myChallengeDetails)); }