Table of Contents

Class AuthorizationPolicyTests

Namespace
ProjectTemplate.Web.Tests
Assembly
ProjectTemplate.Web.Tests.dll

Provides integration tests for application authorization policy configuration and role/permission policy behavior.

public sealed class AuthorizationPolicyTests
Inheritance
AuthorizationPolicyTests
Inherited Members

Methods

ApplicationStartup_Fails_WhenAuthorizationRoleClaimTypeIsEmpty()

Verifies that application startup fails with an appropriate error when the required RoleClaimType authorization option is not configured.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 175)]
public void ApplicationStartup_Fails_WhenAuthorizationRoleClaimTypeIsEmpty()

AuthenticatedUserPolicy_RemainsAvailable()

Verifies that the baseline authenticated-user policy remains available and allows authenticated users.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 157)]
public Task AuthenticatedUserPolicy_RemainsAvailable()

Returns

Task

A task that represents the asynchronous test operation.

AuthorizationOptions_AreBoundFromConfiguration()

Verifies that application authorization options are bound from configuration.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 30)]
public void AuthorizationOptions_AreBoundFromConfiguration()

PermissionPolicy_ReturnsForbidden_WhenUserLacksManagePermission()

Verifies that the manage application permission policy rejects authenticated users without the required permission.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 137)]
public Task PermissionPolicy_ReturnsForbidden_WhenUserLacksManagePermission()

Returns

Task

A task that represents the asynchronous test operation.

PermissionPolicy_ReturnsOk_WhenUserHasManagePermission()

Verifies that the manage application permission policy allows users with the configured permission.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 117)]
public Task PermissionPolicy_ReturnsOk_WhenUserHasManagePermission()

Returns

Task

A task that represents the asynchronous test operation.

ProtectedEndpoint_ReturnsUnauthorized_WhenUnauthenticated()

Verifies that the authenticated-user policy rejects unauthenticated requests.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 60)]
public Task ProtectedEndpoint_ReturnsUnauthorized_WhenUnauthenticated()

Returns

Task

A task that represents the asynchronous test operation.

RolePolicy_ReturnsForbidden_WhenUserLacksAdministratorRole()

Verifies that the administrator role policy rejects authenticated users without the required role.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 97)]
public Task RolePolicy_ReturnsForbidden_WhenUserLacksAdministratorRole()

Returns

Task

A task that represents the asynchronous test operation.

RolePolicy_ReturnsOk_WhenUserHasAdministratorRole()

Verifies that the administrator role policy allows users with the configured administrator role.

[Fact("/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/tests/ProjectTemplate.Web.Tests/AuthorizationPolicyTests.cs", 77)]
public Task RolePolicy_ReturnsOk_WhenUserHasAdministratorRole()

Returns

Task

A task that represents the asynchronous test operation.