Пример #1
0
        public void Reconfiguration_MustCorrectlyHandleFailedRequest()
        {
            var downloadPath = @"C:\Folder\Does\Not\Exist\filepath.seb";
            var filename     = "filepath.seb";
            var args         = new DownloadEventArgs();

            appConfig.DownloadDirectory = @"C:\Folder\Does\Not\Exist";
            settings.ConfigurationMode  = ConfigurationMode.ConfigureClient;
            messageBox.Setup(m => m.Show(
                                 It.IsAny <TextKey>(),
                                 It.IsAny <TextKey>(),
                                 It.IsAny <MessageBoxAction>(),
                                 It.IsAny <MessageBoxIcon>(),
                                 It.IsAny <IWindow>())).Returns(MessageBoxResult.Yes);
            runtimeProxy.Setup(r => r.RequestReconfiguration(It.Is <string>(p => p == downloadPath))).Returns(new CommunicationResult(false));

            sut.TryStart();
            browserController.Raise(b => b.ConfigurationDownloadRequested += null, filename, args);
            args.Callback(true, downloadPath);

            runtimeProxy.Verify(r => r.RequestReconfiguration(It.IsAny <string>()), Times.Once);
            messageBox.Verify(m => m.Show(
                                  It.IsAny <TextKey>(),
                                  It.IsAny <TextKey>(),
                                  It.IsAny <MessageBoxAction>(),
                                  It.Is <MessageBoxIcon>(i => i == MessageBoxIcon.Error),
                                  It.IsAny <IWindow>()), Times.Once);
        }
        public void Reconfiguration_MustCorrectlyHandleDownload()
        {
            var downloadPath = @"C:\Folder\Does\Not\Exist\filepath.seb";
            var filename     = "filepath.seb";
            var args         = new DownloadEventArgs();

            appConfig.TemporaryDirectory           = @"C:\Folder\Does\Not\Exist";
            settings.Security.AllowReconfiguration = true;
            messageBox.Setup(m => m.Show(
                                 It.IsAny <TextKey>(),
                                 It.IsAny <TextKey>(),
                                 It.IsAny <MessageBoxAction>(),
                                 It.IsAny <MessageBoxIcon>(),
                                 It.IsAny <IWindow>())).Returns(MessageBoxResult.Yes);
            runtimeProxy.Setup(r => r.RequestReconfiguration(It.Is <string>(p => p == downloadPath))).Returns(new CommunicationResult(true));

            sut.TryStart();
            browser.Raise(b => b.ConfigurationDownloadRequested += null, filename, args);
            args.Callback(true, downloadPath);

            runtimeProxy.Verify(r => r.RequestReconfiguration(It.Is <string>(p => p == downloadPath)), Times.Once);

            Assert.AreEqual(downloadPath, args.DownloadPath);
            Assert.IsTrue(args.AllowDownload);
        }
Пример #3
0
        public void Reconfiguration_MustCorrectlyHandleFailedRequest()
        {
            var downloadPath = @"C:\Folder\Does\Not\Exist\filepath.seb";
            var downloadUrl  = @"https://www.host.abc/someresource.seb";
            var filename     = "filepath.seb";
            var args         = new DownloadEventArgs();

            appConfig.TemporaryDirectory           = @"C:\Folder\Does\Not\Exist";
            settings.Security.AllowReconfiguration = true;
            messageBox.Setup(m => m.Show(
                                 It.IsAny <TextKey>(),
                                 It.IsAny <TextKey>(),
                                 It.IsAny <MessageBoxAction>(),
                                 It.IsAny <MessageBoxIcon>(),
                                 It.IsAny <IWindow>())).Returns(MessageBoxResult.Yes);
            runtimeProxy.Setup(r => r.RequestReconfiguration(
                                   It.Is <string>(p => p == downloadPath),
                                   It.Is <string>(u => u == downloadUrl))).Returns(new CommunicationResult(false));

            sut.TryStart();
            browser.Raise(b => b.ConfigurationDownloadRequested += null, filename, args);
            args.Callback(true, downloadUrl, downloadPath);

            runtimeProxy.Verify(r => r.RequestReconfiguration(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            messageBox.Verify(m => m.Show(
                                  It.IsAny <TextKey>(),
                                  It.IsAny <TextKey>(),
                                  It.IsAny <MessageBoxAction>(),
                                  It.Is <MessageBoxIcon>(i => i == MessageBoxIcon.Error),
                                  It.IsAny <IWindow>()), Times.Once);
        }
Пример #4
0
        public void Reconfiguration_MustAllowIfNoQuitPasswordSet()
        {
            var args = new DownloadEventArgs();

            appConfig.TemporaryDirectory = @"C:\Folder\Does\Not\Exist";
            runtimeProxy.Setup(r => r.RequestReconfiguration(It.IsAny <string>())).Returns(new CommunicationResult(true));

            sut.TryStart();
            browser.Raise(b => b.ConfigurationDownloadRequested += null, "filepath.seb", args);
            args.Callback(true, string.Empty);

            runtimeProxy.Verify(r => r.RequestReconfiguration(It.IsAny <string>()), Times.Once);
            Assert.IsTrue(args.AllowDownload);
        }
Пример #5
0
        public void Reconfiguration_MustAllowIfUrlMatches()
        {
            var args = new DownloadEventArgs {
                Url = "sebs://www.somehost.org/some/path/some_configuration.seb?query=123"
            };

            appConfig.TemporaryDirectory           = @"C:\Folder\Does\Not\Exist";
            settings.Security.AllowReconfiguration = true;
            settings.Security.QuitPasswordHash     = "abc123";
            settings.Security.ReconfigurationUrl   = "sebs://www.somehost.org/some/path/*.seb?query=123";
            runtimeProxy.Setup(r => r.RequestReconfiguration(It.IsAny <string>())).Returns(new CommunicationResult(true));

            sut.TryStart();
            browser.Raise(b => b.ConfigurationDownloadRequested += null, "filepath.seb", args);
            args.Callback(true, string.Empty);

            runtimeProxy.Verify(r => r.RequestReconfiguration(It.IsAny <string>()), Times.Once);
            Assert.IsTrue(args.AllowDownload);
        }