Ejemplo n.º 1
0
        public void Test_check_otp_ok_password_and_time()
        {
            // Arrange
            string test_user = "******";
            string test_pass = otpGenerator.Create();

            CleanTables();
            CreateOtp(CreateUser(test_user), test_pass, DateTime.Now);
            application.ResetRules();

            // Act
            Sleep(5000);
            bool check   = application.CheckOtp(test_user, test_pass);
            var  koRules = application.ApplicationRules.Where(r => !r.Result);

            // Assert
            Assert.IsTrue(check);
            Assert.IsTrue(koRules.Count() == 0);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Init();
            Console.Write("Insert your username to get your password: "******"Something went wrong!");
                Console.WriteLine("Reasons:");
                foreach (var rule in application.ApplicationRules.Where(r => !r.Result))
                {
                    Console.WriteLine($" - {rule.Reason.ToString()}");
                }
            }
            else
            {
                Console.WriteLine($"Your password is: {otp}");

                Console.Write("Insert you username: "******"Please type your password in 30 seconds: ");
                string checkingOtp = Console.ReadLine();
                bool   granted     = application.CheckOtp(checkingUserid, checkingOtp);
                if (granted)
                {
                    Console.WriteLine("Your access is granted!");
                }
                else
                {
                    Console.WriteLine("Access is denied!");
                    Console.WriteLine("Reasons:");
                    foreach (var rule in application.ApplicationRules.Where(r => !r.Result))
                    {
                        Console.WriteLine($" - {rule.Reason.ToString()}");
                    }
                }
            }
            Console.WriteLine();
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }