Skip to content

Commit

Permalink
fix: prevent publication with unsupported credential types
Browse files Browse the repository at this point in the history
fixes: #347
  • Loading branch information
pcanilho committed Jul 5, 2023
1 parent 983fed5 commit 0e877c2
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public GitHubChecksPublisher(final GitHubChecksContext context, final PluginLogg
public void publish(final ChecksDetails details) {
try {
StandardUsernameCredentials credentials = context.getCredentials();
// Prevent publication with unsupported credential types
switch (credentials.getClass().getSimpleName()) {

Check warning on line 68 in src/main/java/io/jenkins/plugins/checks/github/GitHubChecksPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 68 is only partially covered, one branch is missing
case "GitHubAppCredentials":
case "VaultUsernamePasswordCredentialImpl":
break;
default:
return;

Check warning on line 73 in src/main/java/io/jenkins/plugins/checks/github/GitHubChecksPublisher.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 73 is not covered by tests

Check warning on line 73 in src/main/java/io/jenkins/plugins/checks/github/GitHubChecksPublisher.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/io/jenkins/plugins/checks/github/GitHubChecksPublisher.java#L73

Added line #L73 was not covered by tests
}

String apiUri = null;
if (credentials instanceof GitHubAppCredentials) {
apiUri = ((GitHubAppCredentials) credentials).getApiUri();
Expand Down

0 comments on commit 0e877c2

Please sign in to comment.