예제 #1
0
        public async void Can_get_player_profile()
        {
            // Arrange
            await PlayerWebservice.Login(new LoginRequest
            {
                Username       = _registrationData.Username,
                Password       = _registrationData.Password,
                BrandId        = new Guid("00000000-0000-0000-0000-000000000138"),
                IPAddress      = "::1",
                RequestHeaders = new Dictionary <string, string>()
            });

            // Act
            var result = await PlayerWebservice.ProfileAsync();

            // Assert
            Assert.AreEqual(_registrationData.IpAddress, result.IpAddress);
            Assert.AreEqual(_registrationData.DomainName, result.DomainName);
            Assert.AreEqual(_registrationData.Username, result.Username);
            Assert.AreEqual(_registrationData.FirstName, result.FirstName);
            Assert.AreEqual(_registrationData.LastName, result.LastName);
            Assert.AreEqual(_registrationData.MailingAddressLine1, result.MailingAddressLine1);
            Assert.AreEqual(_registrationData.MailingAddressPostalCode, result.MailingAddressPostalCode);
            Assert.AreEqual(_registrationData.CountryCode, result.CountryCode);
            Assert.AreEqual(_registrationData.CurrencyCode, result.CurrencyCode);
            Assert.AreEqual(_registrationData.Email, result.Email);
            Assert.AreEqual(_registrationData.PhoneNumber, result.PhoneNumber);
            Assert.AreEqual(_registrationData.DateOfBirth, result.DateOfBirth.ToString("yyyy/MM/dd", CultureInfo.InvariantCulture));
        }
예제 #2
0
        public async void No_phone_numbers_validation_works()
        {
            await PlayerWebservice.Login(CreateLoginRequest (_registrationData.Username, _registrationData.Password ));

            var e = Assert.Throws <MemberApiValidationException>(async() => await PlayerWebservice.ReferFriendsAsync(new ReferFriendsRequest()));

            Assert.AreEqual(ReferalDataValidatorResponseCodes.PhoneNumbersAreMissing.ToString(), e.Message);
        }
예제 #3
0
        public async void Unable_to_login_if_password_is_incorrect()
        {
            var e = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>(
                () => PlayerWebservice.Login(CreateLoginRequest(_registrationData.Username, "some invalid password")));

            Assert.IsNotEmpty(e.Exception.ErrorMessage);
            Assert.AreEqual(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString(), e.Exception.ErrorCode);
        }
예제 #4
0
        public async void Unable_to_login_if_username_does_not_exist()
        {
            var e = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>(
                () => PlayerWebservice.Login(CreateLoginRequest("notExistingUsername", _registrationData.Password)));

            Assert.IsNotEmpty(e.Exception.ErrorMessage);
            Assert.That(e.Exception.ErrorCode, Is.EqualTo(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString()));
        }
예제 #5
0
        public void Password_length_validation_works(string password)
        {
            var e = Assert.Throws <MemberApiValidationException>(
                async() => await PlayerWebservice.ChangePasswordAsync(new ChangePasswordRequest {
                Username = _registrationData.Username, OldPassword = _registrationData.Password, NewPassword = password
            }));

            Assert.IsNotEmpty(e.Message);
        }
        public override void BeforeEach()
        {
            base.BeforeEach();

            _response = Task.Run(() => PlayerWebservice.RegistrationFormDataAsync(new RegistrationFormDataRequest
            {
                BrandId = new Guid("00000000-0000-0000-0000-000000000138")
            })).Result;
        }
예제 #7
0
        public void Empty_password_validation_works()
        {
            var e = Assert.Throws <MemberApiValidationException>(
                async() => await PlayerWebservice.ChangePasswordAsync(new ChangePasswordRequest {
                Username = _registrationData.Username, OldPassword = _registrationData.Password, NewPassword = string.Empty
            }));

            Assert.AreEqual(PlayerAccountResponseCode.PasswordShouldNotBeEmpty.ToString(), e.Message);
        }
예제 #8
0
        public async void Can_refer_friends()
        {
            await PlayerWebservice.Login(CreateLoginRequest (_registrationData.Username, _registrationData.Password ));

            var response = PlayerWebservice.ReferFriendsAsync(new ReferFriendsRequest {
                PhoneNumbers = new List <string> {
                    "12345678"
                }
            });
        }
예제 #9
0
        public void Player_is_absent_validation_works()
        {
            var e = Assert.Throws <MemberApiValidationException>(
                async() => await PlayerWebservice.ChangePasswordAsync(new ChangePasswordRequest {
                Username = "******", OldPassword = _registrationData.Password, NewPassword = "******"
            }));

            Assert.IsNotEmpty(e.Message);
            Assert.AreEqual(PlayerAccountResponseCode.PlayerDoesNotExist.ToString(), e.Message);
        }
예제 #10
0
        public async void Unable_to_login_if_username_or_password_is_empty()
        {
            var e = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>(
                () => PlayerWebservice.Login(CreateLoginRequest(string.Empty, _registrationData.Password)));

            Assert.That(e.Exception.ErrorMessage, Is.Not.Empty);
            Assert.AreEqual(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString(), e.Exception.ErrorCode);

            e = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>(
                () => PlayerWebservice.Login(CreateLoginRequest(_registrationData.Username, string.Empty)));

            Assert.IsNotEmpty(e.Exception.ErrorMessage);
            Assert.AreEqual(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString(), e.Exception.ErrorCode);
        }
