use of com.aliyun.oss.common.provider.mock.CustomSessionCredentialsFetcherMock in project aliyun-oss-java-sdk by aliyun.
the class CustomSessionCredentialsProviderTest method testGetExpiredCredentials.
@Test
public void testGetExpiredCredentials() {
try {
CustomSessionCredentialsFetcher credentialsFetcher = new CustomSessionCredentialsFetcherMock(TestConfig.OSS_AUTH_SERVER_HOST).withResponseCategory(ResponseCategory.Expired);
CustomSessionCredentialsProvider credentialsProvider = new CustomSessionCredentialsProvider(TestConfig.OSS_AUTH_SERVER_HOST).withCredentialsFetcher(credentialsFetcher);
BasicCredentials credentials = (BasicCredentials) credentialsProvider.getCredentials();
Assert.assertEquals(credentials.getAccessKeyId().length(), 29);
Assert.assertEquals(credentials.getSecretAccessKey().length(), 44);
Assert.assertEquals(credentials.getSecurityToken().length(), 536);
Assert.assertTrue(credentials.useSecurityToken());
Assert.assertTrue(credentials.willSoonExpire());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.common.provider.mock.CustomSessionCredentialsFetcherMock in project aliyun-oss-java-sdk by aliyun.
the class CustomSessionCredentialsProviderTest method testGetNormalWithoutExpirationCredentials.
@Test
public void testGetNormalWithoutExpirationCredentials() {
try {
CustomSessionCredentialsFetcher credentialsFetcher = new CustomSessionCredentialsFetcherMock(TestConfig.OSS_AUTH_SERVER_HOST).withResponseCategory(ResponseCategory.NormalWithoutExpiration);
CustomSessionCredentialsProvider credentialsProvider = new CustomSessionCredentialsProvider(TestConfig.OSS_AUTH_SERVER_HOST).withCredentialsFetcher(credentialsFetcher);
BasicCredentials credentials = (BasicCredentials) credentialsProvider.getCredentials();
Assert.assertEquals(credentials.getAccessKeyId().length(), 29);
Assert.assertEquals(credentials.getSecretAccessKey().length(), 44);
Assert.assertFalse(credentials.useSecurityToken());
Assert.assertFalse(credentials.willSoonExpire());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.common.provider.mock.CustomSessionCredentialsFetcherMock in project aliyun-oss-java-sdk by aliyun.
the class CustomSessionCredentialsProviderTest method testGetNormalWithoutTokenCredentials.
@Test
public void testGetNormalWithoutTokenCredentials() {
try {
CustomSessionCredentialsFetcher credentialsFetcher = new CustomSessionCredentialsFetcherMock(TestConfig.OSS_AUTH_SERVER_HOST).withResponseCategory(ResponseCategory.NormalWithoutToken);
CustomSessionCredentialsProvider credentialsProvider = new CustomSessionCredentialsProvider(TestConfig.OSS_AUTH_SERVER_HOST).withCredentialsFetcher(credentialsFetcher);
BasicCredentials credentials = (BasicCredentials) credentialsProvider.getCredentials();
Assert.assertEquals(credentials.getAccessKeyId().length(), 29);
Assert.assertEquals(credentials.getSecretAccessKey().length(), 44);
Assert.assertFalse(credentials.useSecurityToken());
Assert.assertFalse(credentials.willSoonExpire());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.common.provider.mock.CustomSessionCredentialsFetcherMock in project aliyun-oss-java-sdk by aliyun.
the class CustomSessionCredentialsProviderTest method testGetCredentialsServerHalt.
@Test
public void testGetCredentialsServerHalt() {
try {
CustomSessionCredentialsFetcher credentialsFetcher = new CustomSessionCredentialsFetcherMock(TestConfig.OSS_AUTH_SERVER_HOST).withResponseCategory(ResponseCategory.ServerHalt);
CustomSessionCredentialsProvider credentialsProvider = new CustomSessionCredentialsProvider(TestConfig.OSS_AUTH_SERVER_HOST).withCredentialsFetcher(credentialsFetcher);
Credentials credentials = credentialsProvider.getCredentials();
Assert.assertNull(credentials);
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.aliyun.oss.common.provider.mock.CustomSessionCredentialsFetcherMock in project aliyun-oss-java-sdk by aliyun.
the class CustomSessionCredentialsProviderTest method testGetNormalCredentials.
@Test
public void testGetNormalCredentials() {
try {
CustomSessionCredentialsFetcher credentialsFetcher = new CustomSessionCredentialsFetcherMock(TestConfig.OSS_AUTH_SERVER_HOST).withResponseCategory(ResponseCategory.Normal);
CustomSessionCredentialsProvider credentialsProvider = new CustomSessionCredentialsProvider(TestConfig.OSS_AUTH_SERVER_HOST).withCredentialsFetcher(credentialsFetcher);
BasicCredentials credentials = (BasicCredentials) credentialsProvider.getCredentials();
Assert.assertEquals(credentials.getAccessKeyId().length(), 29);
Assert.assertEquals(credentials.getSecretAccessKey().length(), 44);
Assert.assertEquals(credentials.getSecurityToken().length(), 536);
Assert.assertTrue(credentials.useSecurityToken());
Assert.assertFalse(credentials.willSoonExpire());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
Aggregations