Skip to content

Instantly share code, notes, and snippets.

@Lutando
Created March 20, 2017 19:46
Show Gist options
  • Save Lutando/970dc0e68b88b6a277b28a400cbe4f6d to your computer and use it in GitHub Desktop.
Save Lutando/970dc0e68b88b6a277b28a400cbe4f6d to your computer and use it in GitHub Desktop.
[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();
await authorizationHandler.HandleAsync(authorizationContext);
Assert.True(authorizationContext.HasSucceeded);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment