Use Connector.lookupScanCredentials to contextualize GitHubAppCredentials#398
Conversation
…lize GitHubAppCredentials
…dentials contextualization
| new PluginLogger(j.createTaskListener().getLogger(), "GitHub Checks"), | ||
| wireMockRule.baseUrl()) | ||
| .publish(details); | ||
| try (var credentialsMatchers = mockCredentialsMatchers()) { |
There was a problem hiding this comment.
Introduced try-with-resource for static mock auto-close. The body is indented without any change.
| .contains("endColumn=20") | ||
| .contains("annotationLevel=WARNING") | ||
| .contains("message='say hello to Jenkins'"); | ||
| try (var credentialsMatchers = mockCredentialsMatchers()) { |
There was a problem hiding this comment.
Introduced try-with-resource for static mock auto-close. The body is indented without any change.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #398 +/- ##
============================================
- Coverage 71.80% 71.58% -0.22%
- Complexity 162 163 +1
============================================
Files 16 16
Lines 532 535 +3
Branches 51 51
============================================
+ Hits 382 383 +1
- Misses 124 126 +2
Partials 26 26 ☔ View full report in Codecov by Sentry. |
| try (MockedStatic<Connector> connector = mockStatic(Connector.class)) { | ||
| connector.when(() -> Connector.connect(anyString(), any(GitHubAppCredentials.class))).thenReturn(gitHub); | ||
| try (var credentialsMatchers = mockCredentialsMatchers(); var connector = mockStatic(Connector.class)) { | ||
| connector.when(() -> Connector.lookupScanCredentials(any(), any(), any(), any())).thenCallRealMethod(); |
There was a problem hiding this comment.
Call real method to involve GitHubAppCredentials contextualization
|
|
||
| when(scmFacade.findGitHubSCMSource(job)).thenReturn(Optional.of(source)); | ||
| when(scmFacade.findGitHubAppCredentials(job, "1")).thenReturn(Optional.of(gitHubAppCredentials)); | ||
| when(scmFacade.findGitHubAppCredentials(job, "1")).thenCallRealMethod(); |
There was a problem hiding this comment.
Call real method to involve GitHubAppCredentials contextualization
#396 fixed
GitHubAppCredentialsowner inference usingwithOwnermethod which not considered as a public API.This uses
Connector.lookupScanCredentialsfrom GitHub Branch Source plugin to contextualize the credentials automatically. It removes the direct usage ofGitHubAppCredentials.withOwnerfromgithub-checks-plugin.This includes some mocking adjustments to involve the credentials contextualization provided by
github-branch-plugin.Testing done
Submitter checklist