diff --git a/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTestUtils.java b/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTestUtils.java index 5afa8ac3f4..4bbcbf2ea5 100644 --- a/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTestUtils.java +++ b/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTestUtils.java @@ -83,8 +83,8 @@ static JsonObject createIncomingPayload(JsonObject cloudEventData) { ); payload.put(SOURCE, source); - payload.put(INVENTORY_URL, "https://console.redhat.com/insights/inventory/8a4a4f75-5319-4255-9eb5-1ee5a92efd7f"); - payload.put(APPLICATION_URL, "https://console.redhat.com/insights/default-application"); + payload.put(INVENTORY_URL, "https://console.redhat.com/insights/inventory/8a4a4f75-5319-4255-9eb5-1ee5a92efd7f?from=notifications"); + payload.put(APPLICATION_URL, "https://console.redhat.com/insights/default-application?from=notifications"); payload.put(SEVERITY, PagerDutySeverity.WARNING); cloudEventData.put(PAYLOAD, payload); diff --git a/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformerTest.java b/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformerTest.java index 5abb2b68a9..b8f5a673c9 100644 --- a/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformerTest.java +++ b/connector-pagerduty/src/test/java/com/redhat/cloud/notifications/connector/pagerduty/PagerDutyTransformerTest.java @@ -112,7 +112,7 @@ void testSuccessfulTestMessage() { ); cloudEventPayload.put("recipients", JsonArray.of()); // No inventory_url generated - cloudEventPayload.put("application_url", "https://console.redhat.com/settings/integrations"); + cloudEventPayload.put("application_url", "https://console.redhat.com/settings/integrations?from=notifications"); cloudEventPayload.put("severity", "warning"); cloudEventData.put(PAYLOAD, cloudEventPayload); diff --git a/engine/src/main/java/com/redhat/cloud/notifications/processors/InsightsUrlsBuilder.java b/engine/src/main/java/com/redhat/cloud/notifications/processors/InsightsUrlsBuilder.java index 751bbda907..883437b6c8 100644 --- a/engine/src/main/java/com/redhat/cloud/notifications/processors/InsightsUrlsBuilder.java +++ b/engine/src/main/java/com/redhat/cloud/notifications/processors/InsightsUrlsBuilder.java @@ -8,6 +8,7 @@ import jakarta.inject.Inject; import java.util.ArrayList; +import java.util.List; import java.util.Optional; @ApplicationScoped @@ -36,7 +37,7 @@ public class InsightsUrlsBuilder { */ public Optional buildInventoryUrl(JsonObject data) { String path; - ArrayList queryParamParts = new ArrayList<>(); + ArrayList queryParamParts = new ArrayList<>(List.of("from=notifications")); JsonObject context = data.getJsonObject("context"); if (context == null) { return Optional.empty(); @@ -45,7 +46,7 @@ public Optional buildInventoryUrl(JsonObject data) { // A provided host url does not need to be modified String host_url = context.getString("host_url", ""); if (!host_url.isEmpty()) { - return Optional.of(host_url); + return Optional.of(host_url + "?" + String.join("&", queryParamParts)); } String environmentUrl = environment.url(); @@ -68,12 +69,7 @@ public Optional buildInventoryUrl(JsonObject data) { return Optional.empty(); } - if (!queryParamParts.isEmpty()) { - String queryParams = "?" + String.join("&", queryParamParts); - path += queryParams; - } - - return Optional.of(environmentUrl + path); + return Optional.of(environmentUrl + path + "?" + String.join("&", queryParamParts)); } /** @@ -88,6 +84,7 @@ public Optional buildInventoryUrl(JsonObject data) { */ public String buildApplicationUrl(JsonObject data) { String path = ""; + ArrayList queryParamParts = new ArrayList<>(List.of("from=notifications")); String environmentUrl = environment.url(); String bundle = data.getString("bundle", ""); @@ -104,6 +101,10 @@ public String buildApplicationUrl(JsonObject data) { } path += application; + if (!queryParamParts.isEmpty()) { + String queryParams = "?" + String.join("&", queryParamParts); + path += queryParams; + } return String.format("%s/%s", environmentUrl, path); } diff --git a/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/google/chat/GoogleChatProcessorTest.java b/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/google/chat/GoogleChatProcessorTest.java index 835ea9dabe..0eb8cd0c1e 100644 --- a/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/google/chat/GoogleChatProcessorTest.java +++ b/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/google/chat/GoogleChatProcessorTest.java @@ -21,11 +21,11 @@ public class GoogleChatProcessorTest extends CamelProcessorTest { "triggered{/if} from {data.source.application.display_name} - {data.source.bundle.display_name}. " + "<{data.application_url}|Open {data.source.application.display_name}>\"}"; - private static final String GOOGLE_CHAT_EXPECTED_MSG = "{\"text\":\"<" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/inventory/6ad30f3e-0497-4e74-99f1-b3f9a6120a6f|my-computer> " + - "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies|Open Policies>\"}"; + private static final String GOOGLE_CHAT_EXPECTED_MSG = "{\"text\":\"<" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/inventory/6ad30f3e-0497-4e74-99f1-b3f9a6120a6f?from=notifications|my-computer> " + + "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies?from=notifications|Open Policies>\"}"; - private static final String GOOGLE_CHAT_EXPECTED_MSG_WITH_HOST_URL = "{\"text\":\"<" + CONTEXT_HOST_URL + "|my-computer> " + - "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies|Open Policies>\"}"; + private static final String GOOGLE_CHAT_EXPECTED_MSG_WITH_HOST_URL = "{\"text\":\"<" + CONTEXT_HOST_URL + "?from=notifications|my-computer> " + + "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies?from=notifications|Open Policies>\"}"; @Inject GoogleChatProcessor googleSpacesProcessor; diff --git a/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/slack/SlackProcessorTest.java b/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/slack/SlackProcessorTest.java index 493085fa58..dac7de6e13 100644 --- a/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/slack/SlackProcessorTest.java +++ b/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/slack/SlackProcessorTest.java @@ -34,10 +34,10 @@ public class SlackProcessorTest extends CamelProcessorTest { "{#else}{data.events.size()} event{#if data.events.size() > 1}s{/if} triggered{/if} " + "from {data.source.application.display_name} - {data.source.bundle.display_name}. " + "<{data.application_url}|Open {data.source.application.display_name}>"; - private static final String SLACK_EXPECTED_MSG = "<" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/inventory/6ad30f3e-0497-4e74-99f1-b3f9a6120a6f|my-computer> " + - "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies|Open Policies>"; - private static final String SLACK_EXPECTED_MSG_WITH_HOST_URL = "<" + CONTEXT_HOST_URL + "|my-computer> " + - "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies|Open Policies>"; + private static final String SLACK_EXPECTED_MSG = "<" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/inventory/6ad30f3e-0497-4e74-99f1-b3f9a6120a6f?from=notifications|my-computer> " + + "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies?from=notifications|Open Policies>"; + private static final String SLACK_EXPECTED_MSG_WITH_HOST_URL = "<" + CONTEXT_HOST_URL + "?from=notifications|my-computer> " + + "triggered 1 event from Policies - Red Hat Enterprise Linux. <" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies?from=notifications|Open Policies>"; @Inject SlackProcessor slackProcessor; diff --git a/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/teams/TeamsProcessorTest.java b/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/teams/TeamsProcessorTest.java index 200aae95e1..16b4d5cdfa 100644 --- a/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/teams/TeamsProcessorTest.java +++ b/engine/src/test/java/com/redhat/cloud/notifications/processors/camel/teams/TeamsProcessorTest.java @@ -21,11 +21,11 @@ public class TeamsProcessorTest extends CamelProcessorTest { "from {data.source.application.display_name} - {data.source.bundle.display_name}. " + "[Open {data.source.application.display_name}]({data.application_url})\"}"; - private static final String TEAMS_EXPECTED_MSG = "{\"text\":\"[my-computer](" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/inventory/6ad30f3e-0497-4e74-99f1-b3f9a6120a6f) " + - "triggered 1 event from Policies - Red Hat Enterprise Linux. [Open Policies](" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies)\"}"; + private static final String TEAMS_EXPECTED_MSG = "{\"text\":\"[my-computer](" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/inventory/6ad30f3e-0497-4e74-99f1-b3f9a6120a6f?from=notifications) " + + "triggered 1 event from Policies - Red Hat Enterprise Linux. [Open Policies](" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies?from=notifications)\"}"; - private static final String TEAMS_EXPECTED_MSG_WITH_HOST_URL = "{\"text\":\"[my-computer](" + CONTEXT_HOST_URL + ") " + - "triggered 1 event from Policies - Red Hat Enterprise Linux. [Open Policies](" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies)\"}"; + private static final String TEAMS_EXPECTED_MSG_WITH_HOST_URL = "{\"text\":\"[my-computer](" + CONTEXT_HOST_URL + "?from=notifications) " + + "triggered 1 event from Policies - Red Hat Enterprise Linux. [Open Policies](" + EnvironmentTest.expectedTestEnvUrlValue + "/insights/policies?from=notifications)\"}"; @Inject TeamsProcessor teamsProcessor;