Skip to content

Commit

Permalink
Merge pull request #13 from leanix/feature/CID-2873/add-appghe-prefix…
Browse files Browse the repository at this point in the history
…-to-all-topic-endpoints

CID-2873: Add /app/ghe prefix to all topic endpoints
  • Loading branch information
mohamedlajmileanix authored Aug 2, 2024
2 parents d9eb4db + 0f555d3 commit 107a2c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import net.leanix.githubagent.client.GitHubClient
import net.leanix.githubagent.dto.Installation
import net.leanix.githubagent.dto.OrganizationDto
import net.leanix.githubagent.exceptions.JwtTokenNotFound
import net.leanix.githubagent.shared.TOPIC_PREFIX
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service
import java.util.UUID
Expand Down Expand Up @@ -64,7 +65,7 @@ class GitHubScanningService(
}
}
logger.info("Sending organizations data")
webSocketService.sendMessage("/app/ghe/${cachingService.get("runId")}/organizations", organizations)
webSocketService.sendMessage("$TOPIC_PREFIX${cachingService.get("runId")}/organizations", organizations)
}

private fun fetchAndSendRepositoriesData(installation: Installation) {
Expand All @@ -79,7 +80,7 @@ class GitHubScanningService(
)
logger.info("Sending page $page of repositories")
webSocketService.sendMessage(
"/app/ghe/${cachingService.get("runId")}/repositories",
"$TOPIC_PREFIX${cachingService.get("runId")}/repositories",
repositoriesPage.repositories
)
cursor = repositoriesPage.cursor
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/net/leanix/githubagent/shared/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.leanix.githubagent.shared

const val TOPIC_PREFIX = "/app/ghe/"
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import net.leanix.githubagent.dto.PagedRepositories
import net.leanix.githubagent.dto.RepositoryDto
import net.leanix.githubagent.exceptions.JwtTokenNotFound
import net.leanix.githubagent.graphql.data.enums.RepositoryVisibility
import net.leanix.githubagent.shared.TOPIC_PREFIX
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
Expand Down Expand Up @@ -53,7 +54,7 @@ class GitHubScanningServiceTest {
fun `scanGitHubResources should send organizations over WebSocket`() {
every { cachingService.get("runId") } returns runId
gitHubScanningService.scanGitHubResources()
verify { webSocketService.sendMessage(eq("/app/ghe/$runId/organizations"), any()) }
verify { webSocketService.sendMessage(eq("$TOPIC_PREFIX$runId/organizations"), any()) }
}

@Test
Expand Down Expand Up @@ -87,6 +88,6 @@ class GitHubScanningServiceTest {
cursor = null
)
gitHubScanningService.scanGitHubResources()
verify { webSocketService.sendMessage(eq("/app/ghe/$runId/repositories"), any()) }
verify { webSocketService.sendMessage(eq("$TOPIC_PREFIX$runId/repositories"), any()) }
}
}

0 comments on commit 107a2c4

Please sign in to comment.