public void Forbid_ResultHasCorrectValues(AuthenticationProperties properties, IList <string> authenticationSchemes)
    {
        // Act
        var result = TypedResults.Forbid(properties, authenticationSchemes);

        // Assert
        Assert.Equal(properties, result.Properties);
        Assert.Equal(authenticationSchemes ?? new ReadOnlyCollection <string>(new List <string>()), result.AuthenticationSchemes);
    }
Exemple #2
0
 /// <summary>
 /// Creates a <see cref="IResult"/> that on execution invokes <see cref="AuthenticationHttpContextExtensions.ForbidAsync(HttpContext, string?, AuthenticationProperties?)"/>.
 /// <para>
 /// By default, executing this result returns a <see cref="StatusCodes.Status403Forbidden"/>. Some authentication schemes, such as cookies,
 /// will convert <see cref="StatusCodes.Status403Forbidden"/> to a redirect to show a login page.
 /// </para>
 /// </summary>
 /// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the authentication
 /// challenge.</param>
 /// <param name="authenticationSchemes">The authentication schemes to challenge.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 /// <remarks>
 /// Some authentication schemes, such as cookies, will convert <see cref="StatusCodes.Status403Forbidden"/> to
 /// a redirect to show a login page.
 /// </remarks>
 public static IResult Forbid(AuthenticationProperties?properties = null, IList <string>?authenticationSchemes = null)
 => TypedResults.Forbid(properties, authenticationSchemes);