public void CanCreateUpdateDeleteWebhook() { using (var undoContext = UndoContext.Current) { undoContext.Start(); using (AutomationTestBase _testFixture = new AutomationTestBase()) { 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.Properties.State); var uri = _testFixture.GenerateUriForWebhook(); Webhook webhook = _testFixture.CreateWebhook(webhookName, runbookName, uri); Assert.NotNull(webhook); webhook = _testFixture.GetWebhook(webhook.Name); Assert.NotNull(webhook); Assert.Equal(runbookName, webhook.Properties.Runbook.Name); webhook.Properties.IsEnabled = false; _testFixture.UpdateWebhook(webhook); var webhooks = _testFixture.GetWebhooks(); Assert.Equal(1, webhooks.Count); var updatedWebhook = webhooks[0]; Assert.False(updatedWebhook.Properties.IsEnabled); webhooks = _testFixture.GetWebhooks(runbookName); Assert.Equal(1, webhooks.Count); updatedWebhook = webhooks[0]; Assert.False(updatedWebhook.Properties.IsEnabled); _testFixture.DeleteWebhook(webhook.Name); _testFixture.DeleteRunbook(runbookName); Assert.Throws <CloudException>(() => { webhook = _testFixture.GetWebhook(webhook.Name); }); } } }
public void CanCreateUpdateDeleteWebhook() { using (var undoContext = UndoContext.Current) { undoContext.Start(); using (AutomationTestBase _testFixture = new AutomationTestBase()) { 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.Properties.State); var uri = _testFixture.GenerateUriForWebhook(); Webhook webhook = _testFixture.CreateWebhook(webhookName, runbookName, uri); Assert.NotNull(webhook); webhook = _testFixture.GetWebhook(webhook.Name); Assert.NotNull(webhook); Assert.Equal(runbookName, webhook.Properties.Runbook.Name); webhook.Properties.IsEnabled = false; _testFixture.UpdateWebhook(webhook); var webhooks = _testFixture.GetWebhooks(); Assert.Equal(1, webhooks.Count); var updatedWebhook = webhooks[0]; Assert.False(updatedWebhook.Properties.IsEnabled); webhooks = _testFixture.GetWebhooks(runbookName); Assert.Equal(1, webhooks.Count); updatedWebhook = webhooks[0]; Assert.False(updatedWebhook.Properties.IsEnabled); _testFixture.DeleteWebhook(webhook.Name); _testFixture.DeleteRunbook(runbookName); Assert.Throws<CloudException>(() => { webhook = _testFixture.GetWebhook(webhook.Name); }); } } }