示例#1
0
    public static async Task <Index> CreateAsync(HttpClient client, DefaultUIContext context = null)
    {
        var goToIndex = await client.GetAsync("/");

        var index = await ResponseAssert.IsHtmlDocumentAsync(goToIndex);

        return(new Index(client, index, context ?? new DefaultUIContext()));
    }
示例#2
0
    internal async Task <DeleteUser> ClickDeleteLinkAsync()
    {
        var goToDelete = await Client.GetAsync(_deleteLink.Href);

        var delete = await ResponseAssert.IsHtmlDocumentAsync(goToDelete);

        return(new DeleteUser(Client, delete, Context.WithAnonymousUser()));
    }
示例#3
0
        public async Task <ChangePassword> ClickChangePasswordLinkAsync()
        {
            var goToChangePassword = await Client.GetAsync(_changePasswordLink.Href);

            var changePasswordDocument = await ResponseAssert.IsHtmlDocumentAsync(goToChangePassword);

            return(new ChangePassword(Client, changePasswordDocument, Context));
        }
示例#4
0
        public async Task <TwoFactorAuthentication> ClickTwoFactorLinkAsync(bool twoFactorEnabled)
        {
            var goToTwoFactor = await Client.GetAsync(_twoFactorLink.Href);

            var twoFactor = await ResponseAssert.IsHtmlDocumentAsync(goToTwoFactor);

            return(new TwoFactorAuthentication(Client, twoFactor, Context, twoFactorEnabled));
        }
示例#5
0
        public async Task <ExternalLogins> ClickExternalLoginsAsync()
        {
            var goToExternalLogin = await Client.GetAsync(_externalLoginLink.Href);

            var externalLoginDocument = await ResponseAssert.IsHtmlDocumentAsync(goToExternalLogin);

            return(new ExternalLogins(Client, externalLoginDocument, Context));
        }
    internal async Task <ResetAuthenticator> ClickResetAuthenticatorLinkAsync()
    {
        var goToResetAuthenticator = await Client.GetAsync(_resetAuthenticatorLink.Href);

        var resetAuthenticator = await ResponseAssert.IsHtmlDocumentAsync(goToResetAuthenticator);

        return(new ResetAuthenticator(Client, resetAuthenticator, Context));
    }
示例#7
0
    public async Task <ForgotPassword> ClickForgotPasswordLinkAsync()
    {
        var response = await Client.GetAsync(_forgotPasswordLink.Href);

        var forgotPassword = await ResponseAssert.IsHtmlDocumentAsync(response);

        return(new ForgotPassword(Client, forgotPassword, Context));
    }
示例#8
0
        public async Task <Email> ClickEmailLinkAsync()
        {
            var goToEmail = await Client.GetAsync(_emailLink.Href);

            var email = await ResponseAssert.IsHtmlDocumentAsync(goToEmail);

            return(new Email(Client, email, Context));
        }
示例#9
0
    public static async Task <ConfirmEmail> Create(IHtmlAnchorElement link, HttpClient client, DefaultUIContext context)
    {
        var response = await client.GetAsync(link.Href);

        var confirmEmail = await ResponseAssert.IsHtmlDocumentAsync(response);

        return(new ConfirmEmail(client, confirmEmail, context));
    }
示例#10
0
    public async Task <ResendEmailConfirmation> ClickReconfirmEmailLinkAsync()
    {
        var response = await Client.GetAsync(_reconfirmLink.Href);

        var forgotPassword = await ResponseAssert.IsHtmlDocumentAsync(response);

        return(new ResendEmailConfirmation(Client, forgotPassword, Context));
    }
示例#11
0
        public async Task <PersonalData> ClickPersonalDataLinkAsync()
        {
            var goToPersonalData = await Client.GetAsync(_personalDataLink.Href);

            var personalData = await ResponseAssert.IsHtmlDocumentAsync(goToPersonalData);

            return(new PersonalData(Client, personalData, Context));
        }
示例#12
0
    internal static async Task <ResetPassword> CreateAsync(IHtmlAnchorElement link, HttpClient client, DefaultUIContext context)
    {
        var resetPasswordResponse = await client.GetAsync(link.Href);

        var resetPassword = await ResponseAssert.IsHtmlDocumentAsync(resetPasswordResponse);

        return(new ResetPassword(client, resetPassword, context));
    }
