예제 #1
0
        async Task CanConstructConfigurationStanza()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ConfigurationStanza.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedConfigurationSettingNames = new string[]
                {
                    "_name",
                    "command",
                    "hostname",
                    "inline",
                    "maxresults",
                    "maxtime",
                    "track_alert",
                    "ttl"
                };

                var configurationStanza = new ConfigurationStanza(context, feed);

                Assert.Equal(expectedConfigurationSettingNames, from setting in configurationStanza select setting.Title);
                Assert.Equal(expectedConfigurationSettingNames.Length, configurationStanza.Count);

                for (int i = 0; i < configurationStanza.Count; i++)
                {
                    Assert.Equal(expectedConfigurationSettingNames[i], configurationStanza[i].Title);

                    Assert.DoesNotThrow(() => { var value = configurationStanza[i].Id; });
                    Assert.DoesNotThrow(() => { var value = configurationStanza[i].Links; });
                    Assert.DoesNotThrow(() => { var value = configurationStanza[i].Updated; });
                    Assert.DoesNotThrow(() => { var value = configurationStanza[i].Value; });
                }
            }
        }
예제 #2
0
        async Task CanConstructStoragePasswordCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "StoragePasswordCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedNames = new string[]
                {
                    ":foobar:",
                    "splunk.com:foobar:",
                    "splunk\\:com:foobar:"
                };

                var passwords = new StoragePasswordCollection(context, feed);

                Assert.Equal(expectedNames, from password in passwords select password.Title);
                Assert.Equal(expectedNames.Length, passwords.Count);
                CheckCommonProperties("passwords", passwords);

                for (int i = 0; i < passwords.Count; i++)
                {
                    var entry    = feed.Entries[i];
                    var password = passwords[i];
                    CheckStoragePassword(entry, password);
                }
            }
        }
예제 #3
0
        async Task CanConstructIndexCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "IndexCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedNames = new string[]
                {
                    "_audit",
                    "_blocksignature",
                    "_internal",
                    "_thefishbucket",
                    "history",
                    "main",
                    "splunklogger",
                    "summary"
                };

                var indexes = new ConfigurationCollection(context, feed);

                Assert.Equal(expectedNames, from index in indexes select index.Title);
                Assert.Equal(expectedNames.Length, indexes.Count);
                CheckCommonProperties("indexes", indexes);

                for (int i = 0; i < indexes.Count; i++)
                {
                    CheckCommonProperties(expectedNames[i], indexes[i]);
                }
            }
        }
예제 #4
0
        async Task CanConstructConfiguration()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "Configuration.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedConfigurationStanzaNames = new string[]
                {
                    "default",
                    "email",
                    "populate_lookup",
                    "rss",
                    "script",
                    "summary_index"
                };

                var configuration = new Configuration(context, feed);

                Assert.Equal(expectedConfigurationStanzaNames, from configurationStanza in configuration select configurationStanza.Title);
                Assert.Equal(expectedConfigurationStanzaNames.Length, configuration.Count);

                for (int i = 0; i < configuration.Count; i++)
                {
                    Assert.Equal(expectedConfigurationStanzaNames[i], configuration[i].Title);

                    Assert.DoesNotThrow(() => { var value = configuration[i].GeneratorVersion; });
                    Assert.DoesNotThrow(() => { var value = configuration[i].Id; });
                    Assert.DoesNotThrow(() => { var value = configuration[i].Updated; });

                    Assert.Equal(0, configuration[i].Count);
                    Assert.Throws <ArgumentOutOfRangeException>(() => { var value = configuration[i][0]; });
                }
            }
        }
        async Task CanConstructApplicationCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ApplicationCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedApplicationNames = new string[]
                {
                    "delete-me-cc314e4eda254dec885f9465e55729e5",
                    "delete-me-db1bc2678174495a9f91d0c2360f53bc",
                    "delete-me-decd5a97569440768914cd0629c5501d",
                    "delete-me-e341f711346a4898b15accd7f77c5c92",
                    "framework",
                    "gettingstarted",
                    "introspection_generator_addon",
                    "launcher",
                    "learned",
                    "legacy",
                    "sample_app",
                    "search",
                    "splunk_datapreview",
                    "SplunkForwarder",
                    "SplunkLightForwarder"
                };

                var applications = new ApplicationCollection(context, feed);

                Assert.Equal(expectedApplicationNames, from application in applications select application.Title);
                Assert.Equal(expectedApplicationNames.Length, applications.Count);

                for (int i = 0; i < applications.Count; i++)
                {
                    Assert.Equal(expectedApplicationNames[i], applications[i].Title);

                    Assert.DoesNotThrow(() => {
                        Version value = applications[i].GeneratorVersion;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() =>
                    {
                        Uri value = applications[i].Id;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() =>
                    {
                        string value = applications[i].Title;
                        Assert.NotNull(value);
                    });

                    Assert.DoesNotThrow(() =>
                    {
                        DateTime value = applications[i].Updated;
                        Assert.NotEqual(DateTime.MinValue, value);
                    });
                }
            }
        }
        async Task CanConstructApplication()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "Application.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                Assert.DoesNotThrow(() => new Application(context, feed));
            }
        }
