public async Task WhenSetClientConnectionEncryptionLevelSetToLow_ThenConnectionSucceeds( [WindowsInstance(InitializeScript = @" & reg add ""HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"" /t REG_DWORD /v MinEncryptionLevel /d 1 /f | Out-Default ")] InstanceRequest testInstance) { await testInstance.AwaitReady(); using (var tunnel = RdpTunnel.Create(testInstance.InstanceReference)) { var session = await Connect(tunnel, testInstance.InstanceReference); AwaitEvent <RemoteDesktopConnectionSuceededEvent>(); Assert.IsNull(this.ExceptionShown); RemoteDesktopWindowClosedEvent expectedEvent = null; this.serviceProvider.GetService <IEventService>() .BindHandler <RemoteDesktopWindowClosedEvent>(e => { expectedEvent = e; }); Delay(TimeSpan.FromSeconds(5)); session.Close(); Assert.IsNotNull(expectedEvent); } }
public async Task WhenSetClientConnectionEncryptionLevelSetToLow_ThenConnectionSucceeds( [WindowsInstance(InitializeScript = @" & reg add ""HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"" /t REG_DWORD /v MinEncryptionLevel /d 1 /f | Out-Default ")] ResourceTask <InstanceLocator> testInstance, [Credential(Role = PredefinedRole.IapTunnelUser)] ResourceTask <ICredential> credential) { var locator = await testInstance; using (var tunnel = RdpTunnel.Create( locator, await credential)) { var session = await Connect(tunnel, locator); AwaitEvent <RemoteDesktopConnectionSuceededEvent>(); Assert.IsNull(this.ExceptionShown); RemoteDesktopWindowClosedEvent expectedEvent = null; this.serviceProvider.GetService <IEventService>() .BindHandler <RemoteDesktopWindowClosedEvent>(e => { expectedEvent = e; }); Delay(TimeSpan.FromSeconds(5)); session.Close(); Assert.IsNotNull(expectedEvent); } }
public async Task WhenCredentialsValid_ThenConnectingSucceeds( [Values(RdpConnectionBarState.AutoHide, RdpConnectionBarState.Off, RdpConnectionBarState.Pinned)] RdpConnectionBarState connectionBarState, [Values(RdpDesktopSize.ClientSize, RdpDesktopSize.ScreenSize)] RdpDesktopSize desktopSize, [Values(RdpAudioMode.DoNotPlay, RdpAudioMode.PlayLocally, RdpAudioMode.PlayOnServer)] RdpAudioMode audioMode, [Values(RdpRedirectClipboard.Disabled, RdpRedirectClipboard.Enabled)] RdpRedirectClipboard redirectClipboard, // Use a slightly larger machine type as all this RDP'ing consumes a fair // amount of memory. [WindowsInstance(MachineType = "n1-standard-2")] InstanceRequest testInstance) { await testInstance.AwaitReady(); using (var tunnel = RdpTunnel.Create(testInstance.InstanceReference)) using (var gceAdapter = new ComputeEngineAdapter(this.serviceProvider.GetService <IAuthorizationService>())) { var credentials = await gceAdapter.ResetWindowsUserAsync( testInstance.InstanceReference, "test", CancellationToken.None); var rdpService = new RemoteDesktopService(this.serviceProvider); var session = rdpService.Connect( testInstance.InstanceReference, "localhost", (ushort)tunnel.LocalPort, new VmInstanceSettings() { Username = credentials.UserName, Password = credentials.SecurePassword, ConnectionBar = connectionBarState, DesktopSize = desktopSize, AudioMode = audioMode, RedirectClipboard = redirectClipboard, AuthenticationLevel = RdpAuthenticationLevel.NoServerAuthentication, BitmapPersistence = RdpBitmapPersistence.Disabled }); AwaitEvent <RemoteDesktopConnectionSuceededEvent>(); Assert.IsNull(this.ExceptionShown); RemoteDesktopWindowClosedEvent expectedEvent = null; this.serviceProvider.GetService <IEventService>() .BindHandler <RemoteDesktopWindowClosedEvent>(e => { expectedEvent = e; }); session.Close(); Assert.IsNotNull(expectedEvent); } }
public async Task WhenRequireUserAuthenticationForRemoteConnectionsByNlaEnabled_ThenConnectionSucceeds( [WindowsInstance(InitializeScript = @" & reg add ""HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"" /t REG_DWORD /v UserAuthentication /d 1 /f | Out-Default ")] InstanceRequest testInstance) { await testInstance.AwaitReady(); using (var tunnel = RdpTunnel.Create(testInstance.InstanceReference)) { var session = await Connect(tunnel, testInstance.InstanceReference); AwaitEvent <RemoteDesktopConnectionSuceededEvent>(); Assert.IsNull(this.ExceptionShown); RemoteDesktopWindowClosedEvent expectedEvent = null; this.serviceProvider.GetService <IEventService>() .BindHandler <RemoteDesktopWindowClosedEvent>(e => { expectedEvent = e; }); session.Close(); Assert.IsNotNull(expectedEvent); } }
public async Task WhenRequireUseOfSpecificSecurityLayerForRdpConnectionsSetToSsl_ThenConnectionSucceeds( [WindowsInstance(InitializeScript = @" & reg add ""HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"" /t REG_DWORD /v SecurityLayer /d 2 /f | Out-Default ")] InstanceRequest testInstance, [Credential] CredentialRequest credential) { await testInstance.AwaitReady(); using (var tunnel = RdpTunnel.Create( testInstance.Locator, await credential.GetCredentialAsync())) { var session = await Connect(tunnel, testInstance.Locator); AwaitEvent <RemoteDesktopConnectionSuceededEvent>(); Assert.IsNull(this.ExceptionShown); RemoteDesktopWindowClosedEvent expectedEvent = null; this.serviceProvider.GetService <IEventService>() .BindHandler <RemoteDesktopWindowClosedEvent>(e => { expectedEvent = e; }); Delay(TimeSpan.FromSeconds(5)); session.Close(); Assert.IsNotNull(expectedEvent); } }
private void OnRdpConnectionClosed(RemoteDesktopWindowClosedEvent e) { var node = (VmInstanceNode)TryFindNode(e.Instance); if (node != null) { node.IsConnected = false; } }