public void WithExistingDeviceIdIsRecognized() { var accessControl = new AccessControl(new CoreSettings()); Guid accessToken = accessControl.RegisterRemoteAccessToken(new Guid()); Guid existingAccessToken = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Equal(accessToken, existingAccessToken); }
public void WithRemoteAccessTokenThrowsArgumentException() { var settings = new CoreSettings(); var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <ArgumentException>(() => accessControl.UpgradeLocalAccess(token, "password123")); }
public async Task SmokeTest() { AccessControl accessControl = SetupVotableAccessControl(2); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.RegisterVote(token, SetupVotedEntry()); Assert.Equal(1, await accessControl.ObserveRemainingVotes(token).FirstAsync()); }
public void ThrowsInvalidOperationExceptionIfGuestSystemIsDisabled() { var settings = new CoreSettings { EnableGuestSystem = false }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <InvalidOperationException>(() => accessControl.RegisterVote(token, SetupVotedEntry())); }
public void WithoutVotesLeftThrowsInvalidOperationException() { var settings = new CoreSettings { EnableGuestSystem = true, MaxVoteCount = 0 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <InvalidOperationException>(() => accessControl.RegisterVote(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }
public void RegisterVoteForSameEntryThrowsInvalidOperationException() { var settings = new CoreSettings { MaxVoteCount = 2 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = SetupVotedEntry(); accessControl.RegisterVote(token, entry); entry.Vote(); Assert.Throws<InvalidOperationException>(() => accessControl.RegisterVote(token, entry)); }
public void UnlockedRemoteControlGivesAdminRightsByDefault() { var settings = new CoreSettings { LockRemoteControl = false }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.VerifyAccess(token); }
public void UnlockedRemoteControlGivesAdminRightsByDefault() { var settings = new CoreSettings { LockRemoteControl = false }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.VerifyAccess(token); }
public void ThrowsWrongPasswordExceptionOnWrongPassword() { var settings = new CoreSettings { RemoteControlPassword = "******" }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <WrongPasswordException>(() => accessControl.UpgradeRemoteAccess(token, "lolol")); }
public void LockedRemoteControlGivesGuestRightsByDefault() { var settings = new CoreSettings { LockRemoteControl = true, RemoteControlPassword = "******" }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws <AccessException>(() => accessControl.VerifyAccess(token)); }
public void LockedRemoteControlGivesGuestRightsByDefault() { var settings = new CoreSettings { LockRemoteControl = true, RemoteControlPassword = "******" }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<AccessException>(() => accessControl.VerifyAccess(token)); }
public void SmokeTest() { var settings = new CoreSettings { EnableGuestSystem = true }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = SetupVotedEntry(); accessControl.RegisterVote(token, entry); Assert.True(accessControl.IsVoteRegistered(token, entry)); Assert.False(accessControl.IsVoteRegistered(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }
public void RegisteredVoteUnregistersAutomaticallyWhenEntryvoteCountIsReset() { var settings = new CoreSettings { MaxVoteCount = 2 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = new PlaylistEntry(0, Helpers.SetupSongMock()); entry.Vote(); var votes = accessControl.ObserveRemainingVotes(token).CreateCollection(); accessControl.RegisterVote(token, entry); entry.ResetVotes(); Assert.Equal(new int?[] { 2, 1, 2 }, votes); }
public void UpgradesToAdmin() { var settings = new CoreSettings { LockRemoteControl = true, RemoteControlPassword = "******" }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.UpgradeRemoteAccess(token, "password123"); accessControl.VerifyAccess(token); }
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())); }
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); }
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); }
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); }
public void SmokeTest() { var settings = new CoreSettings { EnableVotingSystem = true }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var entry = SetupVotedEntry(); accessControl.RegisterVote(token, entry); Assert.True(accessControl.IsVoteRegistered(token, entry)); Assert.False(accessControl.IsVoteRegistered(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }
public async Task ReturnsCurrentValueImmediately() { var settings = new CoreSettings(); var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Equal(settings.MaxVoteCount, await accessControl.ObserveRemainingVotes(token).FirstAsync()); }
public void SmokeTest() { var settings = new CoreSettings(); var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); var votes = accessControl.ObserveRemainingVotes(token).CreateCollection(); accessControl.RegisterVote(token, SetupVotedEntry()); accessControl.RegisterVote(token, SetupVotedEntry()); Assert.Equal(new int?[] { 2, 1, 0 }, votes); }
public void WithExistingDeviceIdIsRecognized() { var accessControl = new AccessControl(new CoreSettings()); Guid accessToken = accessControl.RegisterRemoteAccessToken(new Guid()); Guid existingAccessToken = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Equal(accessToken, existingAccessToken); }
public async Task SmokeTest() { var settings = new CoreSettings { EnableVotingSystem = true, MaxVoteCount = 2 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.RegisterVote(token, SetupVotedEntry()); Assert.Equal(settings.MaxVoteCount - 1, await accessControl.ObserveRemainingVotes(token).FirstAsync()); }
public void WithRemoteAccessTokenThrowsArgumentException() { var settings = new CoreSettings(); var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<ArgumentException>(() => accessControl.UpgradeLocalAccess(token, "password123")); }
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); }
public void ThrowsWrongPasswordExceptionOnWrongPassword() { var settings = new CoreSettings { RemoteControlPassword = "******" }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<WrongPasswordException>(() => accessControl.UpgradeRemoteAccess(token, "lolol")); }
public void ThrowsInvalidOperationExceptionIfVotingIsDisabled() { var settings = new CoreSettings { EnableVotingSystem = false }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<InvalidOperationException>(() => accessControl.RegisterVote(token, SetupVotedEntry())); }
public void UpgradesToAdmin() { var settings = new CoreSettings { LockRemoteControl = true, RemoteControlPassword = "******" }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); accessControl.UpgradeRemoteAccess(token, "password123"); accessControl.VerifyAccess(token); }
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())); }
public void WithoutVotesLeftThrowsInvalidOperationException() { var settings = new CoreSettings { EnableVotingSystem = true, MaxVoteCount = 0 }; var accessControl = new AccessControl(settings); Guid token = accessControl.RegisterRemoteAccessToken(new Guid()); Assert.Throws<InvalidOperationException>(() => accessControl.RegisterVote(token, new PlaylistEntry(0, Helpers.SetupSongMock()))); }