Skip to content

Commit

Permalink
Add the project name and project URL to bom processing notifications (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nscuro authored Jun 18, 2024
1 parent 0012f26 commit 56e2a2f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<MsTeamsPublisher> {

public static class TestProfile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.ofEntries(
Map.entry("dtrack.general.base.url", "https://example.com")
);
}
}

@Override
JsonObjectBuilder extraConfig() {
return super.extraConfig()
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions notification-publisher/src/test/resources/templates/msteams.peb
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit 56e2a2f

Please sign in to comment.