private static String createWebhookExample() { final WebHookModuleBean bean = WebHookModuleBean.newWebHookBean() .withEvent("jira:issue_created") .withUrl("/issue-created") .withExcludeBody(false) .withFilter("project = HSA") .withPropertyKeys(ImmutableList.of("propertyKey", "otherPropertyKey")) .build(); return JsonExamplesUtils.createModuleArrayAsString("webhooks", bean); }
public static WebHookModuleBeanBuilder newWebHookBean() { return new WebHookModuleBeanBuilder(); }
public WebHookModuleBean(WebHookModuleBeanBuilder builder) { super(builder); if (null == event) { this.event = ""; } if (null == url) { this.url = ""; } this.excludeBody = builder.isExcludeBody(); this.propertyKeys = builder.getPropertyKeys(); this.filter = builder.getFilter(); }
private List<ModuleBean> getLifecycleWebhooks(LifecycleBean lifecycle) { List<ModuleBean> webhooks = new ArrayList<>(); if (!Strings.isNullOrEmpty(lifecycle.getEnabled())) { webhooks.add(newWebHookBean().withEvent(PluginsWebHookRegistrationFactory.CONNECT_ADDON_ENABLED).withUrl(lifecycle.getEnabled()).build()); } if (!Strings.isNullOrEmpty(lifecycle.getDisabled())) { webhooks.add(newWebHookBean().withEvent(PluginsWebHookRegistrationFactory.CONNECT_ADDON_DISABLED).withUrl(lifecycle.getDisabled()).build()); } if (!Strings.isNullOrEmpty(lifecycle.getUninstalled())) { webhooks.add(newWebHookBean().withEvent(PluginsWebHookRegistrationFactory.CONNECT_ADDON_UNINSTALLED).withUrl(lifecycle.getUninstalled()).build()); } return webhooks; }
public static void runInRunner(String baseUrl, String eventId, String pluginKey, WebHookTester tester) throws Exception { final String webHookPath = "/webhook"; final WebHookTestServlet servlet = new WebHookTestServlet(); ConnectRunner runner = new ConnectRunner(baseUrl, pluginKey) .addModule("webhooks", newWebHookBean() .withUrl(webHookPath) .withEvent(eventId) .build()) .addRoute(webHookPath, servlet) .addScope(ScopeName.READ) .addJWT(new WebHookTestServlet()) // different servlet for installed callback so that tests can inspect only the webhooks .start(); try { tester.test(servlet::waitForHook); } finally { runner.stopAndUninstall(); } }
public static void runInJsonRunner(String baseUrl, String addonKey, String eventId, boolean excludedBody, String filter, List<String> propertyKeys, WebHookTester tester) throws Exception { final String path = "/webhook"; final WebHookTestServlet servlet = new WebHookTestServlet(); ConnectRunner runner = new ConnectRunner(baseUrl, addonKey) .setAuthenticationToNone() .addModule("webhooks", newWebHookBean().withEvent(eventId).withUrl(path).withExcludeBody(excludedBody).withFilter(filter).withPropertyKeys(propertyKeys).build()) .addRoute(path, servlet) .addModule("webItems", randomWebItemBean()) .addScope(ScopeName.READ) // for receiving web hooks .start(); try { tester.test(servlet::waitForHook); } finally { runner.stopAndUninstall(); } }
public static void runInJsonRunner(String baseUrl, String addonKey, String eventId, WebHookTester tester) throws Exception { final String path = "/webhook"; final WebHookTestServlet servlet = new WebHookTestServlet(); ConnectRunner runner = new ConnectRunner(baseUrl, addonKey) .setAuthenticationToNone() .addModule("webhooks", newWebHookBean().withEvent(eventId).withUrl(path).build()) .addRoute(path, servlet) .addModule("webItems", randomWebItemBean()) .addScope(ScopeName.READ) // for receiving web hooks .start(); try { tester.test(servlet::waitForHook); } finally { runner.stopAndUninstall(); } }
public static WebHookModuleBeanBuilder newWebHookBean(WebHookModuleBean defaultBean) { return new WebHookModuleBeanBuilder(defaultBean); }