示例#13
0
    internal async Task <LoginWithRecoveryCode> ClickRecoveryCodeLinkAsync()
    {
        var goToLoginWithRecoveryCode = await Client.GetAsync(_loginWithRecoveryCodeLink.Href);

        var loginWithRecoveryCode = await ResponseAssert.IsHtmlDocumentAsync(goToLoginWithRecoveryCode);

        return(new LoginWithRecoveryCode(Client, loginWithRecoveryCode, Context));
    }
示例#14
0
    public async Task <ConfirmEmail> ClickConfirmLinkAsync()
    {
        var goToConfirm = await Client.GetAsync(_confirmLink.Href);

        var confirm = await ResponseAssert.IsHtmlDocumentAsync(goToConfirm);

        return(await ConfirmEmail.Create(_confirmLink, Client, Context));
    }
示例#15
0
    internal async Task <Account.Manage.Index> ClickManageLinkAsync()
    {
        Assert.True(Context.UserAuthenticated);

        var goToManage = await Client.GetAsync(_manageLink.Href);

        var manage = await ResponseAssert.IsHtmlDocumentAsync(goToManage);

        return(new Account.Manage.Index(Client, manage, Context));
    }
示例#16
0
    public async Task <Login> ClickLoginLinkAsync()
    {
        Assert.False(Context.UserAuthenticated);

        var goToLogin = await Client.GetAsync(_loginLink.Href);

        var login = await ResponseAssert.IsHtmlDocumentAsync(goToLogin);

        return(new Login(Client, login, Context));
    }
示例#17
0
    public async Task <Register> ClickRegisterLinkAsync()
    {
        Assert.False(Context.UserAuthenticated);

        var goToRegister = await Client.GetAsync(_registerLink.Href);

        var register = await ResponseAssert.IsHtmlDocumentAsync(goToRegister);

        return(new Register(Client, register, Context));
    }
示例#18
0
        public async Task <TwoFactorAuthentication> ClickTwoFactorEnabledLinkAsync()
        {
            var goToTwoFactor = await Client.GetAsync(_twoFactorLink.Href);

            var twoFactor = await ResponseAssert.IsHtmlDocumentAsync(goToTwoFactor);

            Context.TwoFactorEnabled     = true;
            Context.CookiePolicyAccepted = true;
            return(new TwoFactorAuthentication(Client, twoFactor, Context));
        }
        internal async Task <EnableAuthenticator> ClickEnableAuthenticatorLinkAsync()
        {
            Assert.False(_twoFactorEnabled);

            var goToEnableAuthenticator = await Client.GetAsync(_enableAuthenticatorLink.Href);

            var enableAuthenticator = await ResponseAssert.IsHtmlDocumentAsync(goToEnableAuthenticator);

            return(new EnableAuthenticator(Client, enableAuthenticator, Context));
        }
示例#20
0
    public async Task <Contoso.Login> ClickLoginWithContosoLinkAsync()
    {
        var externalFormResponse = await Client.SendAsync(_externalLoginForm, _contosoButton);

        var goToContosoLogin     = ResponseAssert.IsRedirect(externalFormResponse);
        var contosoLoginResponse = await Client.GetAsync(goToContosoLogin);

        var contosoLogin = await ResponseAssert.IsHtmlDocumentAsync(contosoLoginResponse);

        return(new Contoso.Login(Client, contosoLogin, Context));
    }
示例#21
0
        public async Task <SetPassword> ClickChangePasswordLinkExternalLoginAsync()
        {
            var response = await Client.GetAsync(_changePasswordLink.Href);

            var goToSetPassword     = ResponseAssert.IsRedirect(response);
            var setPasswordResponse = await Client.GetAsync(goToSetPassword);

            var setPasswordDocument = await ResponseAssert.IsHtmlDocumentAsync(setPasswordResponse);

            return(new SetPassword(Client, setPasswordDocument, Context));
        }
示例#22
0
    public async Task AnonymousUserCanAccessNotAuthorizedPages(string url)
    {
        // Arrange
        var client = ServerFactory
                     .CreateClient();

        // Act
        var response = await client.GetAsync(url);

        // Assert
        await ResponseAssert.IsHtmlDocumentAsync(response);
    }
