generated from leanix/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from leanix/feature/CID-2885/send-GH-app-name-…
…to-backend CID-2885: Send GitHub App name to backend
- Loading branch information
Showing
4 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/test/kotlin/net/leanix/githubagent/runners/PostStartupRunnerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package net.leanix.githubagent.runners | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import net.leanix.githubagent.dto.GitHubAppResponse | ||
import net.leanix.githubagent.services.CachingService | ||
import net.leanix.githubagent.services.GitHubAuthenticationService | ||
import net.leanix.githubagent.services.GitHubEnterpriseService | ||
import net.leanix.githubagent.services.GitHubScanningService | ||
import net.leanix.githubagent.services.WebSocketService | ||
import net.leanix.githubagent.shared.AGENT_METADATA_TOPIC | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
|
||
class PostStartupRunnerTest { | ||
|
||
private lateinit var githubAuthenticationService: GitHubAuthenticationService | ||
private lateinit var webSocketService: WebSocketService | ||
private lateinit var gitHubScanningService: GitHubScanningService | ||
private lateinit var gitHubEnterpriseService: GitHubEnterpriseService | ||
private lateinit var cachingService: CachingService | ||
private lateinit var postStartupRunner: PostStartupRunner | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
githubAuthenticationService = mockk() | ||
webSocketService = mockk() | ||
gitHubScanningService = mockk() | ||
gitHubEnterpriseService = mockk() | ||
cachingService = mockk() | ||
|
||
postStartupRunner = PostStartupRunner( | ||
githubAuthenticationService, | ||
webSocketService, | ||
gitHubScanningService, | ||
gitHubEnterpriseService, | ||
cachingService | ||
) | ||
|
||
every { webSocketService.initSession() } returns Unit | ||
every { webSocketService.sendMessage(any(), any()) } returns Unit | ||
every { githubAuthenticationService.generateAndCacheJwtToken() } returns Unit | ||
every { cachingService.get("jwt") } returns "jwt" | ||
every { gitHubScanningService.scanGitHubResources() } returns Unit | ||
} | ||
|
||
@Test | ||
fun `should send GitHub App name`() { | ||
val gitHubAppName = "appName" | ||
every { gitHubEnterpriseService.getGitHubApp("jwt") } returns | ||
GitHubAppResponse( | ||
gitHubAppName, mapOf(), listOf() | ||
) | ||
|
||
postStartupRunner.run(mockk()) | ||
|
||
verify { webSocketService.sendMessage(AGENT_METADATA_TOPIC, gitHubAppName) } | ||
} | ||
} |