예제 #7
0
        public async Task CanConstructResource()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "JobCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                dynamic collection = new ResourceCollection(feed);
                CheckCommonStaticPropertiesOfResource(collection);

                //// Static property checks

                Assert.Equal("jobs", collection.Title);
                Assert.Throws <RuntimeBinderException>(() => { var p = collection.Links; });
                Assert.Throws <RuntimeBinderException>(() => { var p = collection.Messages; });

                Assert.DoesNotThrow(() =>
                {
                    Pagination p = collection.Pagination;
                    Assert.Equal(14, p.TotalResults);
                    Assert.Equal(0, p.StartIndex);
                    Assert.Equal(0, p.ItemsPerPage);
                });

                Assert.DoesNotThrow(() =>
                {
                    ReadOnlyCollection <Resource> p = collection.Resources;
                    Assert.Equal(14, p.Count);
                });

                foreach (var resource in collection.Resources)
                {
                    CheckCommonStaticPropertiesOfResource(resource);
                    CheckExistenceOfJobProperties(resource);
                    Assert.IsType(typeof(Resource), resource);
                }

                { dynamic resource = collection.Resources[0];

                  CheckCommonStaticPropertiesOfResource(resource);

                  Assert.IsType(typeof(Uri), resource.Id);
                  Assert.Equal("https://localhost:8089/services/search/jobs/scheduler__admin__search__RMD50aa4c13eb03d1730_at_1401390000_866", resource.Id.ToString());

                  Assert.IsType(typeof(string), resource.Content.Sid);
                  Assert.Equal("scheduler__admin__search__RMD50aa4c13eb03d1730_at_1401390000_866", resource.Content.Sid);

                  Assert.IsType(typeof(string), resource.Title);
                  Assert.Equal("search search index=_internal | head 1000", resource.Title);

                  Assert.NotNull(resource.Links);
                  Assert.IsType(typeof(ReadOnlyDictionary <string, Uri>), resource.Links);
                  Assert.Equal(new string[] { "alternate", "search.log", "events", "results", "results_preview", "timeline", "summary", "control" }, resource.Links.Keys);

                  CheckExistenceOfJobProperties(resource); }
            }
        }
예제 #8
0
        async Task CanConstructStoragePassword()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "StoragePassword.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var password = new StoragePassword(context, feed);
                CheckStoragePassword(feed.Entries[0], password);
            }
        }
예제 #9
0
        async Task CanConstructJob()
        {
            var entry = await TestAtomFeed.ReadEntry(Path.Combine(TestAtomFeed.Directory, "Job.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var job = new Job(context, entry);
                CheckJob(entry, job);
            }
        }
예제 #10
0
        public async Task CanConstructEntity()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "Application.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var entity = new Entity <Resource>(context, feed);
                CheckApplication(entity, feed.Entries[0], feed.GeneratorVersion);
            }
        }
예제 #11
0
        public async Task CanConstructEntityCollectionOfEntityCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ConfigurationCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var collection = new EntityCollection <EntityCollection <Entity <Resource>, Resource>, ResourceCollection>(context, feed);

                CheckCommonStaticPropertiesEntity(collection);
                Assert.Equal("properties", collection.Name);
                Assert.Equal(83, collection.Count);

                foreach (EntityCollection <Entity <Resource>, Resource> entity in collection)
                {
                    Assert.Equal(0, entity.Count);
                }
            }
        }
예제 #12
0
        async Task CanConstructIndex()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "Index.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var index = new Index(context, feed);
                CheckCommonProperties("_audit", index);

                Assert.DoesNotThrow(() =>
                {
                    bool canList = index.Eai.Acl.CanList;
                    string app   = index.Eai.Acl.App;
                    dynamic eai  = index.Eai;
                    Assert.Equal(app, eai.Acl.App);
                    Assert.Equal(canList, eai.Acl.CanList);
                });
            }
        }
