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 dfa552f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Test with Maven
run: mvn test -B -f ./aliyun-java-sdk-core/pom.xml
run: |
java -version
mvn test -B -f ./aliyun-java-sdk-core/pom.xml
- name: Upload Coverage Report
uses: codecov/codecov-action@v4
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ 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
public void run() throws Throwable {
provider.getCredentials();
}
});
ex.printStackTrace();
String message = ex.getMessage();
Assert.assertTrue(message.contains("Parameter OIDCProviderArn is not valid"));
}
Expand Down
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 dfa552f

Please sign in to comment.