Exemplo n.º 1
0
        public void CanCreateUpdateDeleteRunbook()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var runbookName    = RunbookDefinition.TestPSScript.RunbookName;
                    var runbookContent = RunbookDefinition.TestPSScript.PsScript;

                    testFixture.CreatePSScriptRunbook(runbookName, runbookContent);
                    var runbook = testFixture.GetRunbook(runbookName);
                    Assert.NotNull(runbook);

                    testFixture.PublishRunbook(runbook.Name);
                    runbook = testFixture.GetRunbook(runbookName);
                    Assert.Equal("Published", runbook.State);

                    const string description = "description of runbook";
                    runbook.LogProgress = true;
                    runbook.Description = description;

                    testFixture.UpdateRunbook(runbook);
                    var updatedRunbook = testFixture.GetRunbook(runbookName);
                    Assert.True(runbook.LogProgress);
                    Assert.False(runbook.LogVerbose);
                    Assert.Equal(runbook.Description, updatedRunbook.Description);

                    var runbookContentV2 = RunbookDefinition.TestPSScriptV2.PsScript;
                    testFixture.UpdateRunbookContent(runbookName, runbookContentV2);
                    var updatedContent = testFixture.GetRunbookContent(runbookName);
                    var reader         = new StreamReader(updatedContent);
                    Assert.Equal(runbookContentV2, reader.ReadToEnd());

                    testFixture.DeleteRunbook(runbookName);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        runbook = testFixture.GetRunbook(runbookName);
                    });
                }
            }
        }
Exemplo n.º 2
0
        public void CanCreateUpdateDeleteWebhook()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var webhookName    = TestUtilities.GenerateName("webhook");
                    var runbookName    = RunbookDefinition.TestFasterWorkflow.RunbookName;
                    var runbookContent = RunbookDefinition.TestFasterWorkflow.PsScript;

                    testFixture.CreateRunbook(runbookName, runbookContent);
                    testFixture.PublishRunbook(runbookName);
                    var runbook = testFixture.GetRunbook(runbookName);
                    Assert.Equal("Published", runbook.State);

                    var uri = testFixture.GenerateUriForWebhook();

                    var webhook = testFixture.CreateWebhook(webhookName, runbookName, uri);
                    Assert.NotNull(webhook);

                    webhook = testFixture.GetWebhook(webhook.Name);
                    Assert.NotNull(webhook);
                    Assert.Equal(runbookName, webhook.Runbook.Name);

                    webhook.IsEnabled = false;

                    testFixture.UpdateWebhook(webhook);
                    var webhooks = testFixture.GetWebhooks();

                    Assert.Single(webhooks.ToList());
                    var updatedWebhook = webhooks.ToList()[0];
                    Assert.False(updatedWebhook.IsEnabled);

                    webhooks = testFixture.GetWebhooks(runbookName);

                    Assert.Single(webhooks.ToList());
                    updatedWebhook = webhooks.ToList()[0];
                    Assert.False(updatedWebhook.IsEnabled);

                    testFixture.DeleteWebhook(webhook.Name);
                    testFixture.DeleteRunbook(runbookName);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        webhook = testFixture.GetWebhook(webhook.Name);
                    });
                }
            }
        }