예제 #13
0
        async Task CanConstructServerSettings()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ServerSettings.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var serverSettings = new ServerSettings(feed);

                //// TODO: Match contents of feed to contents of resource; in this case serverInfo

                Assert.DoesNotThrow(() =>
                {
                    bool canList = serverSettings.Eai.Acl.CanList;
                    string app   = serverSettings.Eai.Acl.App;
                    dynamic eai  = serverSettings.Eai;
                    Assert.Equal(app, eai.Acl.App);
                    Assert.Equal(canList, eai.Acl.CanList);
                });
            }
        }
예제 #14
0
        async Task CanConstructJobCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "JobCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedNames = new string[]
                {
                    "scheduler__admin__search__RMD50aa4c13eb03d1730_at_1401390000_866",
                    "scheduler__admin__search__RMD54d0063ad31759fca_at_1401390000_867",
                    "scheduler__admin__search__RMD581bb7159c0bb0bbb_at_1401390000_862",
                    "scheduler__admin__search__RMD58306e622619a7dcd_at_1401390000_863",
                    "scheduler__admin__search__RMD5a7321db12d7631bf_at_1401390000_865",
                    "scheduler__admin__search__RMD5e658dbdf77ae86f8_at_1401390000_864",
                    "scheduler__admin__search__RMD5f8965a6a2fa31c5d_at_1401390000_861",
                    "scheduler__admin__search__RMD50aa4c13eb03d1730_at_1401386400_859",
                    "scheduler__admin__search__RMD54d0063ad31759fca_at_1401386400_860",
                    "scheduler__admin__search__RMD581bb7159c0bb0bbb_at_1401386400_855",
                    "scheduler__admin__search__RMD58306e622619a7dcd_at_1401386400_856",
                    "scheduler__admin__search__RMD5a7321db12d7631bf_at_1401386400_858",
                    "scheduler__admin__search__RMD5e658dbdf77ae86f8_at_1401386400_857",
                    "scheduler__admin__search__RMD5f8965a6a2fa31c5d_at_1401386400_854"
                };

                var jobs = new JobCollection(context, feed);

                Assert.Equal(expectedNames.Length, jobs.Count);
                var names = from job in jobs select job.Name;
                Assert.Equal(expectedNames, names);
                CheckCommonProperties("jobs", jobs);

                for (int i = 0; i < jobs.Count; i++)
                {
                    var entry = feed.Entries[i];
                    var job   = jobs[i];
                    CheckJob(entry, job);
                }
            }
        }
        async Task CanConstructServerMessageCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ServerMessageCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedNames = new string[]
                {
                    "some_message_name",
                    "some_other_message_name",
                };

                var messages = new ConfigurationCollection(context, feed);

                Assert.Equal(expectedNames, from message in messages select message.Title);
                Assert.Equal(expectedNames.Length, messages.Count);
                CheckCommonProperties("messages", messages);

                for (int i = 0; i < messages.Count; i++)
                {
                    CheckCommonProperties(expectedNames[i], messages[i]);
                }
            }
        }
예제 #16
0
        public async Task CanConstructEntityCollectionOfEntity()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ApplicationCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                //// EntityCollection<TEntity> checks

                var collection = new EntityCollection <Entity <Resource>, Resource>(context, feed);
                CheckCommonStaticPropertiesEntity(collection);

                Assert.Equal(feed.Id, collection.Id);
                Assert.Equal(feed.GeneratorVersion, collection.GeneratorVersion);
                Assert.Equal(feed.Title, collection.Title);
                Assert.Equal(feed.Entries.Count, collection.Count);

                for (int i = 0; i < collection.Count; i++)
                {
                    var entry  = feed.Entries[i];
                    var entity = collection[i];
                    CheckApplication(entity, entry, feed.GeneratorVersion);
                }
            }
        }
        async Task CanConstructServerMessage()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ServerMessageCollection.CreateAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var message = new ServerMessage(context, feed);

                CheckCommonProperties("some_message_name", message);

                Assert.Equal("some_message_text", message.Text);
                Assert.Equal(ServerMessageSeverity.Information, message.Severity);
                Assert.Equal("2014-05-27 15:28:02Z", message.TimeCreated.ToString("u"));

                Assert.DoesNotThrow(() =>
                {
                    bool canList = message.Eai.Acl.CanList;
                    string app   = message.Eai.Acl.App;
                    dynamic eai  = message.Eai;
                    Assert.Equal(app, eai.Acl.App);
                    Assert.Equal(canList, eai.Acl.CanList);
                });
            }
        }
