Example #1
0
        private void OnRdpConnectionSucceeded(ConnectionSuceededEvent e)
        {
            var node = (VmInstanceNode)TryFindNode(e.Instance);

            if (node != null)
            {
                node.IsConnected = true;
            }
        }
Example #2
0
        private async Task <SshTerminalPane> ConnectSshTerminalPane(
            InstanceLocator instanceLocator,
            ICredential credential)
        {
            var authorization = new Mock <IAuthorization>();

            authorization
            .SetupGet(a => a.Email)
            .Returns("*****@*****.**");
            var authorizationAdapter = new Mock <IAuthorizationAdapter>();

            authorizationAdapter
            .Setup(a => a.Authorization)
            .Returns(authorization.Object);

            using (var key = new RsaSshKey(new RSACng()))
                using (var keyAdapter = new AuthorizedKeyService(
                           authorizationAdapter.Object,
                           new ComputeEngineAdapter(credential),
                           new ResourceManagerAdapter(credential),
                           new Mock <IOsLoginService>().Object))
                {
                    var authorizedKey = await keyAdapter.AuthorizeKeyAsync(
                        instanceLocator,
                        key,
                        TimeSpan.FromMinutes(10),
                        null,
                        AuthorizeKeyMethods.InstanceMetadata,
                        CancellationToken.None)
                                        .ConfigureAwait(true);

                    // Connect and wait for event
                    ConnectionSuceededEvent connectedEvent = null;
                    this.eventService.BindHandler <ConnectionSuceededEvent>(e => connectedEvent = e);

                    var broker = new SshTerminalConnectionBroker(
                        this.serviceProvider);
                    var pane = await broker.ConnectAsync(
                        instanceLocator,
                        new IPEndPoint(await PublicAddressFromLocator(instanceLocator), 22),
                        authorizedKey)
                               .ConfigureAwait(true);

                    Assert.IsNotNull(connectedEvent, "ConnectionSuceededEvent event fired");
                    PumpWindowMessages();

                    return((SshTerminalPane)pane);
                }
        }
Example #3
0
        public async Task WhenAuthenticationSucceeds_ThenConnectionSuceededEventEventIsFired(
            [LinuxInstance] ResourceTask <InstanceLocator> instanceLocatorTask,
            [Credential(Role = PredefinedRole.ComputeInstanceAdminV1)] ResourceTask <ICredential> credential)
        {
            ConnectionSuceededEvent connectedEvent = null;

            this.eventService.BindHandler <ConnectionSuceededEvent>(e => connectedEvent = e);

            using (var pane = await ConnectSshTerminalPane(
                       await instanceLocatorTask,
                       await credential))
            {
                // Close the pane (not the window).
                pane.Close();

                Assert.IsNotNull(connectedEvent, "ConnectionSuceededEvent event fired");
            }
        }