Example #1
0
 public IApplicationClient Create(ICloudRunner runner) => new ApplicationClientStub(
     new List <Application>()
 {
     new Application {
         Name = "Yeti Development Application", Id = "yeti-dev-app"
     }
 });
 // Constructor for tests.
 public GgpDebugQueryTarget(IFileSystem fileSystem, SdkConfig.Factory sdkConfigFactory,
                            IGameletClientFactory gameletClientFactory,
                            IApplicationClientFactory applicationClientFactory,
                            CancelableTask.Factory cancelableTaskFactory,
                            IDialogUtil dialogUtil, IRemoteDeploy remoteDeploy,
                            DebugSessionMetrics metrics,
                            ICredentialManager credentialManager,
                            ITestAccountClientFactory testAccountClientFactory,
                            IGameletSelectorFactory gameletSelectorFactory,
                            ICloudRunner cloudRunner, Versions.SdkVersion sdkVersion,
                            ChromeClientLaunchCommandFormatter launchCommandFormatter,
                            DebugEngine.DebugEngine.Params.Factory paramsFactory,
                            IYetiVSIService yetiVsiService, IGameLauncher gameLauncher)
 {
     _fileSystem               = fileSystem;
     _sdkConfigFactory         = sdkConfigFactory;
     _gameletClientFactory     = gameletClientFactory;
     _applicationClientFactory = applicationClientFactory;
     _cancelableTaskFactory    = cancelableTaskFactory;
     _dialogUtil               = dialogUtil;
     _remoteDeploy             = remoteDeploy;
     _metrics                  = metrics;
     _credentialManager        = credentialManager;
     _testAccountClientFactory = testAccountClientFactory;
     _cloudRunner              = cloudRunner;
     _yetiVsiService           = yetiVsiService;
     _gameletSelectorFactory   = gameletSelectorFactory;
     _sdkVersion               = sdkVersion;
     _launchCommandFormatter   = launchCommandFormatter;
     _paramsFactory            = paramsFactory;
     _gameLauncher             = gameLauncher;
 }
Example #3
0
 public SshManager(IGameletClientFactory gameletClientFactory, ICloudRunner cloudRunner,
                   ISshKeyLoader sshKeyLoader, ISshKnownHostsWriter sshKnownHostsWriter,
                   IRemoteCommand remoteCommand)
 {
     this.gameletClientFactory = gameletClientFactory;
     this.cloudRunner          = cloudRunner;
     this.sshKeyLoader         = sshKeyLoader;
     this.sshKnownHostsWriter  = sshKnownHostsWriter;
     this.remoteCommand        = remoteCommand;
 }
Example #4
0
        /// <summary>
        /// Intercept all cloud calls using the given action.
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when any argument is null.</exception>
        public static ICloudRunner Intercept(this ICloudRunner runner, IAction action)
        {
            if (runner == null)
            {
                throw new ArgumentNullException(nameof(runner));
            }
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            return(new CloudRunnerProxy(runner, new MetricsInterceptor(action)));
        }
        public virtual ISshManager GetSshManager(ManagedProcess.Factory managedProcessFactory,
                                                 ICloudRunner cloudRunner)
        {
            if (_sshManager == null)
            {
                var sshKeyLoader        = new SshKeyLoader(managedProcessFactory);
                var sshKnownHostsWriter = new SshKnownHostsWriter();
                _sshManager = new SshManager(GetGameletClientFactory(), cloudRunner, sshKeyLoader,
                                             sshKnownHostsWriter,
                                             GetRemoteCommand(managedProcessFactory));
            }

            return(_sshManager);
        }
Example #6
0
 // Creates a DebugPortSupplier with specific factories.  Used by tests.
 public DebugPortSupplier(DebugPort.Factory debugPortFactory,
                          GameletClient.Factory gameletClientFactory,
                          IExtensionOptions options, IDialogUtil dialogUtil,
                          CancelableTask.Factory cancelableTaskFactory, IMetrics metrics,
                          ICloudRunner cloudRunner, string developerAccount)
 {
     _debugPortFactory      = debugPortFactory;
     _gameletClientFactory  = gameletClientFactory;
     _dialogUtil            = dialogUtil;
     _cancelableTaskFactory = cancelableTaskFactory;
     _metrics          = metrics;
     _cloudRunner      = cloudRunner;
     _developerAccount = developerAccount;
 }
Example #7
0
        public void SetUp()
        {
            gameletClient        = Substitute.For <IGameletClient>();
            gameletClientFactory = Substitute.For <GameletClient.Factory>();
            gameletClientFactory.Create(Arg.Any <ICloudRunner>()).Returns(gameletClient);

            cloudRunner         = Substitute.For <ICloudRunner>();
            sshKeyLoader        = Substitute.For <ISshKeyLoader>();
            sshKnownHostsWriter = Substitute.For <ISshKnownHostsWriter>();
            remoteCommand       = Substitute.For <IRemoteCommand>();

            sshManager = new SshManager(gameletClientFactory, cloudRunner, sshKeyLoader,
                                        sshKnownHostsWriter, remoteCommand);
        }