예제 #18
0
        async Task CanConstructConfigurationCollection()
        {
            var feed = await TestAtomFeed.ReadFeed(Path.Combine(TestAtomFeed.Directory, "ConfigurationCollection.GetAsync.xml"));

            using (var context = new Context(Scheme.Https, "localhost", 8089))
            {
                var expectedConfigurationNames = new string[]
                {
                    "alert_actions",
                    "app",
                    "audit",
                    "authentication",
                    "authorize",
                    "commands",
                    "conf",
                    "crawl",
                    "datatypesbnf",
                    "default-mode",
                    "delete-me-0af59d05d0124e4ab915398500a45262",
                    "delete-me-1c58e9c0851d435aba8b5c53b0c73959",
                    "delete-me-233bbea06392457c9f38b629a912baff",
                    "delete-me-24d778d67e7b4f4e9704c8118e9cbc75",
                    "delete-me-2a38f8d7bfa542c9a09b201ee29da2a8",
                    "delete-me-2f884142c52b4c0883399dfa30fff5bf",
                    "delete-me-3322c0339fb849d98605559cf119a369",
                    "delete-me-33bc32518a364599a08d4bfb226a0975",
                    "delete-me-35a847f36e8a491d962d04a037310dfd",
                    "delete-me-42cecdc8e72f4645b75616c94cd93399",
                    "delete-me-446ee1261b424ae3aec66b67e391df69",
                    "delete-me-4d5457f77b6d49479d518cc4204f300d",
                    "delete-me-59aa7746422549368e550e1bded488af",
                    "delete-me-6d374e8b93014515b506918ada66026e",
                    "delete-me-6d4d46fe88f0444cb330f2a6f022477a",
                    "delete-me-71e7fd0fc0fc420e9dd034a3fd6ae989",
                    "delete-me-7311a03780674f5dbff082fe5f09b458",
                    "delete-me-7a48db483d73412480efd9883af53001",
                    "delete-me-7a4ad0da232f45dab041343c2235a5b0",
                    "delete-me-980b1cb1b2f34884a972ed8bf0c680e2",
                    "delete-me-9940cceaeaf74309b415c43e648ff9eb",
                    "delete-me-9bd517dbec464d32a3b0b51f79bcdad9",
                    "delete-me-9d0b6101094141eab7a69d0daabdce76",
                    "delete-me-9fd99ef85a3641b09a2d5a512bc692c0",
                    "delete-me-a017f23857f14f9fa66e060fbdbd0b37",
                    "delete-me-a5999e197618423ab0c9afffd052c7a9",
                    "delete-me-b8b05d95822a4552bc9c67f863975f0f",
                    "delete-me-c5c6edfa1ccc470981e794d50f2940c6",
                    "delete-me-c6d66b4d921242608962431036860b50",
                    "delete-me-d7e1572f83644e658ccc926c1a736a7f",
                    "delete-me-d8dc0fb200ab4be9862d7e042e919b2c",
                    "delete-me-f8565b63b2af4c0993481440e81ee018",
                    "delete-me-fd46773243cc4b5a8b731483a13e55fb",
                    "distsearch",
                    "event_renderers",
                    "eventdiscoverer",
                    "eventtypes",
                    "fields",
                    "indexes",
                    "inputs",
                    "launcher",
                    "limits",
                    "literals",
                    "lookups",
                    "macros",
                    "manager",
                    "migration",
                    "multikv",
                    "nav",
                    "outputs",
                    "pdf_server",
                    "prefs",
                    "procmon-filters",
                    "props",
                    "quickstart",
                    "restmap",
                    "savedsearches",
                    "searchbnf",
                    "searchscripts",
                    "segmenters",
                    "server",
                    "serverclass",
                    "source-classifier",
                    "sourcetypes",
                    "times",
                    "transactiontypes",
                    "transforms",
                    "ui-prefs",
                    "user-prefs",
                    "views",
                    "viewstates",
                    "web",
                    "workflow_actions"
                };

                var configurations = new ConfigurationCollection(context, feed);

                Assert.Equal(expectedConfigurationNames, from configuration in configurations select configuration.Title);
                Assert.Equal(expectedConfigurationNames.Length, configurations.Count);

                for (int i = 0; i < configurations.Count; i++)
                {
                    Assert.Equal(expectedConfigurationNames[i], configurations[i].Title);

                    Assert.DoesNotThrow(() => { var value = configurations[i].GeneratorVersion; });
                    Assert.DoesNotThrow(() => { var value = configurations[i].Id; });
                    Assert.DoesNotThrow(() => { var value = configurations[i].Updated; });
                }
            }
        }