예제 #11
0
        public async void Can_change_security_question()
        {
            var player        = FakePlayerRepository.Players.Single();
            var newQuestionId = TestDataGenerator.GetRandomSecurityQuestion();
            var newAnswer     = "SecurityAnswer" + TestDataGenerator.GetRandomString();
            await PlayerWebservice.ChangeSecurityQuestionAsync(new ChangeSecurityQuestionRequest
            {
                Id = player.Id.ToString(),
                SecurityQuestionId = newQuestionId,
                SecurityAnswer     = newAnswer,
            });

            Assert.AreEqual(newQuestionId, player.SecurityQuestionId.ToString());
            Assert.AreEqual(newAnswer, player.SecurityAnswer);
        }
예제 #12
0
        public async void Can_change_password()
        {
            var authRepository       = Container.Resolve <IAuthRepository>();
            var initialPasswordValue = authRepository.Actors.Last().EncryptedPassword;
            await PlayerWebservice.ChangePasswordAsync(new ChangePasswordRequest
            {
                Username    = _registrationData.Username,
                OldPassword = _registrationData.Password,
                NewPassword = "******"
            });

            var changedPasswordValue = authRepository.Actors.Last().EncryptedPassword;

            //Assert.False(result.IsErrorResponse());
            Assert.AreNotEqual(initialPasswordValue, changedPasswordValue);
        }
예제 #13
0
        public void Old_password_validation_works()
        {
            var    newPassword = TestDataGenerator.GetRandomString();
            string oldPasswordToEnter;

            do
            {
                oldPasswordToEnter = TestDataGenerator.GetRandomString();
            }while (oldPasswordToEnter == _registrationData.Password);

            var e = Assert.Throws <MemberApiValidationException>(
                async() => await PlayerWebservice.ChangePasswordAsync(new ChangePasswordRequest {
                Username = _registrationData.Username, OldPassword = oldPasswordToEnter, NewPassword = newPassword
            }));

            Assert.IsNotEmpty(e.Message);
            Assert.AreEqual(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString(), e.Message);
        }
예제 #14
0
        protected async Task <RegisterRequest> RegisterPlayer(bool doLogin = true)
        {
            var registrationData = TestDataGenerator.CreateRandomRegistrationRequestData();

            await PlayerWebservice.RegisterAsync(registrationData);

            if (doLogin)
            {
                await PlayerWebservice.Login(new LoginRequest
                {
                    Username       = registrationData.Username,
                    Password       = registrationData.Password,
                    BrandId        = new Guid("00000000-0000-0000-0000-000000000138"),
                    IPAddress      = registrationData.IpAddress,
                    RequestHeaders = new Dictionary <string, string>()
                });
            }
            return(registrationData);
        }
예제 #15
0
        public async void Unable_to_login_after_max_failed_login_attempts()
        {
            var maxFailedLoginAttempts = Convert.ToInt32(ConfigurationManager.AppSettings["MaxFailedLoginAttempts"]);
            var newPlayer = await RegisterPlayer(false);

            var wrongLoginRequest = CreateLoginRequest(newPlayer.Username, "wrongPassword");

            for (var i = 0; i < maxFailedLoginAttempts; i++)
            {
                var passwordError = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>(
                    () => PlayerWebservice.Login(wrongLoginRequest));

                Assert.IsNotEmpty(passwordError.Exception.ErrorMessage);
                Assert.AreEqual(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString(), passwordError.Exception.ErrorCode);
            }

            var lockedError = await AsyncTestHelper.ThrowsAsync <MemberApiProxyException>(
                () => PlayerWebservice.Login(CreateLoginRequest(newPlayer.Username, newPlayer.Password)));

            Assert.IsNotEmpty(lockedError.Exception.ErrorMessage);
            Assert.AreEqual(PlayerAccountResponseCode.AccountLocked.ToString(), lockedError.Exception.ErrorCode);
        }
예제 #16
0
 public void Can_login_Player()
 {
     var result = PlayerWebservice.Login(CreateLoginRequest(_registrationData.Username, _registrationData.Password));
 }
예제 #17
0
        public void Cannt_change_security_question_with_invalid_player()
        {
            var playerId      = new Guid().ToString();
            var newQuestionId = TestDataGenerator.GetRandomSecurityQuestion();
            var newAnswer     = "SecurityAnswer" + TestDataGenerator.GetRandomString();
            var e             = Assert.Throws <MemberApiValidationException>(async() => await PlayerWebservice.ChangeSecurityQuestionAsync(new ChangeSecurityQuestionRequest
            {
                Id = playerId,
                SecurityQuestionId = newQuestionId,
                SecurityAnswer     = newAnswer,
            }));

            Assert.AreEqual(PlayerAccountResponseCode.PlayerDoesNotExist.ToString(), e.Message);
        }
예제 #18
0
        public void Cannt_change_security_question_with_blank_answer()
        {
            var player        = FakePlayerRepository.Players.Single();
            var newQuestionId = TestDataGenerator.GetRandomSecurityQuestion();
            var newAnswer     = "";
            var e             = Assert.Throws <MemberApiValidationException>(async() => await PlayerWebservice.ChangeSecurityQuestionAsync(new ChangeSecurityQuestionRequest
            {
                Id = player.Id.ToString(),
                SecurityQuestionId = newQuestionId,
                SecurityAnswer     = newAnswer,
            }));

            Assert.AreEqual(RegisterValidatorResponseCodes.SecurityAnswerIsMissing.ToString(), e.Message);
        }