authorization tests with role

pull/2659/head
Mehmet Perk 6 years ago
parent c0d6582986
commit 5016ba69a3

@ -52,5 +52,14 @@ namespace Volo.Abp.Authorization
{
_permissionDefinitionManager.GetGroups().Count.ShouldBe(1);
}
[Fact]
public async Task Should_Not_Allow_To_Call_Method_If_Has_No_Role_ProtectedByRole_Async()
{
await Assert.ThrowsAsync<AbpAuthorizationException>(async () =>
{
await _myAuthorizedService1.ProtectedByRole().ConfigureAwait(false);
}).ConfigureAwait(false);
}
}
}

@ -11,5 +11,7 @@ namespace Volo.Abp.Authorization.TestServices
Task<int> ProtectedByClass();
Task<int> ProtectedByClassAsync();
Task<int> ProtectedByRole();
}
}

@ -30,5 +30,11 @@ namespace Volo.Abp.Authorization.TestServices
await Task.Delay(10).ConfigureAwait(false);
return 42;
}
[Authorize(Roles = "MyRole")]
public virtual Task<int> ProtectedByRole()
{
return Task.FromResult(42);
}
}
}
Loading…
Cancel
Save