Skip to content

Commit

Permalink
fix unit test for OIDC
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Jul 22, 2024
1 parent 0a35f47 commit dbfd7fd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void run() throws Throwable {
@Test
public void getCredentialsTest() throws ClientException {
String filePath = OIDCCredentialsProviderTest.class.getClassLoader().getResource("oidctoken").getPath();
final AlibabaCloudCredentialsProvider provider = new OIDCCredentialsProvider("roleArn", "providerArn", filePath, null, null);
final AlibabaCloudCredentialsProvider provider = new OIDCCredentialsProvider("roleArn", "providerArn", filePath, null, "us-west-1");
Assert.assertNotNull(provider);
ClientException ex = Assert.assertThrows(ClientException.class, new ThrowingRunnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public void withRoleSessionDurationSecondsSmallerThan900Seconds() {
STSAssumeRoleSessionCredentialsProvider provider = new STSAssumeRoleSessionCredentialsProvider(credentials,
roleArn, clientProfile);
provider.withRoleSessionDurationSeconds(duration);

}

@Test
Expand All @@ -137,7 +136,6 @@ public void withRoleSessionDurationSecondsLargerThan3600Seconds() {
STSAssumeRoleSessionCredentialsProvider provider = new STSAssumeRoleSessionCredentialsProvider(credentials,
roleArn, clientProfile);
provider.withRoleSessionDurationSeconds(duration);

}

@Test
Expand Down Expand Up @@ -193,6 +191,5 @@ public void getCredentialsReturnPreviousCredentials() throws ClientException {

AlibabaCloudCredentials credentials3 = provider.getCredentials();
Assert.assertEquals(credentials2, credentials3);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ public void testGetSetHttpProxy() {
Assert.assertNull(EnvironmentUtils.getHttpProxy());
EnvironmentUtils.setHttpProxy("http://www.aliyun.com");
Assert.assertEquals("http://www.aliyun.com", EnvironmentUtils.getHttpProxy());
// reset http proxy
EnvironmentUtils.setHttpProxy(null);
}

@Test
public void testGetSetHttpsProxy() {
Assert.assertNull(EnvironmentUtils.getHttpsProxy());
EnvironmentUtils.setHttpsProxy("https://www.aliyun.com");
Assert.assertEquals("https://www.aliyun.com", EnvironmentUtils.getHttpsProxy());
// reset https proxy
EnvironmentUtils.setHttpsProxy(null);
}

@Test
public void testGetSetNoProxy() {
Assert.assertNull(EnvironmentUtils.getNoProxy());
EnvironmentUtils.setNoProxy("https://www.aliyun.com");
Assert.assertEquals("https://www.aliyun.com", EnvironmentUtils.getNoProxy());
// reset no proxy
EnvironmentUtils.setNoProxy(null);
}
}

0 comments on commit dbfd7fd

Please sign in to comment.