public void IsValidToAddNewTestIsGood()
        {
            Connection connection = new Connection();
            bool       isValid    = ValidatorUtils.IsValidToAddNew("newUser", "123456", "123456", ref connection);

            Assert.IsTrue(isValid);
        }
        public void IsValidToAddNewTestWithAlreadyTakenName()
        {
            Connection connection = new Connection();
            bool       isValid    = ValidatorUtils.IsValidToAddNew("test", "123456", "123456", ref connection);

            Assert.IsFalse(isValid);
        }
Exemple #3
0
        /// <summary>
        /// When user clicks on save secret
        /// </summary>
        /// <param name="sender">System.Windows.Forms.Button</param>
        /// <param name="e">System.Windows.Forms.MouseEventArgs</param>
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            if (ValidatorUtils.IsValidToAddNew(NameTextBox.Text, PasswordTextBox.Text, ConfirmPassTextBox.Text, ref connection) &&
                connection.AddNewSecretPassword(authentifiedUser.Id, NameTextBox.Text, PasswordTextBox.Text))
            {
                MessageBox.Show("Secret ajouté avec succés.", "Secret ajouté", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NameTextBox.Text = "";
            }
            else
            {
                MessageBox.Show("Impossible d'ajouter le secret.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            PasswordTextBox.Text    = "";
            ConfirmPassTextBox.Text = "";
        }
Exemple #4
0
 /// <summary>
 /// When admin clicks on add button
 /// </summary>
 /// <param name="sender">System.Windows.Forms.Button</param>
 /// <param name="e">System.Windows.Forms.MouseEventArgs</param>
 private void AddBtn_Click(object sender, EventArgs e)
 {
     if (ValidatorUtils.IsValidToAddNew(NameTextBox.Text, PasswordTextBox.Text, ConfirmPassTextBox.Text, ref connection) &&
         connection.InsertNewUser(NameTextBox.Text, PasswordTextBox.Text) == 1 &&
         connection.InsertNewImage(NameTextBox.Text, PasswordTextBox.Text) == 1 &&
         connection.InsertNewLog(NameTextBox.Text, PasswordTextBox.Text) == 1)
     {
         MessageBox.Show("L'utilisateur correctement ajouté.",
                         "Utilisateur créé",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Impossible de créer l'utilisateur.\n"
                         + "Le nom doit être unique, le nom et le mot de passe "
                         + "doivent contenir plus de "
                         + Properties.Settings.Default.AuthMinSize,
                         "Erreur",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }