예제 #1
0
        public void testGrandBy_UnixPermissionRequired_Granted()
        {
            var user       = new SystemUser();
            var profile    = new SystemProfile(true);
            var permission = new SystemPermission(user, profile);

            var admin = new SystemAdmin();

            permission.grantBy(admin);
            Assert.AreEqual(SystemPermission.REQUESTED, permission.State(), "requested");
            Assert.AreEqual(false, permission.IsGranted(), "not granted");

            permission.claimBy(admin);
            Assert.AreEqual(SystemPermission.CLAIMED, permission.State(), "claimed");
            Assert.AreEqual(false, permission.IsGranted(), "not granted");

            permission.grantBy(admin);
            Assert.AreEqual(SystemPermission.UNIX_REQUESTED, permission.State(), "Unix requested");
            Assert.AreEqual(false, permission.IsGranted(), "not granted");

            permission.claimBy(admin);
            Assert.AreEqual(SystemPermission.UNIX_CLAIMED, permission.State(), "Unix Claimed");
            Assert.AreEqual(false, permission.IsGranted(), "not granted");

            permission.grantBy(admin);
            Assert.AreEqual(SystemPermission.GRANTED, permission.State(), "granted");
            Assert.AreEqual(true, permission.IsGranted(), "granted");
        }
예제 #2
0
        public void testGrandBy_NoUnixPermissionRequired_NoClaimed_Denied()
        {
            var user       = new SystemUser();
            var profile    = new SystemProfile(false);
            var permission = new SystemPermission(user, profile);

            var admin = new SystemAdmin();

            permission.grantBy(admin);
            Assert.AreEqual(SystemPermission.REQUESTED, permission.State(), "requested");
            Assert.AreEqual(false, permission.IsGranted(), "not granted");

            permission.deniedBy(admin);
            Assert.AreEqual(SystemPermission.REQUESTED, permission.State(), "requested");
            Assert.AreEqual(false, permission.IsGranted(), "not granted");
        }
예제 #3
0
        public void TestDeniedBy()
        {
            SystemUser       user       = new SystemUser();
            SystemProfile    profile    = new SystemProfile();
            SystemPermission permission = new SystemPermission(user, profile);

            Assert.AreEqual(PermissionState.REQUESTED, permission.GetState());

            SystemAdmin admin = new SystemAdmin();

            permission.ClaimedBy(admin);
            Assert.AreEqual(PermissionState.CLAIMED, permission.GetState());
            Assert.AreEqual(false, permission.IsGranted());

            permission.DeniedBy(admin);
            Assert.AreEqual(PermissionState.DENIED, permission.GetState());
            Assert.AreEqual(false, permission.IsGranted());
        }
예제 #4
0
        public void TestGrantedByWithUnixConcerned()
        {
            SystemUser    user    = new SystemUser();
            SystemProfile profile = new SystemProfile();

            profile.SetUnixPermissionRequired(true);
            SystemPermission permission = new SystemPermission(user, profile);

            Assert.AreEqual(PermissionState.UNIX_REQUESTED, permission.GetState());

            SystemAdmin admin = new SystemAdmin();

            permission.ClaimedBy(admin);
            Assert.AreEqual(PermissionState.UNIX_CLAIMED, permission.GetState());
            Assert.AreEqual(false, permission.IsGranted());

            permission.GrantedBy(admin);
            Assert.AreEqual(PermissionState.GRANTED, permission.GetState());
            Assert.AreEqual(true, permission.IsGranted());
        }