Exemple #1
0
 //--- Constructors ---
 public TestScriptService(DreamHostInfo hostinfo)
 {
     _hostinfo = hostinfo;
     MockPlug.Register(_manifestUri, (p, v, u, r, r2) => r2.Return(DreamMessage.Ok(_manifest)));
     _manifest = new XDoc("extension")
                 .Elem("title", "Function Test Extension")
                 .Elem("label", "test")
                 .Elem("namespace", "test")
                 .Start("requires").Attr("host", "MindTouch Core 10.0").End();
 }
Exemple #2
0
        public void Init()
        {
            _folder = Path.GetTempPath();
            Directory.CreateDirectory(_folder);
            _storageFolder = Path.Combine(Path.GetTempPath(), StringUtil.CreateAlphaNumericKey(6));
            Directory.CreateDirectory(_storageFolder);
            XDoc config = new XDoc("config").Elem("service-dir", _folder);

            _hostInfo = DreamTestHelper.CreateRandomPortHost(config);
            CreatePrivateStorageServiceProxy();
        }
Exemple #3
0
 public void Init()
 {
     _config = new AwsS3ClientConfig {
         Endpoint   = AwsTestHelpers.AWS,
         Bucket     = "bucket",
         RootPath   = "root/path",
         PrivateKey = "private",
         PublicKey  = "public",
     };
     _hostInfo = DreamTestHelper.CreateRandomPortHost();
 }
Exemple #4
0
 public void ShutdownHost()
 {
     _withoutInstanceApiKey = false;
     lock (padlock) {
         if (_hostInfo != null)
         {
             _hostInfo.Dispose();
             _hostInfo = null;
         }
     }
 }
 public void Init()
 {
     _config = new AmazonS3ClientConfig {
         S3BaseUri  = new XUri("http://s3.amazonaws.com"),
         Bucket     = "bucket",
         RootPath   = "root/path",
         PrivateKey = "private",
         PublicKey  = "public",
     };
     _hostInfo = DreamTestHelper.CreateRandomPortHost();
 }
 public void Default_public_storage_root_cannot_be_read()
 {
     using (DreamHostInfo hostInfo = DreamTestHelper.CreateRandomPortHost()) {
         MockServiceInfo mock = MockService.CreateMockService(hostInfo);
         mock.Service.CatchAllCallback = delegate(DreamContext context, DreamMessage request, Result <DreamMessage> response2) {
             DreamMessage r = Plug.New((context.Service as MockService).Storage.Uri.WithoutLastSegment()).GetAsync().Wait();
             response2.Return(r);
         };
         DreamMessage response = mock.AtLocalMachine.GetAsync().Wait();
         Assert.AreEqual(DreamStatus.Forbidden, response.Status);
     }
 }
Exemple #7
0
        //--- Constructors ---
        public ScriptTestHarness()
        {
            _hostInfo = DreamTestHelper.CreateRandomPortHost();
            _hostInfo.Host.Self.At("load").With("name", "mindtouch.deki.services").Post(DreamMessage.Ok());
            _hostInfo.Host.Self.At("load").With("name", "mindtouch.deki").Post(DreamMessage.Ok());
            _hostInfo.Host.Self.At("load").With("name", "mindtouch.deki.script.check").Post(DreamMessage.Ok());
            XDoc config = new XDoc("config")
                          .Elem("sid", "sid://mindtouch.com/2008/09/script-test")
                          .Elem("path", SCRIPT_TEST_ROOT)
                          .Elem("debug", true);

            _hostInfo.Host.Self.At("services").Post(config);
        }
Exemple #8
0
        public void FixtureSetup()
        {
            _indexRebuilderMock = new IndexRebuilderMock();
            var builder = new ContainerBuilder();

            builder.Register(c => _searchBLFactory()).As <ISearchBL>().RequestScoped();
            builder.Register(c => _pageBLFactory()).As <IPageBL>().RequestScoped();
            builder.Register(_indexRebuilderMock).As <IIndexRebuilder>();
            _hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config").Elem("apikey", Utils.Settings.ApiKey), builder.Build());
            _hostInfo.Host.Self.At("load").With("name", "mindtouch.deki").Post(DreamMessage.Ok());
            _hostInfo.Host.Self.At("load").With("name", "mindtouch.deki.services").Post(DreamMessage.Ok());
            _hostInfo.Host.Self.At("load").With("name", "mindtouch.indexservice").Post(DreamMessage.Ok());
            _deki   = DreamTestHelper.CreateService(_hostInfo, Utils.Settings.DekiConfig);
            _search = _deki.AtLocalHost.At("site", "query");
        }
