Skip to content

Commit

Permalink
fix(webhook): Add fail fast status to the preconfigured webhook prope…
Browse files Browse the repository at this point in the history
…rties (#3223)
  • Loading branch information
afcastano authored and marchello2000 committed Oct 11, 2019
1 parent d304293 commit 4e1e03e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions orca-web/config/orca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ integrations:
# {
# "text": "Version ${trigger.buildInfo.artifacts[0].version} deployed"
# }
# failFastStatusCodes:
# - 404
# - 501
# waitForCompletion: true
# # The rest of the properties are only used if waitForCompletion == true
# statusUrlResolution: webhookResponse # getMethod, locationHeader, webhookResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ class OperationsControllerSpec extends Specification {

def "should call webhookService and return correct information"() {
given:
def preconfiguredProperties = ["url", "customHeaders", "method", "payload", "waitForCompletion", "statusUrlResolution",
def preconfiguredProperties = ["url", "customHeaders", "method", "payload", "failFastStatusCodes", "waitForCompletion", "statusUrlResolution",
"statusUrlJsonPath", "statusJsonPath", "progressJsonPath", "successStatuses", "canceledStatuses", "terminalStatuses"]

when:
Expand All @@ -652,7 +652,7 @@ class OperationsControllerSpec extends Specification {

def "should not return protected preconfigured webhooks if user don't have the role"() {
given:
def preconfiguredProperties = ["url", "customHeaders", "method", "payload", "waitForCompletion", "statusUrlResolution",
def preconfiguredProperties = ["url", "customHeaders", "method", "payload", "failFastStatusCodes", "waitForCompletion", "statusUrlResolution",
"statusUrlJsonPath", "statusJsonPath", "progressJsonPath", "successStatuses", "canceledStatuses", "terminalStatuses"]
executionLauncher.start(*_) >> { ExecutionType type, String json ->
startedPipeline = mapper.readValue(json, Execution)
Expand Down Expand Up @@ -685,7 +685,7 @@ class OperationsControllerSpec extends Specification {

def "should return protected preconfigured webhooks if user have the role"() {
given:
def preconfiguredProperties = ["url", "customHeaders", "method", "payload", "waitForCompletion", "statusUrlResolution",
def preconfiguredProperties = ["url", "customHeaders", "method", "payload", "failFastStatusCodes", "waitForCompletion", "statusUrlResolution",
"statusUrlJsonPath", "statusJsonPath", "progressJsonPath", "successStatuses", "canceledStatuses", "terminalStatuses"]
executionLauncher.start(*_) >> { ExecutionType type, String json ->
startedPipeline = mapper.readValue(json, Execution)
Expand Down Expand Up @@ -774,7 +774,7 @@ class OperationsControllerSpec extends Specification {
return new WebhookProperties.PreconfiguredWebhook(
label: label, description: description, type: type,
url: "a", customHeaders: customHeaders, method: HttpMethod.POST, payload: "b",
waitForCompletion: true, statusUrlResolution: WebhookProperties.StatusUrlResolution.webhookResponse,
failFastStatusCodes: [500, 501], waitForCompletion: true, statusUrlResolution: WebhookProperties.StatusUrlResolution.webhookResponse,
statusUrlJsonPath: "c", statusJsonPath: "d", progressJsonPath: "e", successStatuses: "f", canceledStatuses: "g", terminalStatuses: "h", parameters: null, parameterData: null,
permissions: permissions
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static class PreconfiguredWebhook {
public Map<String, Map<String, String>> parameterData;
public HttpMethod method;
public String payload;
public List<Integer> failFastStatusCodes;
public Boolean waitForCompletion;
public StatusUrlResolution statusUrlResolution;
public String statusUrlJsonPath; // if webhookResponse above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PreconfiguredWebhookSpec extends Specification {
def fields = preconfiguredWebhook.preconfiguredProperties

then:
fields == ["url", "customHeaders", "method", "payload", "waitForCompletion", "statusUrlResolution", "statusUrlJsonPath",
fields == ["url", "customHeaders", "method", "payload", "failFastStatusCodes", "waitForCompletion", "statusUrlResolution", "statusUrlJsonPath",
"statusJsonPath", "progressJsonPath", "successStatuses", "canceledStatuses", "terminalStatuses"]
}

Expand Down Expand Up @@ -82,7 +82,7 @@ class PreconfiguredWebhookSpec extends Specification {
customHeaders.put("header", ["value1", "value2"])
return new WebhookProperties.PreconfiguredWebhook(
url: "url", customHeaders: customHeaders, method: HttpMethod.POST, payload: "payload",
waitForCompletion: true, statusUrlResolution: webhookResponse,
failFastStatusCodes: [500, 501], waitForCompletion: true, statusUrlResolution: webhookResponse,
statusUrlJsonPath: "statusUrlJsonPath", statusJsonPath: "statusJsonPath", progressJsonPath: "progressJsonPath",
successStatuses: "successStatuses", canceledStatuses: "canceledStatuses", terminalStatuses: "terminalStatuses"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PreconfiguredWebhookStageSpec extends Specification {
customHeaders: ["header": ["value1"]],
method: HttpMethod.POST,
payload: "b",
failFastStatusCodes: [500, 501],
waitForCompletion: true,
statusUrlResolution: WebhookProperties.StatusUrlResolution.locationHeader,
statusUrlJsonPath: "c",
Expand All @@ -70,6 +71,7 @@ class PreconfiguredWebhookStageSpec extends Specification {
customHeaders: ["header": ["value1"]],
method: HttpMethod.POST,
payload: "b",
failFastStatusCodes: [500, 501],
waitForCompletion: true,
statusUrlResolution: WebhookProperties.StatusUrlResolution.webhookResponse,
statusUrlJsonPath: "c",
Expand All @@ -92,6 +94,7 @@ class PreconfiguredWebhookStageSpec extends Specification {
customHeaders: ["header": ["value1"]],
method: HttpMethod.POST,
payload: "b",
failFastStatusCodes: [500, 501],
waitForCompletion: true,
statusUrlResolution: WebhookProperties.StatusUrlResolution.webhookResponse,
statusUrlJsonPath: "c",
Expand All @@ -111,7 +114,7 @@ class PreconfiguredWebhookStageSpec extends Specification {
customHeaders.add("header", "value1")
return new WebhookProperties.PreconfiguredWebhook(
label: label, description: description, type: type, url: "a", customHeaders: customHeaders, method: HttpMethod.POST, payload: "b",
waitForCompletion: true, statusUrlResolution: WebhookProperties.StatusUrlResolution.locationHeader,
failFastStatusCodes: [500, 501], waitForCompletion: true, statusUrlResolution: WebhookProperties.StatusUrlResolution.locationHeader,
statusUrlJsonPath: "c", statusJsonPath: "d", progressJsonPath: "e", successStatuses: "f", canceledStatuses: "g", terminalStatuses: "h"
)
}
Expand Down

0 comments on commit 4e1e03e

Please sign in to comment.