diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/blob_test.rb | 6 | ||||
-rw-r--r-- | test/database/setup.rb | 4 | ||||
-rw-r--r-- | test/disk_controller_test.rb | 14 | ||||
-rw-r--r-- | test/filename_test.rb | 12 | ||||
-rw-r--r-- | test/site/disk_site_test.rb | 6 | ||||
-rw-r--r-- | test/site/gcs_site_test.rb | 6 | ||||
-rw-r--r-- | test/site/s3_site_test.rb | 6 | ||||
-rw-r--r-- | test/site/shared_site_tests.rb | 2 | ||||
-rw-r--r-- | test/test_helper.rb | 12 | ||||
-rw-r--r-- | test/verified_key_with_expiration_test.rb | 12 |
10 files changed, 40 insertions, 40 deletions
diff --git a/test/blob_test.rb b/test/blob_test.rb index 9d190fb703..c7b4aeed39 100644 --- a/test/blob_test.rb +++ b/test/blob_test.rb @@ -1,8 +1,8 @@ require "test_helper" require "database/setup" -require "active_file/blob" +require "active_vault/blob" -class ActiveFile::BlobTest < ActiveSupport::TestCase +class ActiveVault::BlobTest < ActiveSupport::TestCase test "create after upload sets byte size and checksum" do data = "Hello world!" blob = create_blob data: data @@ -23,6 +23,6 @@ class ActiveFile::BlobTest < ActiveSupport::TestCase private def expected_url_for(blob, disposition: :inline) - "/rails/blobs/#{ActiveFile::VerifiedKeyWithExpiration.encode(blob.key, expires_in: 5.minutes)}?disposition=#{disposition}" + "/rails/blobs/#{ActiveVault::VerifiedKeyWithExpiration.encode(blob.key, expires_in: 5.minutes)}?disposition=#{disposition}" end end diff --git a/test/database/setup.rb b/test/database/setup.rb index 21ede8f49c..bc6e8b9ec1 100644 --- a/test/database/setup.rb +++ b/test/database/setup.rb @@ -1,4 +1,4 @@ -require "active_file/migration" +require "active_vault/migration" ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') -ActiveFile::CreateBlobs.migrate(:up) +ActiveVault::CreateBlobs.migrate(:up) diff --git a/test/disk_controller_test.rb b/test/disk_controller_test.rb index ee172b23f7..eaf0b497ac 100644 --- a/test/disk_controller_test.rb +++ b/test/disk_controller_test.rb @@ -4,30 +4,30 @@ require "database/setup" require "action_controller" require "action_controller/test_case" -require "active_file/disk_controller" -require "active_file/verified_key_with_expiration" +require "active_vault/disk_controller" +require "active_vault/verified_key_with_expiration" -class ActiveFile::DiskControllerTest < ActionController::TestCase +class ActiveVault::DiskControllerTest < ActionController::TestCase Routes = ActionDispatch::Routing::RouteSet.new.tap do |routes| routes.draw do - get "/rails/blobs/:encoded_key" => "active_file/disk#show", as: :rails_disk_blob + get "/rails/blobs/:encoded_key" => "active_vault/disk#show", as: :rails_disk_blob end end setup do @blob = create_blob @routes = Routes - @controller = ActiveFile::DiskController.new + @controller = ActiveVault::DiskController.new end test "showing blob inline" do - get :show, params: { encoded_key: ActiveFile::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes) } + get :show, params: { encoded_key: ActiveVault::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes) } assert_equal "inline; filename=\"#{@blob.filename}\"", @response.headers["Content-Disposition"] assert_equal "text/plain", @response.headers["Content-Type"] end test "sending blob as attachment" do - get :show, params: { encoded_key: ActiveFile::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes), disposition: :attachment } + get :show, params: { encoded_key: ActiveVault::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes), disposition: :attachment } assert_equal "attachment; filename=\"#{@blob.filename}\"", @response.headers["Content-Disposition"] assert_equal "text/plain", @response.headers["Content-Type"] end diff --git a/test/filename_test.rb b/test/filename_test.rb index c42ae8ca54..5cb67016c0 100644 --- a/test/filename_test.rb +++ b/test/filename_test.rb @@ -1,9 +1,9 @@ require "test_helper" -class ActiveFile::FilenameTest < ActiveSupport::TestCase +class ActiveVault::FilenameTest < ActiveSupport::TestCase test "sanitize" do "%$|:;/\t\r\n\\".each_char do |character| - filename = ActiveFile::Filename.new("foo#{character}bar.pdf") + filename = ActiveVault::Filename.new("foo#{character}bar.pdf") assert_equal 'foo-bar.pdf', filename.sanitized assert_equal 'foo-bar.pdf', filename.to_s end @@ -16,21 +16,21 @@ class ActiveFile::FilenameTest < ActiveSupport::TestCase "\xCF" => "�", "\x00" => "", }.each do |actual, expected| - assert_equal expected, ActiveFile::Filename.new(actual).sanitized + assert_equal expected, ActiveVault::Filename.new(actual).sanitized end end test "strips RTL override chars used to spoof unsafe executables as docs" do # Would be displayed in Windows as "evilexe.pdf" due to the right-to-left # (RTL) override char! - assert_equal 'evil-fdp.exe', ActiveFile::Filename.new("evil\u{202E}fdp.exe").sanitized + assert_equal 'evil-fdp.exe', ActiveVault::Filename.new("evil\u{202E}fdp.exe").sanitized end test "compare case-insensitively" do - assert_operator ActiveFile::Filename.new('foobar.pdf'), :==, ActiveFile::Filename.new('FooBar.PDF') + assert_operator ActiveVault::Filename.new('foobar.pdf'), :==, ActiveVault::Filename.new('FooBar.PDF') end test "compare sanitized" do - assert_operator ActiveFile::Filename.new('foo-bar.pdf'), :==, ActiveFile::Filename.new("foo\tbar.pdf") + assert_operator ActiveVault::Filename.new('foo-bar.pdf'), :==, ActiveVault::Filename.new("foo\tbar.pdf") end end diff --git a/test/site/disk_site_test.rb b/test/site/disk_site_test.rb index 63f12ad335..e9ebdcb0be 100644 --- a/test/site/disk_site_test.rb +++ b/test/site/disk_site_test.rb @@ -1,8 +1,8 @@ require "tmpdir" require "site/shared_site_tests" -class ActiveFile::Site::DiskSiteTest < ActiveSupport::TestCase - SITE = ActiveFile::Site.configure(:Disk, root: File.join(Dir.tmpdir, "active_file")) +class ActiveVault::Site::DiskSiteTest < ActiveSupport::TestCase + SITE = ActiveVault::Site.configure(:Disk, root: File.join(Dir.tmpdir, "active_vault")) - include ActiveFile::Site::SharedSiteTests + include ActiveVault::Site::SharedSiteTests end diff --git a/test/site/gcs_site_test.rb b/test/site/gcs_site_test.rb index c5f32a0595..56514ef136 100644 --- a/test/site/gcs_site_test.rb +++ b/test/site/gcs_site_test.rb @@ -1,10 +1,10 @@ require "site/shared_site_tests" if SITE_CONFIGURATIONS[:gcs] - class ActiveFile::Site::GCSSiteTest < ActiveSupport::TestCase - SITE = ActiveFile::Site.configure(:GCS, SITE_CONFIGURATIONS[:gcs]) + class ActiveVault::Site::GCSSiteTest < ActiveSupport::TestCase + SITE = ActiveVault::Site.configure(:GCS, SITE_CONFIGURATIONS[:gcs]) - include ActiveFile::Site::SharedSiteTests + include ActiveVault::Site::SharedSiteTests end else puts "Skipping GCS Site tests because no GCS configuration was supplied" diff --git a/test/site/s3_site_test.rb b/test/site/s3_site_test.rb index 7629b78ad5..6daeaac2ea 100644 --- a/test/site/s3_site_test.rb +++ b/test/site/s3_site_test.rb @@ -1,10 +1,10 @@ require "site/shared_site_tests" if SITE_CONFIGURATIONS[:s3] - class ActiveFile::Site::S3SiteTest < ActiveSupport::TestCase - SITE = ActiveFile::Site.configure(:S3, SITE_CONFIGURATIONS[:s3]) + class ActiveVault::Site::S3SiteTest < ActiveSupport::TestCase + SITE = ActiveVault::Site.configure(:S3, SITE_CONFIGURATIONS[:s3]) - include ActiveFile::Site::SharedSiteTests + include ActiveVault::Site::SharedSiteTests end else puts "Skipping S3 Site tests because no S3 configuration was supplied" diff --git a/test/site/shared_site_tests.rb b/test/site/shared_site_tests.rb index de1a54b874..56f1a13742 100644 --- a/test/site/shared_site_tests.rb +++ b/test/site/shared_site_tests.rb @@ -8,7 +8,7 @@ rescue Errno::ENOENT puts "Missing site configuration file in test/sites/configurations.yml" end -module ActiveFile::Site::SharedSiteTests +module ActiveVault::Site::SharedSiteTests extend ActiveSupport::Concern FIXTURE_KEY = SecureRandom.base58(24) diff --git a/test/test_helper.rb b/test/test_helper.rb index 9bb4a2fca1..96ef58b73f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,17 +4,17 @@ require "active_support/test_case" require "active_support/testing/autorun" require "byebug" -require "active_file" +require "active_vault" -require "active_file/site" -ActiveFile::Blob.site = ActiveFile::Site.configure(:Disk, root: File.join(Dir.tmpdir, "active_file")) +require "active_vault/site" +ActiveVault::Blob.site = ActiveVault::Site.configure(:Disk, root: File.join(Dir.tmpdir, "active_vault")) -require "active_file/verified_key_with_expiration" -ActiveFile::VerifiedKeyWithExpiration.verifier = ActiveSupport::MessageVerifier.new("Testing") +require "active_vault/verified_key_with_expiration" +ActiveVault::VerifiedKeyWithExpiration.verifier = ActiveSupport::MessageVerifier.new("Testing") class ActiveSupport::TestCase private def create_blob(data: "Hello world!", filename: "hello.txt", content_type: "text/plain") - ActiveFile::Blob.create_after_upload! io: StringIO.new(data), filename: filename, content_type: content_type + ActiveVault::Blob.create_after_upload! io: StringIO.new(data), filename: filename, content_type: content_type end end
\ No newline at end of file diff --git a/test/verified_key_with_expiration_test.rb b/test/verified_key_with_expiration_test.rb index 8f145590d0..073bb047f6 100644 --- a/test/verified_key_with_expiration_test.rb +++ b/test/verified_key_with_expiration_test.rb @@ -1,19 +1,19 @@ require "test_helper" require "active_support/core_ext/securerandom" -class ActiveFile::VerifiedKeyWithExpirationTest < ActiveSupport::TestCase +class ActiveVault::VerifiedKeyWithExpirationTest < ActiveSupport::TestCase FIXTURE_KEY = SecureRandom.base58(24) test "without expiration" do - encoded_key = ActiveFile::VerifiedKeyWithExpiration.encode(FIXTURE_KEY) - assert_equal FIXTURE_KEY, ActiveFile::VerifiedKeyWithExpiration.decode(encoded_key) + encoded_key = ActiveVault::VerifiedKeyWithExpiration.encode(FIXTURE_KEY) + assert_equal FIXTURE_KEY, ActiveVault::VerifiedKeyWithExpiration.decode(encoded_key) end test "with expiration" do - encoded_key = ActiveFile::VerifiedKeyWithExpiration.encode(FIXTURE_KEY, expires_in: 1.minute) - assert_equal FIXTURE_KEY, ActiveFile::VerifiedKeyWithExpiration.decode(encoded_key) + encoded_key = ActiveVault::VerifiedKeyWithExpiration.encode(FIXTURE_KEY, expires_in: 1.minute) + assert_equal FIXTURE_KEY, ActiveVault::VerifiedKeyWithExpiration.decode(encoded_key) travel 2.minutes - assert_nil ActiveFile::VerifiedKeyWithExpiration.decode(encoded_key) + assert_nil ActiveVault::VerifiedKeyWithExpiration.decode(encoded_key) end end |