Exemple #9
0
        public void XmlAsUriWithDreamContext()
        {
            DreamHostInfo   hostInfo = DreamTestHelper.CreateRandomPortHost();
            MockServiceInfo mock     = MockService.CreateMockService(hostInfo);

            mock.Service.CatchAllCallback = delegate(DreamContext context, DreamMessage request, Result <DreamMessage> response) {
                XUri uri = mock.AtLocalMachine.Uri;
                XDoc doc = new XDoc("test").Elem("uri", uri);
                Assert.AreEqual(uri.AsPublicUri().ToString(), doc["uri"].AsText);
                Assert.AreEqual(uri, doc["uri"].AsUri);
                response.Return(DreamMessage.Ok(doc));
            };
            DreamMessage result = mock.AtLocalMachine.PostAsync().Wait();

            Assert.IsTrue(result.IsSuccessful, "failure in service");
            Assert.AreEqual(mock.AtLocalHost.Uri.WithoutQuery(), result.ToDocument()["uri"].AsUri);
        }
        public void GlobalSetup()
        {
            var config  = new XDoc("config");
            var builder = new ContainerBuilder();

            _smtpClientFactory = new SmtpClientFactoryMock();
            builder.Register(c => _smtpClientFactory).As <ISmtpClientFactory>().ServiceScoped();
            _hostInfo     = DreamTestHelper.CreateRandomPortHost(config, builder.Build());
            _emailService = DreamTestHelper.CreateService(
                _hostInfo,
                "sid://mindtouch.com/2009/01/dream/email",
                "email",
                new XDoc("config")
                .Elem("apikey", "servicekey")
                .Elem("smtp-host", DEFAULT_HOST)
                );
            _plug = _emailService.WithInternalKey().AtLocalHost;
        }
Exemple #11
0
        public void Init()
        {
            var config  = new XDoc("config");
            var builder = new ContainerBuilder();

            builder.Register((c, p) => {
                var s3Config = p.TypedAs <AmazonS3ClientConfig>();
                var mock     = new Mock <IAmazonS3Client>();
                Assert.AreEqual("test", s3Config.RootPath);
                Assert.AreEqual("http://s3.amazonaws.com", s3Config.S3BaseUri.ToString());
                Assert.AreEqual("test-bucket", s3Config.Bucket);
                Assert.AreEqual("test-private", s3Config.PrivateKey);
                Assert.AreEqual("test-public", s3Config.PublicKey);
                Assert.IsNull(_s3ClientMock, "test storage already resolved");
                _s3ClientMock = mock;
                return(mock.Object);
            }).As <IAmazonS3Client>().ServiceScoped();
            _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build());
        }
Exemple #12
0
        public void Init()
        {
            var config  = new XDoc("config");
            var builder = new ContainerBuilder();

            builder.Register((c, p) => {
                var s3Config = p.TypedAs <AwsS3ClientConfig>();
                var mock     = new Mock <IAwsS3Client>();
                Assert.AreEqual("test", s3Config.RootPath);
                Assert.AreEqual("default", s3Config.Endpoint.Name);
                Assert.AreEqual("test-bucket", s3Config.Bucket);
                Assert.AreEqual("test-private", s3Config.PrivateKey);
                Assert.AreEqual("test-public", s3Config.PublicKey);
                Assert.IsNull(_s3ClientMock, "test storage already resolved");
                _s3ClientMock = mock;
                return(mock.Object);
            }).As <IAwsS3Client>().ServiceScoped();
            _hostInfo = DreamTestHelper.CreateRandomPortHost(config, builder.Build(ContainerBuildOptions.None));
        }
 public void GlobalInit()
 {
     _hostInfo = DreamTestHelper.CreateRandomPortHost();
 }
Exemple #14
0
 internal MockServiceInfo(DreamHostInfo hostInfo, string path, MockService service)
 {
     AtLocalMachine = Plug.New(hostInfo.Host.LocalMachineUri.At(path));
     AtLocalHost = Plug.New(hostInfo.LocalHost.At(path));
     Service = service;
 }
Exemple #15
0
 public void GlobalSetup()
 {
     _hostInfo     = DreamTestHelper.CreateRandomPortHost();
     _queueService = DreamTestHelper.CreateService(_hostInfo, "sid://mindtouch.com/2009/12/dream/queue", "queue", new XDoc("config").Elem("folder", Path.GetTempPath()));
     _plug         = _queueService.WithInternalKey().AtLocalHost;
 }
 public void FixtureSetup()
 {
     _hostInfo = DreamTestHelper.CreateRandomPortHost(new XDoc("config").Elem("apikey", "123"));
     _hostInfo.Host.Self.At("load").With("name", "mindtouch.deki.services").Post(DreamMessage.Ok());
 }
Exemple #17
0
 internal MockServiceInfo(DreamHostInfo hostInfo, string path, MockService service)
 {
     AtLocalMachine = Plug.New(hostInfo.Host.LocalMachineUri.At(path));
     AtLocalHost    = Plug.New(hostInfo.LocalHost.At(path));
     Service        = service;
 }
 public void PerTestCleanup()
 {
     MockPlug.DeregisterAll();
     _hostInfo = null;
     _log.Debug("cleaned up");
 }
Exemple #19
0
 public void FixtureSetup()
 {
     _hostInfo = DreamTestHelper.CreateRandomPortHost();
 }
 public void PerTestSetup()
 {
     _hostInfo = DreamTestHelper.CreateRandomPortHost();
 }