Skip to content

Commit

Permalink
Don't allow WebHook Preview and TestExecution to modify existing Configs
Browse files Browse the repository at this point in the history
This addresses issue: #127

When a request is made to do a webhook preview or execution on an
existing webhook, the WebHookConfigFactoryImpl was returning the a
reference to the actual configuration from in memory. This object was
then modified and used for the preview or test webhook execution.

The changes in this object were not persisted (so the
plugin-settings.xml was not changed on disk), but subsequent page loads
would return the modified instance, rather then the persisted instance.

If subsequent edits were made to this instance, then the values from the
test execution would be loaded into the UI, and would effectively
over-write the persisted settings.

The solution is for the WebHookConfigFactoryImpl to return a copy of the
persisted configuration so that the WebHookUserRequestedExecutorImpl has
a temporary copy of the config to use for its executions.
  • Loading branch information
netwolfuk committed Dec 13, 2018
1 parent bfd4d4c commit 17ac1e6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ private WebHookConfig findWebHookWithId(String projectExternalId, String webHook
}

if (whc.getUniqueKey().equals(webHookConfigUniqueId)) {
if (myWebHookPayloadManager.isRegisteredFormat(whc.getPayloadFormat())){
return whc;
} else {
throw new WebHookConfigNotFoundException("No registered Payload Handler for " + whc.getPayloadFormat());
if (myWebHookPayloadManager.isRegisteredFormat(whc.getPayloadFormat())){
return whc.copy();
} else {
throw new WebHookConfigNotFoundException("No registered Payload Handler for " + whc.getPayloadFormat());
}
}
}
}
} else {
Loggers.SERVER.debug("WebHookUserRequestedExecutorImpl :: WebHooks are disasbled for " + projectExternalId);
Expand Down

0 comments on commit 17ac1e6

Please sign in to comment.