Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CID-3000: Switch from app name to slug #28

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading