Skip to content

Commit

Permalink
CID-3000: Switch from app name to slug
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedlajmileanix committed Oct 7, 2024
1 parent 4b170e0 commit f9ab68c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty

@JsonIgnoreProperties(ignoreUnknown = true)
data class GitHubAppResponse(
@JsonProperty("name") val name: String,
@JsonProperty("slug") val slug: String,
@JsonProperty("permissions") val permissions: Map<String, String>,
@JsonProperty("events") val events: List<String>
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PostStartupRunner(
val jwt = cachingService.get("jwtToken") as String
webSocketService.sendMessage(
APP_NAME_TOPIC,
gitHubEnterpriseService.getGitHubApp(jwt).name
gitHubEnterpriseService.getGitHubApp(jwt).slug
)
gitHubScanningService.scanGitHubResources()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GitHubEnterpriseService(private val githubClient: GitHubClient) {
runCatching {
val githubApp = getGitHubApp(jwt)
validateGithubAppResponse(githubApp)
logger.info("Authenticated as GitHub App: '${githubApp.name}'")
logger.info("Authenticated as GitHub App: '${githubApp.slug}'")
}.onFailure {
logger.error("Failed to verify JWT token", it)
when (it) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GitHubEnterpriseServiceTest {
fun `verifyJwt with valid jwt should not throw exception`() {
val jwt = "validJwt"
val githubApp = GitHubAppResponse(
name = "validApp",
slug = "validApp",
permissions = mapOf("administration" to "read", "contents" to "read", "metadata" to "read"),
events = listOf("label", "public", "repository")
)
Expand All @@ -39,7 +39,7 @@ class GitHubEnterpriseServiceTest {
@Test
fun `validateGithubAppResponse with correct permissions should not throw exception`() {
val response = GitHubAppResponse(
name = "validApp",
slug = "validApp",
permissions = mapOf("administration" to "read", "contents" to "read", "metadata" to "read"),
events = listOf("label", "public", "repository")
)
Expand All @@ -50,7 +50,7 @@ class GitHubEnterpriseServiceTest {
@Test
fun `validateGithubAppResponse with missing permissions should throw exception`() {
val response = GitHubAppResponse(
name = "validApp",
slug = "validApp",
permissions = mapOf("administration" to "read", "contents" to "read"),
events = listOf("label", "public", "repository")
)
Expand All @@ -63,7 +63,7 @@ class GitHubEnterpriseServiceTest {
@Test
fun `validateGithubAppResponse with missing events should throw exception`() {
val response = GitHubAppResponse(
name = "validApp",
slug = "validApp",
permissions = mapOf("administration" to "read", "contents" to "read", "metadata" to "read"),
events = listOf("label", "public")
)
Expand Down

0 comments on commit f9ab68c

Please sign in to comment.