Пример #1
0
            public void ThrowsInvalidOperationExceptionIfLocalPasswordIsNotSet()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                Assert.Throws <InvalidOperationException>(() => accessControl.DowngradeLocalAccess(token));
            }
Пример #2
0
            public void ThrowsArgumentExceptionOnBogusAccessToken()
            {
                var settings      = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.SetLocalPassword(token, "password123");

                Assert.Throws <ArgumentException>(() => accessControl.UpgradeLocalAccess(new Guid(), "password123"));
            }
Пример #3
0
            public void ThrowsWrongPasswordExceptionOnWrongPassword()
            {
                var settings      = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.SetLocalPassword(token, "password123");

                Assert.Throws <WrongPasswordException>(() => accessControl.UpgradeLocalAccess(token, "lolol"));
            }
Пример #4
0
            public void ValidatesPassword()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                Assert.Throws <ArgumentException>(() => accessControl.SetLocalPassword(token, ""));
                Assert.Throws <ArgumentException>(() => accessControl.SetLocalPassword(token, " "));
                Assert.Throws <ArgumentNullException>(() => accessControl.SetLocalPassword(token, null));
            }
Пример #5
0
            public void UpgradesToAdmin()
            {
                var settings      = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.SetLocalPassword(token, "password123");
                accessControl.UpgradeLocalAccess(token, "password123");

                accessControl.VerifyAccess(token);
            }
Пример #6
0
            public void LocalAccessTokenIgnoresVoteCount()
            {
                var settings = new CoreSettings {
                    MaxVoteCount = 0
                };

                var accessControl = new AccessControl(settings);

                Guid accessToken = accessControl.RegisterLocalAccessToken();

                accessControl.VerifyVotingPreconditions(accessToken);
            }
Пример #7
0
            public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled()
            {
                var settings = new CoreSettings {
                    EnableGuestSystem = false
                };

                var accessControl = new AccessControl(settings);

                Guid accessToken = accessControl.RegisterLocalAccessToken();

                Assert.Throws <InvalidOperationException>(() => accessControl.VerifyVotingPreconditions(accessToken));
            }
Пример #8
0
            public void WithLocalAccessTokenThrowsArgumentException()
            {
                var settings = new CoreSettings
                {
                    RemoteControlPassword = "******"
                };

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                Assert.Throws <ArgumentException>(() => accessControl.UpgradeRemoteAccess(token, "password123"));
            }
Пример #9
0
            public void LocalSmokeTest()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.VerifyAccess(token, false);

                accessControl.SetLocalPassword(token, "password123");
                accessControl.DowngradeLocalAccess(token);

                Assert.Throws <AccessException>(() => accessControl.VerifyAccess(token));
            }
Пример #10
0
            public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled()
            {
                var settings = new CoreSettings
                {
                    EnableGuestSystem = false,
                    LockRemoteControl = true
                };

                var  accessControl = new AccessControl(settings);
                Guid localToken    = accessControl.RegisterLocalAccessToken();

                accessControl.SetRemotePassword(localToken, "Password");

                Guid token = accessControl.RegisterRemoteAccessToken(new Guid());

                Assert.Throws <InvalidOperationException>(() => accessControl.RegisterShadowVote(token, SetupShadowVotedEntry()));
            }
Пример #11
0
            public void SmokeTest()
            {
                var settings = new CoreSettings
                {
                    LockRemoteControl = false
                };

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                var permissions = accessControl.ObserveAccessPermission(token).CreateCollection();

                accessControl.SetLocalPassword(token, "password");
                accessControl.DowngradeLocalAccess(token);
                accessControl.UpgradeLocalAccess(token, "password");

                Assert.Equal(new[] { AccessPermission.Admin, AccessPermission.Guest, AccessPermission.Admin }, permissions);
            }
Пример #12
0
            public void UpdatesOnlyRemoteAccessPermissions()
            {
                var settings = new CoreSettings
                {
                    LockRemoteControl     = true,
                    RemoteControlPassword = null
                };

                var accessControl = new AccessControl(settings);

                Guid localToken = accessControl.RegisterLocalAccessToken();

                Guid remoteToken       = accessControl.RegisterRemoteAccessToken(new Guid());
                var  remotePermissions = accessControl.ObserveAccessPermission(remoteToken).CreateCollection();

                accessControl.SetRemotePassword(localToken, "password");

                Assert.Equal(AccessPermission.Admin, accessControl.ObserveAccessPermission(localToken).FirstAsync().Wait());
                Assert.Equal(new[] { AccessPermission.Admin, AccessPermission.Guest }, remotePermissions);
            }
Пример #13
0
        public void UpdatesRemoteAccessWhenLockRemoteSettingChanges()
        {
            var settings = new CoreSettings
            {
                LockRemoteControl = false
            };

            var accessControl = new AccessControl(settings);

            Guid remoteToken = accessControl.RegisterRemoteAccessToken(new Guid());
            Guid adminToken  = accessControl.RegisterLocalAccessToken();

            var permissions = accessControl.ObserveAccessPermission(remoteToken).CreateCollection();

            settings.LockRemoteControl = true;
            accessControl.SetRemotePassword(adminToken, "password");

            settings.LockRemoteControl = false;
            settings.LockRemoteControl = true;

            Assert.Equal(new[] { AccessPermission.Admin, AccessPermission.Guest, AccessPermission.Admin, AccessPermission.Guest }, permissions);
        }
