private static void CreateAppleTestAccountIfNeeded(UnityContainer container, ICommandBus commandBus)
        {
            var accountDao = container.Resolve <IAccountDao>();

            if (accountDao.FindByEmail("*****@*****.**") != null)
            {
                //Account is already present.
                return;
            }

            Console.WriteLine(@"Registering test account for Apple");
            //Register normal account
            var registerAccountCommand = new RegisterAccount
            {
                Id        = Guid.NewGuid(),
                AccountId = Guid.NewGuid(),
                Email     = "*****@*****.**",
                Name      = "John Doe",
                Country   = new CountryISOCode("CA"),
                Phone     = "6132875020",
                Password  = "******"
            };

            var confirmationToken = Guid.NewGuid();

            registerAccountCommand.ConfimationToken = confirmationToken.ToString();

            commandBus.Send(registerAccountCommand);

            commandBus.Send(new ConfirmAccount
            {
                AccountId        = registerAccountCommand.AccountId,
                ConfimationToken = registerAccountCommand.ConfimationToken
            });
        }
        private static void CreateDefaultAccounts(UnityContainer container, ICommandBus commandBus)
        {
            Console.WriteLine("Register normal account...");
            //Register normal account
            var registerAccountCommand = new RegisterAccount
            {
                Id        = Guid.NewGuid(),
                AccountId = Guid.NewGuid(),
                Email     = "*****@*****.**",
                Name      = "John Doe",
                Country   = new CountryISOCode("CA"),
                Phone     = "6132875020",
                Password  = "******"
            };

            var confirmationToken = Guid.NewGuid();

            registerAccountCommand.ConfimationToken = confirmationToken.ToString();

            commandBus.Send(registerAccountCommand);

            commandBus.Send(new ConfirmAccount
            {
                AccountId        = registerAccountCommand.AccountId,
                ConfimationToken = registerAccountCommand.ConfimationToken
            });

            //Register admin account
            Console.WriteLine("Register admin account...");
            var registerAdminAccountCommand = new RegisterAccount
            {
                Id        = Guid.NewGuid(),
                AccountId = Guid.NewGuid(),
                Email     = "*****@*****.**",
                Name      = "Administrator",
                Country   = new CountryISOCode("CA"),
                Phone     = "6132875020",
                Password  = "******", //TODO MKTAXI-3573: Super admin password should be customizable
                IsAdmin   = true
            };

            var confirmationAdminToken = Guid.NewGuid();

            registerAdminAccountCommand.ConfimationToken = confirmationAdminToken.ToString();

            commandBus.Send(registerAdminAccountCommand);
            commandBus.Send(new UpdateRoleToUserAccount
            {
                AccountId = registerAdminAccountCommand.AccountId,
                RoleName  = RoleName.SuperAdmin,
            });

            commandBus.Send(new ConfirmAccount
            {
                AccountId        = registerAdminAccountCommand.AccountId,
                ConfimationToken = registerAdminAccountCommand.ConfimationToken
            });
        }
        public object Get(TestOnlyReqGetAdminTestAccount request)
        {
            //This method can only be used for unit test.
            if ((RequestContext.EndpointAttributes & EndpointAttributes.Localhost) != EndpointAttributes.Localhost)
            {
                throw HttpError.NotFound("This method can only be called from the server");
            }

            var testEmail = String.Format(TestUserEmail, request.Index);

            var testAccount = _dao.FindByEmail(testEmail);

            if (testAccount != null)
            {
                return(testAccount);
            }

            var command = new RegisterAccount
            {
                AccountId        = Guid.NewGuid(),
                Email            = testEmail,
                Password         = TestUserPassword,
                Name             = "Test",
                Phone            = "5141234567",
                Country          = new CountryISOCode("CA"),
                ConfimationToken = Guid.NewGuid().ToString("N"),
                Language         = "en",
                IsAdmin          = true
            };

            _commandBus.Send(command);

            Thread.Sleep(400);
            // Confirm account immediately
            _commandBus.Send(new ConfirmAccount
            {
                AccountId        = command.AccountId,
                ConfimationToken = command.ConfimationToken
            });

            _commandBus.Send(new AddOrUpdateCreditCard
            {
                AccountId         = command.AccountId,
                CreditCardCompany = "Visa",
                CreditCardId      = Guid.NewGuid(),
                ExpirationMonth   = DateTime.Now.AddYears(1).ToString("MM"),
                ExpirationYear    = DateTime.Now.AddYears(1).ToString("yy"),
                Last4Digits       = "1234",
                NameOnCard        = "test test",
                Token             = "123456",
                Label             = CreditCardLabelConstants.Personal.ToString()
            });

            return(_dao.FindByEmail(testEmail));
        }
Exemple #4
0
        public object Get(TestOnlyReqGetTestAccount request)
        {
            //This method can only be used for unit test.
            if ((RequestContext.EndpointAttributes & EndpointAttributes.Localhost) != EndpointAttributes.Localhost)
            {
                throw HttpError.NotFound("This method can only be called from the server");
            }

            var testEmail   = String.Format(TestUserEmail, request.Index);
            var testAccount = _dao.FindByEmail(testEmail);

            if (testAccount != null)
            {
                return(testAccount);
            }

            var accountId = Guid.NewGuid();

            var command = new RegisterAccount
            {
                AccountId        = accountId,
                Email            = testEmail,
                Password         = TestUserPassword,
                Name             = "Test",
                Phone            = "5144567890",
                Country          = new CountryISOCode("CA"),
                ConfimationToken = accountId.ToString("N"),
                Language         = "en",
                IsAdmin          = false
            };

            _commandBus.Send(command);

            Thread.Sleep(400);
            // Confirm account immediately
            _commandBus.Send(new ConfirmAccount
            {
                AccountId        = command.AccountId,
                ConfimationToken = command.ConfimationToken
            });

            return(_dao.FindByEmail(testEmail));
        }