Exemplo n.º 1
0
        public void Test_create_otp_new()
        {
            // Arrange
            CleanTables();
            application.ResetRules();
            string test_user = "******";

            // Act
            string password = application.CreateOtp(test_user);
            var    koRules  = application.ApplicationRules.Where(r => !r.Result);

            // Assert
            Assert.IsNotNull(password);
            Assert.IsTrue(koRules.Count() == 0);
        }
Exemplo 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();
        }