Пример #14
0
            public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled()
            {
                var settings = new CoreSettings { EnableGuestSystem = false };

                var accessControl = new AccessControl(settings);

                Guid accessToken = accessControl.RegisterLocalAccessToken();

                Assert.Throws<InvalidOperationException>(() => accessControl.VerifyVotingPreconditions(accessToken));
            }
Пример #15
0
            public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled()
            {
                var settings = new CoreSettings
                {
                    EnableGuestSystem = false,
                    LockRemoteControl = true
                };

                var accessControl = new AccessControl(settings);
                Guid localToken = accessControl.RegisterLocalAccessToken();
                accessControl.SetRemotePassword(localToken, "Password");

                Guid token = accessControl.RegisterRemoteAccessToken(new Guid());

                Assert.Throws<InvalidOperationException>(() => accessControl.RegisterShadowVote(token, SetupShadowVotedEntry()));
            }
Пример #16
0
            public void SmokeTest()
            {
                var settings = new CoreSettings
                {
                    LockRemoteControl = false
                };

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                var permissions = accessControl.ObserveAccessPermission(token).CreateCollection();

                accessControl.SetLocalPassword(token, "password");
                accessControl.DowngradeLocalAccess(token);
                accessControl.UpgradeLocalAccess(token, "password");

                Assert.Equal(new[] { AccessPermission.Admin, AccessPermission.Guest, AccessPermission.Admin }, permissions);
            }
Пример #17
0
            public void ThrowsInvalidOperationExceptionIfLocalPasswordIsNotSet()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();
                Assert.Throws<InvalidOperationException>(() => accessControl.DowngradeLocalAccess(token));
            }
Пример #18
0
            public void UpdatesOnlyRemoteAccessPermissions()
            {
                var settings = new CoreSettings
                {
                    LockRemoteControl = true,
                    RemoteControlPassword = null
                };

                var accessControl = new AccessControl(settings);

                Guid localToken = accessControl.RegisterLocalAccessToken();

                Guid remoteToken = accessControl.RegisterRemoteAccessToken(new Guid());
                var remotePermissions = accessControl.ObserveAccessPermission(remoteToken).CreateCollection();

                accessControl.SetRemotePassword(localToken, "password");

                Assert.Equal(AccessPermission.Admin, accessControl.ObserveAccessPermission(localToken).FirstAsync().Wait());
                Assert.Equal(new[] { AccessPermission.Admin, AccessPermission.Guest }, remotePermissions);
            }
Пример #19
0
            public void ValidatesPassword()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                Assert.Throws<ArgumentException>(() => accessControl.SetLocalPassword(token, ""));
                Assert.Throws<ArgumentException>(() => accessControl.SetLocalPassword(token, " "));
                Assert.Throws<ArgumentNullException>(() => accessControl.SetLocalPassword(token, null));
            }
Пример #20
0
            public void ThrowsWrongPasswordExceptionOnWrongPassword()
            {
                var settings = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();
                accessControl.SetLocalPassword(token, "password123");

                Assert.Throws<WrongPasswordException>(() => accessControl.UpgradeLocalAccess(token, "lolol"));
            }
Пример #21
0
            public void ThrowsArgumentExceptionOnBogusAccessToken()
            {
                var settings = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();
                accessControl.SetLocalPassword(token, "password123");

                Assert.Throws<ArgumentException>(() => accessControl.UpgradeLocalAccess(new Guid(), "password123"));
            }
Пример #22
0
            public void UpgradesToAdmin()
            {
                var settings = new CoreSettings();
                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.SetLocalPassword(token, "password123");
                accessControl.UpgradeLocalAccess(token, "password123");

                accessControl.VerifyAccess(token);
            }
Пример #23
0
            public void WithLocalAccessTokenThrowsArgumentException()
            {
                var settings = new CoreSettings
                {
                    RemoteControlPassword = "******"
                };

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                Assert.Throws<ArgumentException>(() => accessControl.UpgradeRemoteAccess(token, "password123"));
            }
Пример #24
0
            public void LocalSmokeTest()
            {
                var settings = new CoreSettings();

                var accessControl = new AccessControl(settings);

                Guid token = accessControl.RegisterLocalAccessToken();

                accessControl.VerifyAccess(token, false);

                accessControl.SetLocalPassword(token, "password123");
                accessControl.DowngradeLocalAccess(token);

                Assert.Throws<AccessException>(() => accessControl.VerifyAccess(token));
            }
Пример #25
0
        public void UpdatesRemoteAccessWhenLockRemoteSettingChanges()
        {
            var settings = new CoreSettings
            {
                LockRemoteControl = false
            };

            var accessControl = new AccessControl(settings);

            Guid remoteToken = accessControl.RegisterRemoteAccessToken(new Guid());
            Guid adminToken = accessControl.RegisterLocalAccessToken();

            var permissions = accessControl.ObserveAccessPermission(remoteToken).CreateCollection();

            settings.LockRemoteControl = true;
            accessControl.SetRemotePassword(adminToken, "password");

            settings.LockRemoteControl = false;
            settings.LockRemoteControl = true;

            Assert.Equal(new[] { AccessPermission.Admin, AccessPermission.Guest, AccessPermission.Admin, AccessPermission.Guest }, permissions);
        }
Пример #26
0
            public void LocalAccessTokenIgnoresVoteCount()
            {
                var settings = new CoreSettings { MaxVoteCount = 0 };

                var accessControl = new AccessControl(settings);

                Guid accessToken = accessControl.RegisterLocalAccessToken();

                accessControl.VerifyVotingPreconditions(accessToken);
            }