コード例 #1
0
        public void UpdateCredentials()
        {
            Assert.True(authDatabaseUtils.AddCredentials("test2", PasswordHasher.GetHash("p2")));
            Assert.True(authDatabaseUtils.UpdateCredentials("test2", PasswordHasher.GetHash("p2"), "test2", PasswordHasher.GetHash("pass2")));
            Assert.False(authDatabaseUtils.CheckCredentials("test2", PasswordHasher.GetHash("p2")));
            Assert.True(authDatabaseUtils.CheckCredentials("test2", PasswordHasher.GetHash("pass2")));

            Clear();
        }
コード例 #2
0
        public void PositiveUpdateCredentials()
        {
            string oldLogin = "******";
            string oldPass  = PasswordHasher.GetHash("test");

            string newLogin = "******";
            string newPass  = PasswordHasher.GetHash("test");

            bool result = storageDatкabaseUtils.UpdateCredentials(oldLogin, oldPass, newLogin, newPass);

            Assert.IsTrue(result);
        }
コード例 #3
0
        public void Test_UsedLogin() // 2.2
        {
            string login     = "******";
            string login2    = "someData2";
            string password  = PasswordHasher.GetHash("someMoreData");
            string password2 = PasswordHasher.GetHash("someMoreData2");

            Assert.True(db.AddCredentials(login, password));
            Assert.True(db.AddCredentials(login2, password2));
            Assert.False(db.UpdateCredentials(login, password, login2, password2));
            Assert.True(db.CheckCredentials(login, password));
            Assert.True(db.DeleteCredentials(login, password));
            Assert.True(db.DeleteCredentials(login2, password2));
        }
コード例 #4
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);
        }
コード例 #5
0
        public void TestUpdateWithAlreadyExisting()
        {
            AuthDatabaseUtils connection = new AuthDatabaseUtils(server, database, isTrusted, login1, password1, connectionTimeOut);
            bool status = connection.UpdateCredentials(login1, password1, login2, password2);

            Assert.False(status);
        }
コード例 #6
0
        public void TestGetHash_Update_in_DB()
        {
            try
            {
                const string login       = "******";
                const string password    = "******";
                const string newlogin    = "******";
                const string newpassword = "******";
                string       hash        = PasswordHasher.GetHash(password);
                string       newhash     = PasswordHasher.GetHash(newpassword);

                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.UpdateCredentials(login, hash, newlogin, newhash),
                              "Updating an existing entry is not successful");
                Assert.IsTrue(authDatabase.CheckCredentials(newlogin, newhash),
                              "After updating, the new record did not appear in the database");
                Assert.IsFalse(authDatabase.CheckCredentials(login, hash),
                               "After updating the old record is still in the database");
            }
            catch (Exception err)
            {
                Assert.Fail(err.Message);
            }
        }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: tinguen/kpi
        public void TestUpdateLogin()
        {
            string login     = "******";
            string password  = "******";
            string new_login = "******";

            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsTrue(authDatabaseUtils.UpdateCredentials(login, PasswordHasher.GetHash(password), new_login, PasswordHasher.GetHash(password)));
        }
コード例 #8
0
        public void updateNonExistant()
        {
            string login_updated = "updated";
            string pass_updated  = "some_pass";
            string start_login   = "******";
            string start_hashed  = PasswordHasher.GetHash("start_pass", start_login);
            string hashed_upd    = PasswordHasher.GetHash(pass_updated, login_updated);

            Assert.False(adu.UpdateCredentials(start_login, start_hashed, login_updated, hashed_upd));
            Assert.False(adu.CheckCredentials(login_updated, hashed_upd));
        }
コード例 #9
0
        public void UpdateCredentialsWithPasswordChangeReturnTrue()
        {
            string login       = "******";
            string password    = "******";
            string passwordNew = "password_updated";


            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsTrue(authDatabaseUtils.UpdateCredentials(login, PasswordHasher.GetHash(password),
                                                              login, PasswordHasher.GetHash(passwordNew)));
        }
コード例 #10
0
        public void UpdateCreadentialsTest()
        {
            authDatabaseUtils.AddCredentials("login", PasswordHasher.GetHash("password"));
            Assert.IsFalse(authDatabaseUtils.UpdateCredentials(
                               "login1", PasswordHasher.GetHash("password1"),
                               "login", PasswordHasher.GetHash("password")
                               ));

            Assert.IsFalse(authDatabaseUtils.UpdateCredentials(
                               "login1", PasswordHasher.GetHash("password"),
                               "login", PasswordHasher.GetHash("password")
                               ));

            Assert.IsFalse(authDatabaseUtils.UpdateCredentials(
                               "login", PasswordHasher.GetHash("password1"),
                               "login", PasswordHasher.GetHash("password")
                               ));

            Assert.IsFalse(authDatabaseUtils.UpdateCredentials(
                               "login", PasswordHasher.GetHash("password"),
                               "another login 1", PasswordHasher.GetHash("password")
                               ));

            Assert.IsFalse(authDatabaseUtils.UpdateCredentials(
                               "login", PasswordHasher.GetHash("password"),
                               "login", "password"
                               ));

            Assert.IsTrue(authDatabaseUtils.UpdateCredentials(
                              "login", PasswordHasher.GetHash("password"),
                              "login", PasswordHasher.GetHash("password")
                              ));

            Assert.IsTrue(authDatabaseUtils.UpdateCredentials(
                              "login", PasswordHasher.GetHash("password"),
                              "update", PasswordHasher.GetHash("update")
                              ));
        }
コード例 #11
0
 public void UpdateCredentials_WithExistingCredentials()
 {
     Assert.IsTrue(connection.UpdateCredentials("Mariia", PasswordHasher.GetHash("MASHA", "salt", 2), "Masha",
                                                PasswordHasher.GetHash("NewPassword", "soul", 458)));
 }
コード例 #12
0
 public void UpdateRightCredentialsTest()
 {
     Assert.IsTrue(connectionWithDB.UpdateCredentials("gerf", "  678pol[]]\\/*``ervfdsvsd;;;[]`][`][;[`:{};`][;`[]]{};`:cwrrrrrr", "gerf",
                                                      PasswordHasher.GetHash(passwordForManualUser, saltForManualUser)));
 }
コード例 #13
0
        public void UpdateCredentialsTestNull()
        {
            auth.AddCredentials("5 test login", PasswordHasher.GetHash("5 test password"));

            Assert.Throws <ArgumentNullException>(() => auth.UpdateCredentials("5 test login", PasswordHasher.GetHash("5 test password"), null, PasswordHasher.GetHash(null)));
            Assert.Throws <ArgumentNullException>(() => auth.UpdateCredentials("5 test login", PasswordHasher.GetHash("5 test password"), "5 new login", PasswordHasher.GetHash(null)));
            Assert.False(auth.UpdateCredentials("5 test login", PasswordHasher.GetHash("5 test password"), null, PasswordHasher.GetHash("5 new password")));
        }
コード例 #14
0
 public void Database_Update()
 {
     Assert.IsTrue(authDatabaseUtils.UpdateCredentials(dLogin, dPassword, newdLogin, newdPassword));
 }
コード例 #15
0
ファイル: AuthDBTest.cs プロジェクト: otschebutsch/lab4test
 public void UpdatePswdCreds()
 {
     authDatabaseUtils.AddCredentials("userup", PasswordHasher.GetHash("password"));
     Assert.True(authDatabaseUtils.UpdateCredentials("userup", PasswordHasher.GetHash("password"), "userup", PasswordHasher.GetHash("newpassword")));
 }