public void Create_IfServiceForAuthMethodExists_ReturnsService(AuthenticationMethod authMethod, Type expectedType) { var context = new ApiContext(It.IsAny <Environments>()) { AuthenticationMethod = authMethod }; var service = AuthenticationServiceFactory.Create(context, It.IsAny <string>(), It.IsAny <string>()); Assert.IsInstanceOf(expectedType, service); }
Create_IfServiceForAuthMethodDoesNotExist_ThrowsNotImplementedException(AuthenticationMethod authMethod) { var context = new ApiContext(It.IsAny <Environments>()) { AuthenticationMethod = authMethod }; Assert.Throws <NotImplementedException>(() => { AuthenticationServiceFactory.Create(context, It.IsAny <string>(), It.IsAny <string>()); }); }
/// <inheritdoc /> public IAuthenticationService GetAuthenticationService(ApiContext context) { const string standardLoginEndpoint = "login"; try { return(AuthenticationServiceFactory.Create(context, Host, standardLoginEndpoint)); } catch (NotImplementedException) { return(null); } }
public void EfetuarLoginObterUsuarioLogado() { AuthenticationServiceFactory.SetCurrent(new FormsAuthenticationFactory()); authenticationService = AuthenticationServiceFactory.Create(); var serializeModel = new CustomPrincipalSerializeModel(); serializeModel.Id = 1; serializeModel.Nome = "Wilson Marques"; serializeModel.Login = "******"; serializeModel.Roles = new string[] { "Gerente", "Coordenador", "Administrador" }; var serializer = new JavaScriptSerializer(); var userData = serializer.Serialize(serializeModel); authenticationService.Login(serializeModel.Nome, true, userData, 20); authenticationService.PostAuthenticateRequest(); var user = authenticationService.GetUser(); Assert.IsNotNull(user); Assert.IsInstanceOfType(user, typeof(CustomPrincipal)); Assert.AreEqual("wilson", user.Login); Assert.IsTrue(user.IsInRole("Gerente")); }
protected AbstractAuthenticationController() { _authService = AuthenticationServiceFactory.Create(); }
public void Logout() { AuthenticationServiceFactory.Create().Logout(); GravarLogAcesso(UsuarioLogado.HostName, UsuarioLogado.Login, "OUT"); }
protected void Application_PostAuthenticateRequest(Object sender, EventArgs e) { AuthenticationServiceFactory.Create().PostAuthenticateRequest(); }