diff --git a/notification-publisher/src/test/java/org/dependencytrack/notification/publisher/MsTeamsPublisherTest.java b/notification-publisher/src/test/java/org/dependencytrack/notification/publisher/MsTeamsPublisherTest.java index 336f0f356..40e56307d 100644 --- a/notification-publisher/src/test/java/org/dependencytrack/notification/publisher/MsTeamsPublisherTest.java +++ b/notification-publisher/src/test/java/org/dependencytrack/notification/publisher/MsTeamsPublisherTest.java @@ -20,17 +20,32 @@ import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; import jakarta.json.JsonObjectBuilder; import org.junit.jupiter.api.Test; +import java.util.Map; + import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; @QuarkusTest +@TestProfile(MsTeamsPublisherTest.TestProfile.class) class MsTeamsPublisherTest extends AbstractWebhookPublisherTest { + public static class TestProfile implements QuarkusTestProfile { + + @Override + public Map getConfigOverrides() { + return Map.ofEntries( + Map.entry("dtrack.general.base.url", "https://example.com") + ); + } + } + @Override JsonObjectBuilder extraConfig() { return super.extraConfig() @@ -108,6 +123,14 @@ void testInformWithBomProcessingFailedNotification() throws Exception { { "name": "Group", "value": "GROUP_BOM_PROCESSING_FAILED" + }, + { + "name" : "Project", + "value" : "pkg:maven/org.acme/projectName@projectVersion" + }, + { + "name" : "Project URL", + "value" : "https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95" } ], "text": "An error occurred while processing a BOM" @@ -148,6 +171,14 @@ void testInformWithBomProcessingFailedNotificationAndNoSpecVersionInSubject() th { "name": "Group", "value": "GROUP_BOM_PROCESSING_FAILED" + }, + { + "name" : "Project", + "value" : "pkg:maven/org.acme/projectName@projectVersion" + }, + { + "name" : "Project URL", + "value" : "https://example.com/projects/c9c9539a-e381-4b36-ac52-6a7ab83b2c95" } ], "text": "An error occurred while processing a BOM" diff --git a/notification-publisher/src/test/resources/templates/msteams.peb b/notification-publisher/src/test/resources/templates/msteams.peb index 0fd980066..bb6121106 100644 --- a/notification-publisher/src/test/resources/templates/msteams.peb +++ b/notification-publisher/src/test/resources/templates/msteams.peb @@ -96,6 +96,29 @@ "value": "{{ subject.project | summarize | escape(strategy="json") }}" } ], + {% elseif notification.group == "GROUP_BOM_PROCESSING_FAILED" %} + "facts": [ + { + "name": "Level", + "value": "{{ notification.level | escape(strategy="json") }}" + }, + { + "name": "Scope", + "value": "{{ notification.scope | escape(strategy="json") }}" + }, + { + "name": "Group", + "value": "{{ notification.group | escape(strategy="json") }}" + }, + { + "name": "Project", + "value": "{{ subject.project | summarize | escape(strategy="json") }}" + }, + { + "name": "Project URL", + "value": "{{ baseUrl }}/projects/{{ subject.project.uuid | escape(strategy='json') }}" + } + ], {% else %} "facts": [ {