Exemplo n.º 1
0
        public void CreateFileTest()
        {
            using (HttpClient client = ApiHttpClient.Create($"{Globals.TEST_SERVER}:{Globals.TEST_PORT}")) {
                string fileName = "test_file";

                // Web Server Scope
                JObject webServerFeature = GetDefaultDocumentFeature(client, null, null);
                Assert.NotNull(webServerFeature);

                CreateAndRemoveFile(client, webServerFeature, fileName);

                // Site Scope
                Sites.EnsureNoSite(client, TEST_SITE_NAME);
                JObject site        = Sites.CreateSite(client, TEST_SITE_NAME, 50311, @"c:\sites\test_site");
                JObject siteFeature = GetDefaultDocumentFeature(client, site.Value <string>("name"), null);
                Assert.NotNull(siteFeature);

                CreateAndRemoveFile(client, siteFeature, fileName);

                // Application Scope
                JObject app        = Applications.CreateApplication(client, "test_app", @"c:\sites\test_site\test_application", site);
                JObject appFeature = GetDefaultDocumentFeature(client, site.Value <string>("name"), app.Value <string>("path"));
                Assert.NotNull(appFeature);

                CreateAndRemoveFile(client, appFeature, fileName);

                // Vdir Scope
                JObject vdir        = VirtualDirectories.CreateVdir(client, "test_vdir", @"c:\sites\test_site\test_vdir", site);
                JObject vdirFeature = GetDefaultDocumentFeature(client, site.Value <string>("name"), vdir.Value <string>("path"));
                Assert.NotNull(vdirFeature);

                CreateAndRemoveFile(client, vdirFeature, fileName);

                // Directory Scope
                JObject directoryFeature = GetDefaultDocumentFeature(client, site.Value <string>("name"), "/test_directory");
                Assert.NotNull(directoryFeature);

                CreateAndRemoveFile(client, directoryFeature, fileName);
            }
        }
Exemplo n.º 2
0
        public void CreateAndCleanup()
        {
            bool pass = false;

            using (HttpClient client = ApiHttpClient.Create($"{Globals.TEST_SERVER}:{Globals.TEST_PORT}")) {
                _output.WriteLine($"Running Virtual Directory tests with Virtual Directory {TEST_VDIR}");

                Sites.EnsureNoSite(client, TEST_SITE_NAME);

                JObject site;

                if (Sites.CreateSite(client, TEST_SITE, out site))
                {
                    string app = TEST_APPLICATION.Replace("{site_id}", site.Value <string>("id"));

                    JObject testApp;

                    if (Applications.CreateApplication(client, app, out testApp))
                    {
                        string vdir = TEST_VDIR.Replace("{app_id}", testApp.Value <string>("id"));

                        JObject jVdir;
                        if (CreateVdir(client, vdir, out jVdir))
                        {
                            string vdirUri = Utils.Self(jVdir);

                            pass = VdirExists(client, vdirUri);

                            Assert.True(DeleteVdir(client, vdirUri));
                        }

                        Assert.True(Applications.DeleteApplication(client, Utils.Self(testApp)));
                    }

                    Assert.True(Sites.DeleteSite(client, Utils.Self(site)));
                }
                Assert.True(pass);
            }
        }
Exemplo n.º 3
0
        public void ChangeAllProperties()
        {
            using (HttpClient client = ApiHttpClient.Create($"{Globals.TEST_SERVER}:{Globals.TEST_PORT}")) {
                // Web Server Scope
                JObject webServerFeature = GetCompressionFeature(client, null, null);

                ChangeAndRestoreProps(client, webServerFeature);

                // Site Scope
                Sites.EnsureNoSite(client, TEST_SITE_NAME);
                JObject site        = Sites.CreateSite(client, TEST_SITE_NAME, 53010, @"c:\sites\test_site");
                JObject siteFeature = GetCompressionFeature(client, site.Value <string>("name"), null);

                ChangeAndRestoreProps(client, siteFeature);

                // Application Scope
                JObject app        = Applications.CreateApplication(client, "test_app", @"c:\sites\test_site\test_application", site);
                JObject appFeature = GetCompressionFeature(client, site.Value <string>("name"), app.Value <string>("path"));
                Assert.NotNull(appFeature);

                ChangeAndRestoreProps(client, appFeature);

                // Vdir Scope
                JObject vdir        = VirtualDirectories.CreateVdir(client, "test_vdir", @"c:\sites\test_site\test_vdir", site);
                JObject vdirFeature = GetCompressionFeature(client, site.Value <string>("name"), vdir.Value <string>("path"));
                Assert.NotNull(vdirFeature);

                ChangeAndRestoreProps(client, vdirFeature);

                // Directory Scope
                JObject directoryFeature = GetCompressionFeature(client, site.Value <string>("name"), "/test_directory");
                Assert.NotNull(directoryFeature);

                ChangeAndRestoreProps(client, directoryFeature);

                Sites.DeleteSite(client, Utils.Self(site));
            }
        }