This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Fact] | |
[Trait("Category", Category)] | |
public async void HandleEdit_WhenCalledWithResourceOwner_ShouldSucceed() | |
{ | |
var resource = make_PostDefault(); | |
var authorizationModel = PostAuthorizationModel.From(resource); | |
var user = new ClaimsPrincipal(new ClaimsIdentity(new List<Claim> { new Claim("sub", UserIdDefault.ToString()) })); | |
var requirement = PostOperations.Edit; | |
var authorizationContext = new AuthorizationHandlerContext(new List<IAuthorizationRequirement> { requirement }, user, authorizationModel); | |
var authorizationHandler = new PostAuthorizationHandler(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Forum.Models | |
{ | |
public class Post | |
{ | |
public Guid Id { get; private set; } | |
public Guid UserId { get; private set; } | |
public DateTime CreatedAt { get; private set; } | |
public string Text { get; private set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Authorization.Infrastructure; | |
namespace Formum.Api.Authorization.Operations | |
{ | |
public class PostOperations | |
{ | |
public static OperationAuthorizationRequirement Delete = new OperationAuthorizationRequirement { Name = "PostDelete" }; | |
public static OperationAuthorizationRequirement Edit = new OperationAuthorizationRequirement { Name = "PostEdit" }; | |
} | |
} |
NewerOlder