Skip to content

Instantly share code, notes, and snippets.

@Lutando
Created March 20, 2017 19:47
Show Gist options
  • Save Lutando/b39657791eb5d205db4b9da517f72411 to your computer and use it in GitHub Desktop.
Save Lutando/b39657791eb5d205db4b9da517f72411 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