CloudStore { public AmazonS3 getS3Client() { if (!awsEnabled) { throw new ResourceException(ResourceException.INTERNAL_SERVER_ERROR, "AWS Support not enabled"); } if (credentials == null) { throw new ResourceException(ResourceException.INTERNAL_SERVER_ERROR, "AWS Role credentials are not available"); } return AmazonS3ClientBuilder.standard() .withCredentials(new AWSStaticCredentialsProvider(credentials)) .withRegion(Regions.fromName(awsRegion)) .build(); } CloudStore(); void close(); void setHttpClient(HttpClient client); boolean isAwsEnabled(); AmazonS3 getS3Client(); AWSTemporaryCredentials assumeAWSRole(String account, String roleName, String principal,
                                                 Integer durationSeconds, String externalId); String getCloudAccount(String domainName);  }
@Test public void testGetS3Client() { System.setProperty(ZTS_PROP_AWS_PUBLIC_CERT, "src/test/resources/aws_public.crt"); CloudStore store = new CloudStore(); store.credentials = new BasicSessionCredentials("accessKey", "secretKey", "token"); store.awsEnabled = true; store.awsRegion = "us-west-2"; assertNotNull(store.getS3Client()); assertNotNull(store.getS3Client()); store.close(); }