示例#23
0
    internal async Task <Account.Manage.Index> ClickManageLinkWithExternalLoginAsync()
    {
        Assert.True(Context.UserAuthenticated);

        var goToManage = await Client.GetAsync(_manageLink.Href);

        var manage = await ResponseAssert.IsHtmlDocumentAsync(goToManage);

        return(new Account.Manage.Index(Client, manage, Context
                                        .WithSocialLoginEnabled()
                                        .WithSocialLoginProvider()));
    }
示例#24
0
    public async Task <FunctionalTests.Index> Delete(string password)
    {
        var loggedIn = await SendDeleteForm(password);

        var deleteLocation = ResponseAssert.IsRedirect(loggedIn);

        Assert.Equal(Index.Path, deleteLocation.ToString());
        var indexResponse = await Client.GetAsync(deleteLocation);

        var index = await ResponseAssert.IsHtmlDocumentAsync(indexResponse);

        return(new FunctionalTests.Index(Client, index, Context));
    }
示例#25
0
        internal async Task <Index> SendConfirmationEmailAsync()
        {
            Assert.False(Context.EmailConfirmed);

            var response = await Client.SendAsync(_updateProfileForm, _confirmEmailButton);

            var goToManage     = ResponseAssert.IsRedirect(response);
            var manageResponse = await Client.GetAsync(goToManage);

            var manage = await ResponseAssert.IsHtmlDocumentAsync(manageResponse);

            return(new Index(Client, manage, Context));
        }
示例#26
0
    public async Task <ManageExternalLogin> LinkExternalLoginAsync(string loginEmail)
    {
        // Click on the button to link external login to current user account
        var linkExternalLogin = await Client.SendAsync(_linkLoginForm, _linkLoginButton);

        var goToLinkExternalLogin = ResponseAssert.IsRedirect(linkExternalLogin);
        var externalLoginResponse = await Client.GetAsync(goToLinkExternalLogin);

        var externalLoginDocument = await ResponseAssert.IsHtmlDocumentAsync(externalLoginResponse);

        // Redirected to manage page for external login with a remove button
        return(new ManageExternalLogin(Client, externalLoginDocument, Context));
    }
示例#27
0
    public async Task <LoginWith2fa> PasswordLoginValidUserWith2FaAsync(string userName, string password)
    {
        var loggedIn = await SendLoginForm(userName, password);

        var loggedInLocation = ResponseAssert.IsRedirect(loggedIn);

        Assert.StartsWith(LoginWith2fa.Path, loggedInLocation.ToString());
        var loginWithTwoFactorResponse = await Client.GetAsync(loggedInLocation);

        var loginWithTwoFactor = await ResponseAssert.IsHtmlDocumentAsync(loginWithTwoFactorResponse);

        return(new LoginWith2fa(Client, loginWithTwoFactor, Context));
    }
示例#28
0
        public async Task <Index> LoginValidUserAsync(string userName, string password)
        {
            var loggedIn = await SendLoginForm(userName, password);

            var loggedInLocation = ResponseAssert.IsRedirect(loggedIn);

            Assert.Equal(Index.Path, loggedInLocation.ToString());
            var indexResponse = await Client.GetAsync(loggedInLocation);

            var index = await ResponseAssert.IsHtmlDocumentAsync(indexResponse);

            return(new Index(Client, index, Context, authenticated: true));
        }
示例#29
0
        public async Task <Index> SendEmailAsync(string email)
        {
            var response = await Client.SendAsync(_emailForm, new Dictionary <string, string>
            {
                ["Input_Email"] = email
            });

            var redirect      = ResponseAssert.IsRedirect(response);
            var indexResponse = await Client.GetAsync(redirect);

            var index = await ResponseAssert.IsHtmlDocumentAsync(indexResponse);

            return(new Index(Client, index, Context.WithAuthenticatedUser()));
        }
示例#30
0
    public async Task <Index> SendRecoveryCodeAsync(string recoveryCode)
    {
        var response = await Client.SendAsync(_loginWithRecoveryCodeForm, new Dictionary <string, string>
        {
            ["Input_RecoveryCode"] = recoveryCode
        });

        var goToIndex = ResponseAssert.IsRedirect(response);
        var indexPage = await Client.GetAsync(goToIndex);

        var index = await ResponseAssert.IsHtmlDocumentAsync(indexPage);

        return(new Index(Client, index, Context.WithAuthenticatedUser()));
    }