コード例 #1
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);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: tinguen/kpi
        public void TestCheckCredentials()
        {
            string login    = "******";
            string password = "******";

            Assert.IsTrue(authDatabaseUtils.AddCredentials(login, PasswordHasher.GetHash(password)));
            Assert.IsTrue(authDatabaseUtils.CheckCredentials(login, PasswordHasher.GetHash(password)));
        }
コード例 #3
0
        public void CheckValidCredentialsReturnsTrue()
        {
            string login    = "******";
            string password = "******";

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

            authDatabaseUtils.AddCredentials(login, password);
            Assert.True(authDatabaseUtils.CheckCredentials(login, password));
        }
コード例 #5
0
        public void PositiveCheckCredentials()
        {
            string oldLogin = "******";
            string oldPass  = PasswordHasher.GetHash("test");

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

            Assert.IsTrue(result);
        }
コード例 #6
0
 public void Database_CheckFew()
 {
     /*bool res;
      * bool res2 = authDatabaseUtils.CheckCredentials(dLogin, dPassword);
      * bool res1 = authDatabaseUtils.CheckCredentials(newdLogin, newdPassword);
      *
      * if (res1 == true && res2 == true)
      *  res = true;
      * else
      *  res = false;*/
     Assert.IsTrue(authDatabaseUtils.CheckCredentials(dLogin, dPassword) &&
                   authDatabaseUtils.CheckCredentials(newdLogin, newdPassword));
 }
コード例 #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 AuthDbCheckTrue(string pass, string login)
        {
            string hashed = PasswordHasher.GetHash(pass, login);

            adu.AddCredentials(login, hashed);
            Assert.True(adu.CheckCredentials(login, hashed));
        }
コード例 #9
0
        public void CheckCreadentialsTest()
        {
            Assert.IsTrue(authDatabaseUtils.CheckCredentials("login", PasswordHasher.GetHash("password")));

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

            Assert.IsFalse(authDatabaseUtils.CheckCredentials("another login 1", PasswordHasher.GetHash("password password")));
            Assert.IsFalse(authDatabaseUtils.CheckCredentials("another login 5", PasswordHasher.GetHash("pass")));
        }
コード例 #10
0
 public void CheckCredentials_WithRightCredentials()
 {
     Assert.IsTrue(connection.CheckCredentials("Mariia", PasswordHasher.GetHash("MASHA", "salt", 2)));
 }
コード例 #11
0
 public void CheckRightCredentialsTest()
 {
     Assert.IsTrue(connectionWithDB.CheckCredentials(userName1, PasswordHasher.GetHash(password1, salt1)));
     Assert.IsTrue(connectionWithDB.CheckCredentials(userName4, PasswordHasher.GetHash(password4, salt4)));
 }
コード例 #12
0
        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")));
        }
コード例 #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 CheckNonExistingCredentials()
 {
     Assert.False(authDatabaseUtils.CheckCredentials("test", PasswordHasher.GetHash("p")));
 }
コード例 #15
0
 public void Database_Check()
 {
     Assert.IsTrue(authDatabaseUtils.CheckCredentials(dLogin, dPassword));
 }