diff --git a/src/main/kotlin/net/leanix/githubagent/shared/Constants.kt b/src/main/kotlin/net/leanix/githubagent/shared/Constants.kt index 9bbaf22..a295efb 100644 --- a/src/main/kotlin/net/leanix/githubagent/shared/Constants.kt +++ b/src/main/kotlin/net/leanix/githubagent/shared/Constants.kt @@ -3,7 +3,7 @@ package net.leanix.githubagent.shared const val TOPIC_PREFIX = "/app/ghe/" const val APP_NAME_TOPIC = "appName" const val LOGS_TOPIC = "logs" -const val MANIFEST_FILE_NAME = "leanix.yml" +const val MANIFEST_FILE_NAME = "leanix.yaml" val SUPPORTED_EVENT_TYPES = listOf( "REPOSITORY", diff --git a/src/test/kotlin/net/leanix/githubagent/services/WebhookEventServiceTest.kt b/src/test/kotlin/net/leanix/githubagent/services/WebhookEventServiceTest.kt index 7de900c..e1c4f5f 100644 --- a/src/test/kotlin/net/leanix/githubagent/services/WebhookEventServiceTest.kt +++ b/src/test/kotlin/net/leanix/githubagent/services/WebhookEventServiceTest.kt @@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles +const val UNSUPPORTED_MANIFEST_EXTENSION = "leanix.yml" + @SpringBootTest @ActiveProfiles("test") class WebhookEventServiceTest { @@ -150,6 +152,34 @@ class WebhookEventServiceTest { verify { webSocketService.sendMessage(any(), any()) } } + @Test + fun `should not send updates for unsupported yml manifest file`() { + val payload = """ + { + "ref": "refs/heads/main", + "repository": { + "name": "repo", + "full_name": "org/repo", + "default_branch": "main", + "owner": { + "name": "org" + } + }, + "head_commit": { + "added": ["$UNSUPPORTED_MANIFEST_EXTENSION"], + "modified": [], + "removed": [] + }, + "installation": { + "id": 1 + } + } + """ + webhookEventService.consumeWebhookEvent("PUSH", payload) + + verify (exactly = 0) { webSocketService.sendMessage(any(), any()) } + } + @Test fun `should handle manifest file in subdirectory`() { val payload = """{ @@ -233,4 +263,37 @@ class WebhookEventServiceTest { ) } } + + @Test + fun `should handle push event with supported YAML extension`() { + val payload = """{ + "repository": { + "name": "repo", + "full_name": "owner/repo", + "owner": {"name": "owner"}, + "default_branch": "main" + }, + "head_commit": { + "added": ["custom/path/added1/leanix.yml", "custom/path/added2/$MANIFEST_FILE_NAME"], + "modified": [], + "removed": [] + }, + "installation": {"id": 1}, + "ref": "refs/heads/main" + }""" + + webhookEventService.consumeWebhookEvent("PUSH", payload) + + verify(exactly = 1) { + webSocketService.sendMessage( + "/events/manifestFile", + ManifestFileUpdateDto( + "owner/repo", + ManifestFileAction.ADDED, + "content", + "custom/path/added2/$MANIFEST_FILE_NAME" + ) + ) + } + } }