/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Security/test/AuthSamples.FunctionalTests/StaticFilesAuthTests.cs
41 строка
1 KB
Pranav K
Use file scoped namespaces (#38076)
06 ноя 2021, 03:52
Не верифицирован
06 ноя 2021, 03:52
a450cb6
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Net; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Testing; using Xunit; namespace AuthSamples.FunctionalTests; public class StaticFilesAuthTests : IClassFixture<WebApplicationFactory<StaticFilesAuth.Startup>> { public StaticFilesAuthTests(WebApplicationFactory<StaticFilesAuth.Startup> fixture) { Client = fixture.CreateDefaultClient(); } public HttpClient Client { get; } [Fact] public async Task DefaultReturns200() { var response = await Client.GetAsync("/"); var content = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); } [Theory] [InlineData("MapAuthenticatedFiles")] [InlineData("MapImperativeFiles")] public async Task EndpointRedirectsToLoginPageWhenNotLoggedIn(string scenario) { var response = await Client.GetAsync(scenario); var content = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); Assert.Equal("http://localhost/Account/Login?ReturnUrl=%2F" + scenario, response.Headers.Location.ToString()); } }