Пример #1
0
        public void Roles_Contains_All_Role_Claims()
        {
            var acc = MockAccessor.With("user",
                                        new Claim(ClaimTypes.Role, Role.Admin));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.Contains(ctx.Roles, r => r.Equals(Role.Admin));
        }
Пример #2
0
        public void IsInRole_Is_False_When_User_Is_Not_In_Role()
        {
            var acc = MockAccessor.With("tester",
                                        new Claim(ClaimTypes.Role, Role.Admin));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.False(ctx.IsInRole(Role.Fed));
        }
Пример #3
0
        public void UUID_Does_Not_Return_Null()
        {
            var acc = MockAccessor.With("tester",
                                        new Claim(JwtRegisteredClaimNames.Iss, "urn:leaf:iss:test.tld"));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.Equal("tester@urn:leaf:iss:test.tld", ctx.UUID);
        }
Пример #4
0
        public void IsInstitutional_Is_False_When_Issues_Do_Not_Match()
        {
            var acc = MockAccessor.With("tester",
                                        new Claim(JwtRegisteredClaimNames.Iss, "urn:leaf:iss:test.tld"));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions("urn:leaf:iss:failTest.tld"));

            Assert.False(ctx.IsInstitutional);
        }
Пример #5
0
        public void IsQuarantined_Is_True_When_User_Is_Not_In_Fed_Role()
        {
            var acc = MockAccessor.With("tester",
                                        new Claim(ClaimTypes.Role, Role.Admin));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.True(ctx.IsQuarantined);
        }
Пример #6
0
        public void Groups_Contains_All_Group_Claims()
        {
            var acc = MockAccessor.With("user@localhost",
                                        new Claim(Group.Key, "test-group-1"),
                                        new Claim(JwtRegisteredClaimNames.Iss, "urn:leaf:iss:test.tld"));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.Contains(ctx.Groups, g => g.Equals("test-group-1@localhost@urn:leaf:iss:test.tld"));
        }
Пример #7
0
        public void SessionNonce_Returns_A_Guid_If_Session_Exists()
        {
            var sess = Guid.NewGuid();
            var acc  = MockAccessor.With("tester",
                                         new Claim(Nonce.Access, sess.ToString()));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.Equal(sess, ctx.SessionNonce);
        }
Пример #8
0
        public void IdNonce_Returns_A_Guid()
        {
            var id  = Guid.NewGuid();
            var acc = MockAccessor.With("tester",
                                        new Claim(Nonce.Id, id.ToString()));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.Equal(id, ctx.IdNonce);
        }
Пример #9
0
        public void IsAdmin_Is_False_When_User_Is_Not_In_Admin_Role()
        {
            var acc = MockAccessor.With("tester",
                                        new Claim(ClaimTypes.Role, Role.Fed),
                                        new Claim(JwtRegisteredClaimNames.Iss, "urn:leaf:iss:test.tld"));
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions("urn:leaf:iss:test.tld"));

            Assert.False(ctx.IsAdmin);
        }
Пример #10
0
        public void SessionNonce_Returns_Default_If_Session_Does_Not_Exist()
        {
            var acc = MockAccessor.With("tester");
            var ctx = new HttpUserContext(acc, GetJwtVerifyingOptions());

            Assert.Equal(default, ctx.SessionNonce);
Пример #11
0
 public PositionManageAppService(DefaultDbContext defaultDbContext, HttpUserContext currentUser)
 {
     _defaultDbContext = defaultDbContext;
     _currentUser      = currentUser;
 }
Пример #12
0
 public AccountAppService(DefaultDbContext defaultDbContext, IJwtBearerService jwtBearerService, HttpUserContext currentUser)
 {
     _defaultDbContext = defaultDbContext;
     _jwtBearerService = jwtBearerService;
     _currentUser      = currentUser;
 }
Пример #13
0
 public AttachmentAppService(DefaultDbContext defaultDbContext, IHostingEnvironment hostingEnvironment, HttpUserContext currentUser)
 {
     _defaultDbContext   = defaultDbContext;
     _hostingEnvironment = hostingEnvironment;
     _currentUser        = currentUser;
 }