Esempio n. 1
0
        public void DeleteCredentials()
        {
            Assert.True(authDatabaseUtils.AddCredentials("test3", PasswordHasher.GetHash("p3")));
            Assert.True(authDatabaseUtils.DeleteCredentials("test3", PasswordHasher.GetHash("p3")));

            Clear();
        }
        public void DeleteCreadentialsTest()
        {
            Assert.IsTrue(authDatabaseUtils.DeleteCredentials("login", PasswordHasher.GetHash("password")));
            Assert.IsTrue(authDatabaseUtils.DeleteCredentials("login", PasswordHasher.GetHash("password")));

            Assert.IsTrue(authDatabaseUtils.DeleteCredentials("another login 1", PasswordHasher.GetHash("password password")));
            Assert.IsTrue(authDatabaseUtils.DeleteCredentials("another login 5", PasswordHasher.GetHash("pass")));
        }
        public void CheckCredentialsTestNull()
        {
            auth.AddCredentials("12 test login", PasswordHasher.GetHash("12 test password"));

            Assert.Throws <ArgumentNullException>(() => auth.DeleteCredentials(null, PasswordHasher.GetHash(null)));
            Assert.Throws <ArgumentNullException>(() => auth.DeleteCredentials("12 test login", PasswordHasher.GetHash(null)));
            Assert.False(auth.CheckCredentials(null, PasswordHasher.GetHash("12 test password")));
        }
Esempio n. 4
0
        public void Test_TypicalData()
        {
            string login    = "******";
            string password = PasswordHasher.GetHash("usualPassword");

            Assert.True(db.AddCredentials(login, password));
            Assert.True(db.CheckCredentials(login, password));
            Assert.True(db.DeleteCredentials(login, password));
        }
Esempio n. 5
0
        public void TestDeleteCredentials()
        {
            string login    = "******";
            string password = "******";

            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsTrue(authDatabaseUtils.DeleteCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsFalse(authDatabaseUtils.CheckCredentials(login, PasswordHasher.GetHash(password)));
        }
        public void DeleteExistingCredentialsTestReturnsTrue()
        {
            string login    = "******";
            string password = "******";

            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsTrue(authDatabaseUtils.DeleteCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsFalse(authDatabaseUtils.CheckCredentials(login, PasswordHasher.GetHash(password)));
        }
Esempio n. 7
0
        public void PositivedDeleteCredentials()
        {
            string oldLogin = "******";
            string oldPass  = PasswordHasher.GetHash("test");

            bool result = storageDatкabaseUtils.DeleteCredentials(oldLogin, oldPass);

            Assert.IsTrue(result);
        }
Esempio n. 8
0
        public void DeleteEntry()
        {
            string login  = "******";
            string pass   = "******";
            string hashed = PasswordHasher.GetHash(pass, login);

            adu.AddCredentials(login, hashed);
            Assert.True(adu.CheckCredentials(login, hashed), "Add check");
            adu.DeleteCredentials(login, hashed);
            Assert.False(adu.CheckCredentials(login, hashed), "Delete check");
        }
Esempio n. 9
0
        public void TestSuccessfulCase()
        {
            string password1Hashed = PasswordHasher.GetHash(password1);
            string password2Hashed = PasswordHasher.GetHash(password2);
            string password3Hashed = PasswordHasher.GetHash(password3);
            bool   status;

            // 1. Check if password hashes the same way
            Assert.Equal(password1Hashed, PasswordHasher.GetHash(password1));
            AuthDatabaseUtils connection = new AuthDatabaseUtils(server, database, isTrusted, login1, password1, connectionTimeOut);

            status = connection.AddCredentials(login2, password2Hashed);
            // 2. Check status of adding credentials
            Assert.True(status);
            status = connection.CheckCredentials(login2, password2Hashed);
            // 3. Check if credentials were saved
            Assert.True(status);
            status = connection.UpdateCredentials(login2, password2Hashed, login3, password3Hashed);
            // 4. Check status
            Assert.True(status);
            status = connection.CheckCredentials(login3, password3Hashed);
            // 5. Check if credentials were updated
            Assert.True(status);
            status = connection.DeleteCredentials(login3, password3Hashed);
            // 6. Check status
            Assert.True(status);
            status = connection.CheckCredentials(login3, password3Hashed);
            // 7. Check if credentials were deleted
            Assert.False(status);
        }
Esempio n. 10
0
        public void TestDeleteNotExisting()
        {
            AuthDatabaseUtils connection = new AuthDatabaseUtils(server, database, isTrusted, login1, password1, connectionTimeOut);
            bool status = connection.DeleteCredentials(login1, password1);

            Assert.False(status);
        }
Esempio n. 11
0
        public void TestAddNotHashedPassword()
        {
            AuthDatabaseUtils connection = new AuthDatabaseUtils(server, database, isTrusted, login1, password1, connectionTimeOut);
            bool status = connection.AddCredentials(login1, password1);

            Assert.False(status);
            status = connection.DeleteCredentials(login1, password1);
            Assert.True(status);
            string longString = "";

            for (int i = 0; i < 1000; i++)
            {
                longString += "a";
            }
            status = connection.AddCredentials(login1, longString);
            if (status)
            {
                status = connection.DeleteCredentials(login1, longString);
                Assert.True(status);
            }
            Assert.False(status);
        }
Esempio n. 12
0
        public void TestGetHash_Deleting_From_DB()
        {
            try
            {
                const string login    = "******";
                const string password = "******";
                string       hash     = PasswordHasher.GetHash(password);

                Assert.IsTrue(authDatabase.AddCredentials(login, hash),
                              "The system does not add a non-existent user with next input data " +
                              $"login: {login}, password: ${password}");

                Assert.IsTrue(authDatabase.DeleteCredentials(login, hash),
                              "Deleting an existing entry is not successful");

                Assert.IsFalse(authDatabase.CheckCredentials(login, hash),
                               "After deletion the record is still in the database");
            }
            catch (Exception err)
            {
                Assert.Fail(err.Message);
            }
        }
Esempio n. 13
0
 public void DeleteCredentials_WithExistingCredentials()
 {
     Assert.IsTrue(connection.DeleteCredentials("Masha", PasswordHasher.GetHash("NewPassword", "soul", 458)));
 }
Esempio n. 14
0
 public void Database_DeleteOneFromFew()
 {
     Assert.IsTrue(authDatabaseUtils.DeleteCredentials(dLogin, dPassword));
 }
Esempio n. 15
0
 public void DeleteCredentialsTest()
 {
     Assert.IsTrue(connectionWithDB.DeleteCredentials(userName1, PasswordHasher.GetHash(password1, salt1)));
 }
Esempio n. 16
0
 public void Database_Delete()
 {
     Assert.IsTrue(authDatabaseUtils.DeleteCredentials(newdLogin, newdPassword));
 }
Esempio n. 17
0
 public void DeleteWrongPswdCreds()
 {
     Assert.False(authDatabaseUtils.DeleteCredentials("user", PasswordHasher.GetHash("notpassword")));
 }