diff options
Diffstat (limited to 'test/sites')
-rw-r--r-- | test/sites/.gitignore | 1 | ||||
-rw-r--r-- | test/sites/configurations-example.yml | 11 | ||||
-rw-r--r-- | test/sites/gcs_site_test.rb | 8 | ||||
-rw-r--r-- | test/sites/s3_site_test.rb | 11 | ||||
-rw-r--r-- | test/sites/shared_site_tests.rb | 9 |
5 files changed, 26 insertions, 14 deletions
diff --git a/test/sites/.gitignore b/test/sites/.gitignore new file mode 100644 index 0000000000..c102131f3d --- /dev/null +++ b/test/sites/.gitignore @@ -0,0 +1 @@ +configurations.yml diff --git a/test/sites/configurations-example.yml b/test/sites/configurations-example.yml new file mode 100644 index 0000000000..031197342a --- /dev/null +++ b/test/sites/configurations-example.yml @@ -0,0 +1,11 @@ +# Copy this file to configurations.yml and edit the credentials to match your IAM test account and bucket +s3: + access_key_id: + secret_access_key: + region: + bucket: + +gcs: + project: + keyfile: + bucket: diff --git a/test/sites/gcs_site_test.rb b/test/sites/gcs_site_test.rb index e43223c28d..fbf6c4a242 100644 --- a/test/sites/gcs_site_test.rb +++ b/test/sites/gcs_site_test.rb @@ -1,13 +1,11 @@ require "sites/shared_site_tests" -if ENV["GCS_PROJECT"] && ENV["GCS_KEYFILE"] && ENV["GCS_BUCKET"] +if SITE_CONFIGURATIONS[:gcs] class ActiveFile::Sites::GCSSiteTest < ActiveSupport::TestCase - SITE = ActiveFile::Sites::GCSSite.new( - project: ENV["GCS_PROJECT"], keyfile: ENV["GCS_KEYFILE"], bucket: ENV["GCS_BUCKET"] - ) + SITE = ActiveFile::Sites::GCSSite.new(SITE_CONFIGURATIONS[:gcs]) include ActiveFile::Sites::SharedSiteTests end else - puts "Skipping GCS Site tests because ENV variables are missing" + puts "Skipping GCS Site tests because no GCS configuration was supplied" end diff --git a/test/sites/s3_site_test.rb b/test/sites/s3_site_test.rb index 9e165f0dea..12f5d084f6 100644 --- a/test/sites/s3_site_test.rb +++ b/test/sites/s3_site_test.rb @@ -1,16 +1,11 @@ require "sites/shared_site_tests" -if ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"] && ENV["AWS_REGION"] && ENV["AWS_S3_BUCKET"] +if SITE_CONFIGURATIONS[:s3] class ActiveFile::Sites::S3SiteTest < ActiveSupport::TestCase - SITE = ActiveFile::Sites::S3Site.new( - access_key_id: ENV["AWS_ACCESS_KEY_ID"], - secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"], - region: ENV["AWS_REGION"], - bucket: ENV["AWS_S3_BUCKET"] - ) + SITE = ActiveFile::Sites::S3Site.new(SITE_CONFIGURATIONS[:s3]) include ActiveFile::Sites::SharedSiteTests end else - puts "Skipping S3 Site tests because ENV variables are missing" + puts "Skipping S3 Site tests because no S3 configuration was supplied" end diff --git a/test/sites/shared_site_tests.rb b/test/sites/shared_site_tests.rb index fd900be4a4..de28d7ae63 100644 --- a/test/sites/shared_site_tests.rb +++ b/test/sites/shared_site_tests.rb @@ -1,9 +1,16 @@ require "test_helper" require "active_support/core_ext/securerandom" +require "yaml" + +SITE_CONFIGURATIONS = begin + YAML.load_file(File.expand_path("../configurations.yml", __FILE__)).deep_symbolize_keys +rescue Errno::ENOENT + puts "Missing site configuration file in test/sites/configurations.yml" +end module ActiveFile::Sites::SharedSiteTests extend ActiveSupport::Concern - + FIXTURE_KEY = SecureRandom.base58(24) FIXTURE_FILE = StringIO.new("Hello world!") |