예제 #1
0
        public void CanInferRoleBasedOnReadOnlyFlag(bool canOnlyRead, string role)
        {
            var user = new BasicAuthElement { CanOnlyRead = canOnlyRead };
            var testee = new WebApiRole(user);

            testee.ToString().Should().Be(role);
        }
        private static ClaimsIdentity CreateIdentity(
            OAuthGrantResourceOwnerCredentialsContext context,
            BasicAuthElement user)
        {
            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));
            identity.AddClaim(new Claim(ClaimTypes.Role, new WebApiRole(user).ToString()));

            return identity;
        }