Skip to content

Commit

Permalink
Fix testing using S3Mock
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Dolski committed May 22, 2018
1 parent 3648a1b commit ade7c21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Expand Up @@ -8,13 +8,10 @@
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSCredentialsProviderChain;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.AnonymousAWSCredentials;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import edu.illinois.library.cantaloupe.config.ConfigurationFactory;

/**
* Creates an AWS client using the Builder pattern.
Expand Down Expand Up @@ -126,12 +123,6 @@ private AWSCredentialsProvider getCredentialsProvider() {
// and use the first one that works.
final List<AWSCredentialsProvider> providers = new ArrayList<>();

// Use anonymous credentials with S3Mock when testing.
// This is rather crude but will do for now.
if ("memory".equals(System.getProperty(ConfigurationFactory.CONFIG_VM_ARGUMENT))) {
providers.add(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()));
}

// As a first resort, add a provider that draws from the application
// configuration.
AWSCredentialsProvider configProvider =
Expand Down
10 changes: 6 additions & 4 deletions test.properties.sample
Expand Up @@ -2,14 +2,16 @@
# and edit that.

# Used by S3SourceTest and S3CacheTest.
# Leave blank to use a built-in mock S3 endpoint.
# Note: to use S3Mock, leave the endpoint blank and set the keys to non-empty
# strings.
s3.endpoint =
s3.access_key_id =
s3.secret_key =
s3.access_key_id = s3mock
s3.secret_key = s3mock
s3.bucket = test.cantaloupe.library.illinois.edu

# Used by AzureStorageSourceTest and AzureStorageCacheTest.
# Note: leave blank to test sas and container specified in a URL to the object key.
# Note: leave blank to test SAS and container specified in a URL to the object
# key.
azurestorage.account_name =
azurestorage.account_key =
azurestorage.container =
Expand Down

0 comments on commit ade7c21

Please sign in to comment.