Example #8
0
        public CoreAttachWindow(IServiceProvider serviceProvider)
        {
            var serviceManager = new ServiceManager();

            _taskContext = serviceManager.GetJoinableTaskContext();

            _dialogUtil = new DialogUtil();
            IExtensionOptions options =
                ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService)))
                .Options;
            var managedProcessFactory = new ManagedProcess.Factory();
            var progressDialogFactory = new ProgressDialog.Factory();

            _cancelableTaskFactory =
                new CancelableTask.Factory(_taskContext, progressDialogFactory);
            _coreListRequest = new CoreListRequest.Factory().Create();
            var jsonUtil = new JsonUtil();
            var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil);
            var accountOptionLoader     = new VsiAccountOptionLoader(options);
            var credentialManager       =
                new CredentialManager(credentialConfigFactory, accountOptionLoader);

            _developerAccount = credentialManager.LoadAccount();
            IRemoteCommand remoteCommand = new RemoteCommand(managedProcessFactory);

            _remoteFile = new RemoteFile(managedProcessFactory);
            var cloudConnection  = new CloudConnection();
            var sdkConfigFactory = new SdkConfig.Factory(jsonUtil);

            // NOTE: the lifetime of this CloudRunner is limited to the current CoreAttachWindow.
            _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                           new GgpSDKUtil());
            _gameletClientFactory = new GameletClient.Factory();
            var sshKeyLoader        = new SshKeyLoader(managedProcessFactory);
            var sshKnownHostsWriter = new SshKnownHostsWriter();

            _sshManager = new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader,
                                         sshKnownHostsWriter, remoteCommand);
            _debugSessionMetrics = new DebugSessionMetrics(
                serviceProvider.GetService(typeof(SMetrics)) as IMetrics);
            _debugSessionMetrics.UseNewDebugSessionId();
            _actionRecorder = new ActionRecorder(_debugSessionMetrics);

            InitializeComponent();
            _instanceSelectionWindowFactory = new ProjectInstanceSelection.Factory();
            _paramsFactory = new DebugEngine.DebugEngine.Params.Factory(jsonUtil);
            SelectInstanceOnInit();
        }
Example #9
0
 public GameletSelectorLegacyFlow(
     IDialogUtil dialogUtil, ICloudRunner runner,
     InstanceSelectionWindow.Factory gameletSelectionWindowFactory,
     CancelableTask.Factory cancelableTaskFactory,
     IGameletClientFactory gameletClientFactory, ISshManager sshManager,
     IRemoteCommand remoteCommand, ActionRecorder actionRecorder)
 {
     _dialogUtil = dialogUtil;
     _runner     = runner;
     _gameletSelectionWindowFactory = gameletSelectionWindowFactory;
     _cancelableTaskFactory         = cancelableTaskFactory;
     _gameletClientFactory          = gameletClientFactory;
     _sshManager    = sshManager;
     _remoteCommand = remoteCommand;
     _mountChecker  =
         new GameletMountChecker(remoteCommand, dialogUtil, cancelableTaskFactory);
     _actionRecorder = actionRecorder;
 }
Example #10
0
 public GameletSelectorFactory(IDialogUtil dialogUtil, ICloudRunner runner,
                               InstanceSelectionWindow.Factory gameletSelectionWindowFactory,
                               CancelableTask.Factory cancelableTaskFactory,
                               IGameletClientFactory gameletClientFactory,
                               ISshManager sshManager, IRemoteCommand remoteCommand,
                               IGameLaunchBeHelper gameLaunchBeHelper,
                               JoinableTaskContext taskContext)
 {
     _dialogUtil = dialogUtil;
     _runner     = runner;
     _gameletSelectionWindowFactory = gameletSelectionWindowFactory;
     _cancelableTaskFactory         = cancelableTaskFactory;
     _gameletClientFactory          = gameletClientFactory;
     _sshManager         = sshManager;
     _remoteCommand      = remoteCommand;
     _gameLaunchBeHelper = gameLaunchBeHelper;
     _taskContext        = taskContext;
 }
