Skip to content

Commit

Permalink
adapt to last changes from jenkinsci/credentials-plugin#558
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Lamy <olamy@apache.org>
  • Loading branch information
olamy committed Sep 17, 2024
1 parent a342d69 commit 430421d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>

<hpi.compatibleSinceVersion>190</hpi.compatibleSinceVersion>
</properties>

<dependencies>
Expand All @@ -72,7 +74,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1380.vd7b_c2d143cd0</version>
<version>1383.va_3924cecb_a_36</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.Extension;
import hudson.model.Descriptor;
import hudson.util.FormValidation;
import hudson.util.Secret;
import jenkins.security.FIPS140;
Expand Down Expand Up @@ -48,7 +49,8 @@ public class OpenShiftBearerTokenCredentialImpl extends UsernamePasswordCredenti
private transient ConcurrentMap<String, Token> tokenCache = new ConcurrentHashMap<>();

@DataBoundConstructor
public OpenShiftBearerTokenCredentialImpl(CredentialsScope scope, String id, String description, String username, String password) {
public OpenShiftBearerTokenCredentialImpl(CredentialsScope scope, String id, String description, String username, String password)
throws Descriptor.FormException {
super(scope, id, description, username, password);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void unprepareFakeOAuthServer() {
}

@Test
public void ensureFIPSCompliantURIRequest() throws IOException {
public void ensureFIPSCompliantURIRequest() throws Exception {
OpenShiftBearerTokenCredentialImpl cred =
new OpenShiftBearerTokenCredentialImpl(CredentialsScope.GLOBAL, "id", "description", "username", "theaustraliancricketteamisthebest");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ private String getURI() {
}

@Test
public void testValidResponse() throws IOException {
public void testValidResponse() throws Exception {
OpenShiftBearerTokenCredentialImpl t = new OpenShiftBearerTokenCredentialImpl(CredentialsScope.GLOBAL, CREDENTIAL_ID, "sample", USERNAME, PASSWORD);
String token = t.getToken(getURI() + "valid-response", null, true);
assertEquals("1234", token);
}

@Test
public void testMultipleCachedTokens() throws IOException {
public void testMultipleCachedTokens() throws Exception {
OpenShiftBearerTokenCredentialImpl t = new OpenShiftBearerTokenCredentialImpl(CredentialsScope.GLOBAL, CREDENTIAL_ID, "sample", USERNAME, PASSWORD);
String token1 = t.getToken(getURI() + "valid-response", null, true);
String token2 = t.getToken(getURI() + "valid-response2", null, true);
Expand All @@ -70,7 +70,7 @@ public void testMultipleCachedTokens() throws IOException {
}

@Test
public void testBadStatusCode() throws IOException {
public void testBadStatusCode() throws Exception {
expectedEx.expect(IOException.class);
expectedEx.expectMessage("The response from the OAuth server was invalid: The OAuth service didn't respond with a redirection but with '400: Bad Request'");

Expand All @@ -79,7 +79,7 @@ public void testBadStatusCode() throws IOException {
}

@Test
public void testMissingLocation() throws IOException {
public void testMissingLocation() throws Exception {
expectedEx.expect(IOException.class);
expectedEx.expectMessage("The response from the OAuth server was invalid: The OAuth service didn't respond with location header");

Expand All @@ -88,7 +88,7 @@ public void testMissingLocation() throws IOException {
}

@Test
public void testBadLocation() throws IOException {
public void testBadLocation() throws Exception {
expectedEx.expect(IOException.class);
expectedEx.expectMessage("The response from the OAuth server was invalid: The response contained no token");

Expand Down

0 comments on commit 430421d

Please sign in to comment.