示例#1
0
        public new void Setup()
        {
            SecureHttpRequest.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(ApiRequestHelper.CreateHttpResponseMessage(AzureAdGraphQueryResponse, HttpStatusCode.OK));

            _newAdUserAccount = new NewAdUserAccount {
                Username = "******", UserId = "TestUserId", OneTimePassword = "******"
            };
            IdentityServiceApiClient.Setup(i => i.CreateUserAsync(It.IsAny <string>(), It.IsAny <string>(),
                                                                  It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).ReturnsAsync(_newAdUserAccount);
        }
示例#2
0
        public async Task Should_create_new_user_account_successfully()
        {
            var existingUsers = new[] { "existing.user", "existing.user1" };

            IdentityServiceApiClient.Setup(x => x.GetUsernamesStartingWithAsync(It.IsAny <string>()))
            .ReturnsAsync(existingUsers.Select(username => username + Domain));

            Filter = $"otherMails/any(c:c eq '{RecoveryEmail.Replace("'", "''")}')";

            AzureAdGraphQueryResponse.Value = new List <AzureAdGraphUserResponse>();
            SecureHttpRequest.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(ApiRequestHelper.CreateHttpResponseMessage(AzureAdGraphQueryResponse, HttpStatusCode.OK));


            var response = await Service.CreateUserAsync("fName", "lName", RecoveryEmail, false);

            response.Should().NotBeNull();
            response.Username.Should().Be(_newAdUserAccount.Username);
            response.UserId.Should().Be(_newAdUserAccount.UserId);
            response.OneTimePassword.Should().Be(_newAdUserAccount.OneTimePassword);
            SecureHttpRequest.Verify(s => s.GetAsync(It.IsAny <string>(), AccessUri), Times.Once);
            IdentityServiceApiClient.Verify(i => i.CreateUserAsync(It.IsAny <string>(), "fName", "lName", "fName lName", RecoveryEmail, false), Times.Once);
        }