Example #11
0
        // Creates a DebugPortSupplier.  This will be invoked by Visual Studio based on this class
        // Guid being in the registry.
        public DebugPortSupplier()
        {
            // Factory creation for the PortSupplier entry point.
            var serviceManager        = new ServiceManager();
            IExtensionOptions options =
                ((YetiVSIService)serviceManager.RequireGlobalService(typeof(YetiVSIService)))
                .Options;
            var taskContext               = serviceManager.GetJoinableTaskContext();
            var debugPropertyFactory      = new DebugProperty.Factory();
            var debugProgramFactory       = new DebugProgram.Factory(debugPropertyFactory, options);
            var debugProcessFactory       = new DebugProcess.Factory(debugProgramFactory);
            var managedProcessFactory     = new ManagedProcess.Factory();
            var processListRequestFactory = new ProcessListRequest.Factory(managedProcessFactory);
            var jsonUtil                = new JsonUtil();
            var sdkConfigFactory        = new SdkConfig.Factory(jsonUtil);
            var credentialConfigFactory = new CredentialConfig.Factory(jsonUtil);
            var accountOptionLoader     = new VsiAccountOptionLoader(options);
            var credentialManager       =
                new CredentialManager(credentialConfigFactory, accountOptionLoader);

            _developerAccount = credentialManager.LoadAccount();
            _dialogUtil       = new DialogUtil();
            var progressDialogFactory = new ProgressDialog.Factory();

            _cancelableTaskFactory = new CancelableTask.Factory(taskContext, progressDialogFactory);
            var cloudConnection = new CloudConnection();

            // NOTE: this CloudRunner is re-used for all subsequent Attach to Process windows.
            _cloudRunner = new CloudRunner(sdkConfigFactory, credentialManager, cloudConnection,
                                           new GgpSDKUtil());
            var sshKeyLoader        = new SshKeyLoader(managedProcessFactory);
            var sshKnownHostsWriter = new SshKnownHostsWriter();

            _gameletClientFactory = new GameletClient.Factory();
            var sshManager =
                new SshManager(_gameletClientFactory, _cloudRunner, sshKeyLoader,
                               sshKnownHostsWriter, new RemoteCommand(managedProcessFactory));

            _metrics          = (IMetrics)serviceManager.RequireGlobalService(typeof(SMetrics));
            _debugPortFactory = new DebugPort.Factory(
                debugProcessFactory, processListRequestFactory, _cancelableTaskFactory, _dialogUtil,
                sshManager, _metrics, _developerAccount);
        }
        /// <summary>
        /// Load the application given a string representing the app id or name.
        /// </summary>
        /// <exception cref="InvalidStateException">Thrown if the application doesn't exist
        /// </exception>
        /// <exception cref="ConfigurationException">Thrown if applicationNameOrId is null
        /// or empty</exception>
        async Task <Application> LoadApplicationAsync(ICloudRunner runner,
                                                      string applicationNameOrId)
        {
            if (string.IsNullOrEmpty(applicationNameOrId))
            {
                throw new ConfigurationException(ErrorStrings.NoApplicationConfigured);
            }

            var application = await _applicationClientFactory.Create(runner)
                              .LoadByNameOrIdAsync(applicationNameOrId);

            if (application == null)
            {
                throw new InvalidStateException(
                          ErrorStrings.FailedToRetrieveApplication(applicationNameOrId));
            }

            return(application);
        }
Example #13
0
 public GameletSelector(IDialogUtil dialogUtil, ICloudRunner runner,
                        InstanceSelectionWindow.Factory gameletSelectionWindowFactory,
                        CancelableTask.Factory cancelableTaskFactory,
                        IGameletClientFactory gameletClientFactory, ISshManager sshManager,
                        IRemoteCommand remoteCommand, IGameLaunchBeHelper gameLaunchBeHelper,
                        JoinableTaskContext taskContext, ActionRecorder actionRecorder)
 {
     _dialogUtil = dialogUtil;
     _runner     = runner;
     _gameletSelectionWindowFactory = gameletSelectionWindowFactory;
     _cancelableTaskFactory         = cancelableTaskFactory;
     _gameletClientFactory          = gameletClientFactory;
     _sshManager    = sshManager;
     _remoteCommand = remoteCommand;
     _mountChecker  =
         new GameletMountChecker(remoteCommand, dialogUtil, cancelableTaskFactory);
     _gameLaunchBeHelper = gameLaunchBeHelper;
     _taskContext        = taskContext;
     _actionRecorder     = actionRecorder;
 }
        /// <summary>
        /// Load a test account given the organization id, project id and test account
        /// (Stadia Name). Returns null if the test account is empty or null.
        /// </summary>
        /// <exception cref="ConfigurationException">Thrown if the given test account doesn't exist
        /// or if there is more than one test account with the given name.
        /// </exception>
        async Task <TestAccount> LoadTestAccountAsync(ICloudRunner runner, string organizationId,
                                                      string projectId, string testAccount)
        {
            if (string.IsNullOrEmpty(testAccount))
            {
                return(null);
            }

            var testAccounts = await _testAccountClientFactory.Create(runner)
                               .LoadByIdOrGamerTagAsync(organizationId, projectId, testAccount);

            if (testAccounts.Count == 0)
            {
                throw new ConfigurationException(ErrorStrings.InvalidTestAccount(testAccount));
            }

            if (testAccounts.Count > 1)
            {
                throw new ConfigurationException(
                          ErrorStrings.MoreThanOneTestAccount(testAccounts[0].GamerTagName));
            }

            return(testAccounts[0]);
        }
Example #15
0
 public IGameletClient Create(ICloudRunner runner) =>
 new GameletClientStub(_instances, _lastLaunches);
 public override ISshManager GetSshManager(ManagedProcess.Factory managedProcessFactory,
                                           ICloudRunner cloudRunner) =>
 Substitute.For <ISshManager>();
Example #17
0
 public ITestAccountClient Create(ICloudRunner runner) =>
 new TestAccountClientStub(new HashSet <string>()
 {
     "gamer#1234"
 });