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 OnClick_CreateAccount() { m_CanvasGroup.interactable = false; // Request new account CustomAuthenticator authenticator = new CustomAuthenticator(AppController.appService); authenticator.CreateAccount(OnCreateAccountResponse, m_InputEmail.text, m_InputUserName.text, m_InputDisplayName.text, m_InputPassword.text, Application.version); }
private void OnForgotPasswordResponse(string userInput) { if (string.IsNullOrEmpty(userInput)) { m_LoginCanvasGroup.interactable = true; return; } // Reset password CustomAuthenticator authenticator = new CustomAuthenticator(AppController.appService); authenticator.RequestPasswordReset(OnPasswordRequestResponse, userInput); }
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)); }
/// <summary> /// Executes log in for the specified user. /// </summary> /// <param name="cb">The result of the web request.</param> /// <param name="userName">The username of the account to log into.</param> /// <param name="password">The password of the account to log into, or "TOKEN" to use "remember me".</param> /// <param name="gameVersion">The version of the application.</param> /// <param name="shouldRememberMe">Should this user be able to log in without a password next time.</param> /// <param name="adminOverride">Allow login while in maintenance mode. User must be an admin.</param> public static void Login(LoginCallback cb, string userName, string password, string gameVersion, bool shouldRememberMe, bool adminOverride = false) { if (m_Instance == null) { throw new System.NullReferenceException("AppService has not been instantiated on the scene!"); } CustomAuthenticator authenticator = new CustomAuthenticator(appService); // "TOKEN" is safe to use since real passwords must be at least 8 characters. if (password == "TOKEN") { authenticator.LoginRememberMe((LoginResponse r, ErrorResponse e) => OnLoginResponse(cb, r, e), userName, gameVersion, shouldRememberMe, adminOverride); } else { authenticator.Login((LoginResponse r, ErrorResponse e) => OnLoginResponse(cb, r, e), userName, password, gameVersion, shouldRememberMe, adminOverride); } }
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)); }