コード例 #1
0
        public void AuthDbCheckTrue(string pass, string login)
        {
            string hashed = PasswordHasher.GetHash(pass, login);

            adu.AddCredentials(login, hashed);
            Assert.True(adu.CheckCredentials(login, hashed));
        }
コード例 #2
0
        public void PositiveAddCredentials()
        {
            string hash = PasswordHasher.GetHash("test");

            bool result = storageDatкabaseUtils.AddCredentials("login", hash);

            Assert.IsTrue(result);
        }
コード例 #3
0
        public void TestAddInvalidPassword()
        {
            AuthDatabaseUtils connection = new AuthDatabaseUtils(server, database, isTrusted, login1, password1, connectionTimeOut);
            bool status = connection.AddCredentials(login1, null);

            Assert.False(status);
            status = connection.AddCredentials(login1, "");
            Assert.False(status);
        }
コード例 #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 AddCreadentialsTest()
        {
            Assert.IsTrue(authDatabaseUtils.AddCredentials("login", PasswordHasher.GetHash("password")));

            Assert.IsTrue(authDatabaseUtils.AddCredentials("another login 1", PasswordHasher.GetHash("password")));
            Assert.IsTrue(authDatabaseUtils.AddCredentials("another login 2", PasswordHasher.GetHash("pass")));
            Assert.IsTrue(authDatabaseUtils.AddCredentials("another login 3", PasswordHasher.GetHash("")));

            Assert.IsFalse(authDatabaseUtils.AddCredentials("login", PasswordHasher.GetHash("password")));
            Assert.IsFalse(authDatabaseUtils.AddCredentials("another login again", "password"));
        }
コード例 #6
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);
        }
コード例 #7
0
        public void TestGetHash_Push_to_DB_ValidFields(string login, string password, string salt = null, uint?adlerMod = null)
        {
            try
            {
                string hash = PasswordHasher.GetHash(password, salt, adlerMod);
                Assert.IsTrue(authDatabase.AddCredentials(login, hash),
                              "The system does not add a non-existent user with next input data " +
                              $"login: {login}, password: ${password}, salt: {salt}, adlerMod: ${adlerMod}");

                Assert.IsTrue(authDatabase.CheckCredentials(login, hash),
                              "There must be a user on the system with " +
                              $"login: {login}, password: ${password}");
            } catch (Exception err)
            {
                Assert.Fail(err.Message);
            }
        }
コード例 #8
0
 public void AddCredentials_WithLatinLogin()
 {
     Assert.IsTrue(connection.AddCredentials("Mariia", PasswordHasher.GetHash("MASHA", "salt", 2)));
 }
コード例 #9
0
ファイル: UnitTest1.cs プロジェクト: tinguen/kpi
        public void TestAddingCredentials()
        {
            string login    = "******";
            string password = "******";

            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
        }
コード例 #10
0
 public void Database_AddFew()
 {
     Assert.IsTrue(authDatabaseUtils.AddCredentials(dLogin, dPassword) &&
                   authDatabaseUtils.AddCredentials(newdLogin, newdPassword));
 }
コード例 #11
0
 public void InsertingCredentialsToDBTest1()
 {
     Assert.IsTrue(connectionWithDB.AddCredentials(userName1, PasswordHasher.GetHash(password1, salt1)));
 }
コード例 #12
0
 public void AddCredentialsTestParamsNull()
 {
     Assert.False(auth.AddCredentials(null, PasswordHasher.GetHash("1 test password")));
     Assert.Throws <ArgumentNullException>(() => auth.AddCredentials("1 test login", PasswordHasher.GetHash(null)));
     Assert.Throws <ArgumentNullException>(() => auth.AddCredentials(null, PasswordHasher.GetHash(null)));
 }
コード例 #13
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));
        }
コード例 #14
0
        public void AddCredentials()
        {
            Assert.True(authDatabaseUtils.AddCredentials("test1", PasswordHasher.GetHash("p1")));
            Assert.True(authDatabaseUtils.CheckCredentials("test1", PasswordHasher.GetHash("p1")));

            Clear();
        }
コード例 #15
0
        public void AddLatinCredentialsReturnsTrue()
        {
            string login    = "******";
            string password = "******";

            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
        }
コード例 #16
0
ファイル: AuthDBTest.cs プロジェクト: otschebutsch/lab4test
        public void AddNormalCreds()
        {
            string login    = "******";
            string password = PasswordHasher.GetHash("password");

            Assert.True(authDatabaseUtils.AddCredentials(login, password));
        }