public async Task get_null_when_user_is_not_authenticated() { IHttpContextAccessor httpContextAccessor = new HttpContextAccessor(); var provider = new HttpContextRoleProvider(httpContextAccessor); (await provider.GetRoleAsync()).Should().BeNull(); }
public async Task get_null_when_claim_role_not_exist() { var context = new DefaultHttpContext(); context.User = GetAuthenticatedIdentityWithoutRole(); var httpContextAccessor = new HttpContextAccessor(); httpContextAccessor.HttpContext = context; var provider = new HttpContextRoleProvider(httpContextAccessor); (await provider.GetRoleAsync()).Should().BeNull(); }
public async Task get_the_custom_claim_role_value_of_authenticated_user() { string currentRole = "stuff"; var context = new DefaultHttpContext(); context.User = GetAuthenticatedIdentityWithCustomRoleClaim(role: currentRole); var httpContextAccessor = new HttpContextAccessor(); httpContextAccessor.HttpContext = context; var provider = new HttpContextRoleProvider(httpContextAccessor); (await provider.GetRoleAsync()).Should().Be(currentRole); }
public async Task get_null_for_non_authenticated_user_with_default_claim_role() { string currentRole = "stuff"; var context = new DefaultHttpContext(); context.User = GetNonAuthenticatedIdentityWithDefaultRoleClaim(role: currentRole); var httpContextAccessor = new HttpContextAccessor(); httpContextAccessor.HttpContext = context; var provider = new HttpContextRoleProvider(httpContextAccessor); (await provider.GetRoleAsync()).Should().BeNull(); }