-
Notifications
You must be signed in to change notification settings - Fork 38
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call real method to involve GitHubAppCredentials contextualization
#396 fixed
GitHubAppCredentials
owner inference usingwithOwner
method which not considered as a public API.This uses
Connector.lookupScanCredentials
from GitHub Branch Source plugin to contextualize the credentials automatically. It removes the direct usage ofGitHubAppCredentials.withOwner
fromgithub-checks-plugin
.This includes some mocking adjustments to involve the credentials contextualization provided by
github-branch-plugin
.Testing done
Submitter checklist