public void TestMethod1() { Employe employe = new Employe(); AuthentificationController authentifcationController = new AuthentificationController(); employe.Username = "******"; employe.Password = "******"; employe.ConfirmPassword = "******"; employe.RoleId = 1; Assert.AreEqual(authentifcationController.IsValid(employe), true); }
public static ServerStartStatus Start(HttpServerConfiguration <TAccount> configuration) { if (_started) { LogMessage(LogLevel.Warning, "Server is already running"); return(ServerStartStatus.AlreadyStarted); } lock (OperationLock) { if (_operationInProgress) { LogMessage(LogLevel.Info, "Cannot start now, operation in progress"); return(ServerStartStatus.AlreadyStarted); } _operationInProgress = true; } if (configuration == null || !configuration.IsEnough()) { return(ServerStartStatus.BadParameters); } DebugLogsEnabled = configuration.DebugLogsEnabled; RequestTracingEnabled = configuration.RequestTracingEnabled; try { PrepareStatistics(configuration); _optionsController = new OptionsController <TAccount>(InnerRequestProcessors); _pingController = new PingController(); _configurationController = new ConfigurationController <TAccount>(configuration); Protocol = configuration.Protocol; _authorizer = configuration.Authorizer; _authentificationController = new AuthentificationController(configuration.Authentificator); ConfigureResponseBuilding(configuration); if (configuration.FilesEnabled) { if (!StartFileProcessing(configuration)) { return(ServerStartStatus.BadParameters); } } _requestMaxServeTime = configuration.RequestMaxServeTime; if (Protocol == Protocol.Https) { if (!BindCertificate(configuration)) { LogMessage(LogLevel.Warning, "Binding failed"); return(ServerStartStatus.BindingError); } } StartListenerThread(configuration); StartServices(configuration); _started = true; return(ServerStartStatus.Ok); } catch (SocketException) { LogMessage(LogLevel.Critical, $"Error binding to port {configuration.Port}. Is it in use?"); _fileRequestController?.Stop(); return(ServerStartStatus.BindingError); } catch (Exception ex) { LogException(LogLevel.Critical, ex); _fileRequestController?.Stop(); return(ServerStartStatus.UnknownError); } finally { lock (OperationLock) { _operationInProgress = false; } } }
private void btnConnexion_Click(object sender, EventArgs e) { try {//Authentification Personnel if (radioPersonnel.Checked && !radioResponsable.Checked) { //validation des champs bool etat; AuthentificationController.ValiderChamps(ref txtLogin, ref txtPasse, out etat); //si y'as des erreurs on est besoin de faire quitter la procedure if (etat == false) { return; } //Obtenir la valuer de la zone login Login = txtLogin.Text; //authentification Models.Authentification login = new Models.Authentification(txtLogin.Text, txtPasse.Text, "Personnel"); //validation des champs if (Models.Authentification.num >= 1) { //fermer le formulaire d'authentification pour ne pas chargé la ram this.Close(); //ouvrire le nouveau formulaire Thread thread = new Thread(TableauBordPersonnel); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } else { MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Compte invalide."); message.ShowDialog(); } } else if (!radioPersonnel.Checked && radioResponsable.Checked) { //validation des champs bool etat; AuthentificationController.ValiderChamps(ref txtLogin, ref txtPasse, out etat); //si y'as des erreurs on est besoin de faire quitter la procedure if (etat == false) { return; } //Obtenir la valuer de la zone login Login = txtLogin.Text; //authentification Models.Authentification login = new Models.Authentification(txtLogin.Text, txtPasse.Text, "Responsable"); //validation des champs if (Models.Authentification.num >= 1) { //fermer le formulaire d'authentification pour ne pas chargé la ram this.Close(); //ouvrire le nouveau formulaire Thread thread = new Thread(TableauBordResponsable); thread.SetApartmentState(ApartmentState.STA); thread.Start(); } else { MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Compte invalide."); message.ShowDialog(); } } else { MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", "Choisir un radion bouton."); message.ShowDialog(); return; } } catch (Exception ex) { MyMessageBox.MyMessageBox message = new MyMessageBox.MyMessageBox("Erreur", ex.Message); message.ShowDialog(); } }