diff --git a/src/main/kotlin/net/leanix/githubagent/controllers/GitHubWebhookController.kt b/src/main/kotlin/net/leanix/githubagent/controllers/GitHubWebhookController.kt index b76d600..c218576 100644 --- a/src/main/kotlin/net/leanix/githubagent/controllers/GitHubWebhookController.kt +++ b/src/main/kotlin/net/leanix/githubagent/controllers/GitHubWebhookController.kt @@ -24,11 +24,10 @@ class GitHubWebhookController(private val webhookService: WebhookService) { @RequestBody payload: String ) { runCatching { - logger.info("Received a GitHub event of type $eventType") if (SUPPORTED_EVENT_TYPES.contains(eventType.uppercase())) { webhookService.consumeWebhookEvent(eventType, payload) } else { - logger.warn("Event type not supported") + logger.warn("Received an unsupported event of type: $eventType") } } } diff --git a/src/main/kotlin/net/leanix/githubagent/runners/PostStartupRunner.kt b/src/main/kotlin/net/leanix/githubagent/runners/PostStartupRunner.kt index 41283c4..98cc898 100644 --- a/src/main/kotlin/net/leanix/githubagent/runners/PostStartupRunner.kt +++ b/src/main/kotlin/net/leanix/githubagent/runners/PostStartupRunner.kt @@ -18,7 +18,7 @@ class PostStartupRunner( override fun run(args: ApplicationArguments?) { webSocketService.initSession() - githubAuthenticationService.generateJwtToken() + githubAuthenticationService.generateAndCacheJwtToken() gitHubScanningService.scanGitHubResources() } } diff --git a/src/main/kotlin/net/leanix/githubagent/services/GitHubAuthenticationService.kt b/src/main/kotlin/net/leanix/githubagent/services/GitHubAuthenticationService.kt index e6291b3..1e2bcdd 100644 --- a/src/main/kotlin/net/leanix/githubagent/services/GitHubAuthenticationService.kt +++ b/src/main/kotlin/net/leanix/githubagent/services/GitHubAuthenticationService.kt @@ -38,7 +38,7 @@ class GitHubAuthenticationService( } fun refreshTokens() { - generateJwtToken() + generateAndCacheJwtToken() val jwtToken = cachingService.get("jwtToken") generateAndCacheInstallationTokens( gitHubClient.getInstallations("Bearer $jwtToken"), @@ -46,7 +46,7 @@ class GitHubAuthenticationService( ) } - fun generateJwtToken() { + fun generateAndCacheJwtToken() { runCatching { logger.info("Generating JWT token") Security.addProvider(BouncyCastleProvider()) diff --git a/src/main/kotlin/net/leanix/githubagent/services/WebhookService.kt b/src/main/kotlin/net/leanix/githubagent/services/WebhookService.kt index dbf7923..7966e23 100644 --- a/src/main/kotlin/net/leanix/githubagent/services/WebhookService.kt +++ b/src/main/kotlin/net/leanix/githubagent/services/WebhookService.kt @@ -26,7 +26,7 @@ class WebhookService( when (eventType.uppercase()) { "PUSH" -> handlePushEvent(payload) else -> { - logger.debug("Sending event of type: $eventType") + logger.info("Sending event of type: $eventType") webSocketService.sendMessage("/events/other", payload) } } diff --git a/src/test/kotlin/net/leanix/githubagent/services/GitHubAuthenticationServiceTest.kt b/src/test/kotlin/net/leanix/githubagent/services/GitHubAuthenticationServiceTest.kt index 75c6a27..8543776 100644 --- a/src/test/kotlin/net/leanix/githubagent/services/GitHubAuthenticationServiceTest.kt +++ b/src/test/kotlin/net/leanix/githubagent/services/GitHubAuthenticationServiceTest.kt @@ -34,7 +34,7 @@ class GitHubAuthenticationServiceTest { every { resourceLoader.getResource(any()) } returns ClassPathResource("valid-private-key.pem") every { gitHubEnterpriseService.verifyJwt(any()) } returns Unit - assertDoesNotThrow { githubAuthenticationService.generateJwtToken() } + assertDoesNotThrow { githubAuthenticationService.generateAndCacheJwtToken() } assertNotNull(cachingService.get("jwtToken")) } @@ -44,6 +44,6 @@ class GitHubAuthenticationServiceTest { every { githubEnterpriseProperties.pemFile } returns "invalid-private-key.pem" every { resourceLoader.getResource(any()) } returns ClassPathResource("invalid-private-key.pem") - assertThrows(IllegalArgumentException::class.java) { githubAuthenticationService.generateJwtToken() } + assertThrows(IllegalArgumentException::class.java) { githubAuthenticationService.generateAndCacheJwtToken() } } }