aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test/service
Commit message (Collapse)AuthorAgeFilesLines
* Delegated path_for to primary in the MirrorServiceAbhay Nikam2019-02-141-0/+4
|
* include the content type when uploading to S3Simo Leone2019-01-241-0/+18
|
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-215-148/+126
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* add require 'database/setup' in activestorage/test/service/s3_service_test.rbMarcelo Perini Veloso2018-12-011-0/+1
|
* `metadata` is not passed to serviceyuuji.yaginuma2018-12-011-2/+1
| | | | | | | | | Ref: https://github.com/rails/rails/blob/604fac6d7191fca102380b1a5f5eb9c619fb407f/activestorage/app/models/active_storage/blob.rb#L256-L264 This fixes broken `GCSServiceTest`. https://travis-ci.org/rails/rails/jobs/461868394#L6624-L6626 Follow up to #34576.
* Add a test with extra keys to active_storage Service#uploadYannick Schutz2018-11-301-0/+19
|
* Fix "warning: ambiguous first argument; put parentheses or a space even ↵yuuji.yaginuma2018-11-281-3/+3
| | | | after `/' operator"
* Remove duplicated testyuuji.yaginuma2018-11-281-14/+0
| | | | | | | | | | | | Since 06ab7b27ea1c1ab357085439abacdb464f6742bf, `GCSServiceTest#test_signed_URL_response_headers` is broken. https://travis-ci.org/rails/rails/jobs/460454477#L7084-L7087 This seems to be due to lack of `content_type` at upload. This is solved by specifying `conten_type`. However, since the same content is also tested with `test_upload_with_content_type`, it will be duplicated content, so I think that can remove `test_signed_URL_response_headers`.
* Prevent content type and disposition bypass in storage service URLsRosa Gutierrez2018-11-271-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Force content-type to binary on service urls for relevant content types We have a list of content types that must be forcibly served as binary, but in practice this only means to serve them as attachment always. We should also set the Content-Type to the configured binary type. As a bonus: add text/cache-manifest to the list of content types to be served as binary by default. * Store content-disposition and content-type in GCS Forcing these in the service_url when serving the file works fine for S3 and Azure, since these services include params in the signature. However, GCS specifically excludes response-content-disposition and response-content-type from the signature, which means an attacker can modify these and have files that should be served as text/plain attachments served as inline HTML for example. This makes our attempt to force specific files to be served as binary and as attachment can be easily bypassed. The only way this can be forced in GCS is by storing content-disposition and content-type in the object metadata. * Update GCS object metadata after identifying blob In some cases we create the blob and upload the data before identifying the content-type, which means we can't store that in GCS right when uploading. In these, after creating the attachment, we enqueue a job to identify the blob, and set the content-type. In other cases, files are uploaded to the storage service via direct upload link. We create the blob before the direct upload, which happens independently from the blob creation itself. We then mark the blob as identified, but we have already the content-type we need without having put it in the service. In these two cases, then, we need to update the metadata in the GCS service. * Include content-type and disposition in the verified key for disk service This prevents an attacker from modifying these params in the service signed URL, which is particularly important when we want to force them to have specific values for security reasons. * Allow only a list of specific content types to be served inline This is different from the content types that must be served as binary in the sense that any content type not in this list will be always served as attachment but with its original content type. Only types in this list are allowed to be served either inline or as attachment. Apart from forcing this in the service URL, for GCS we need to store the disposition in the metadata. Fix CVE-2018-16477.
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* Fix zero-byte files uploadMarcelo Perini Veloso2018-09-061-0/+7
|
* Translate service-specific missing object exceptions into a generic oneCameron Bothner2018-08-211-0/+21
| | | | | | | | | `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise `ActiveStorage::FileNotFoundError` when the corresponding file is missing from the storage service. Services translate service-specific missing object exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and `Errno::ENOENT` for the disk service) into `ActiveStorage::FileNotFoundError`.
* Improve ActiveStorage service adapter error handlingJoel Taylor2018-08-061-0/+6
|
* Fix uploading Tempfiles to Azure StorageGeorge Claghorn2018-08-031-0/+17
| | | | Closes #32530.
* Generate a new key for each service testGeorge Claghorn2018-06-256-20/+20
| | | | Sidestep Google Cloud Storage's restrictive per-object rate limit.
* Fix "warning: Net::HTTPResponse#header is obsolete"yuuji.yaginuma2018-06-171-1/+1
| | | | Ref: https://github.com/ruby/ruby/blob/cc77a811298bd7ab1c422f7f999b93c858327da9/lib/net/http/response.rb#L138-L155
* Merge pull request #32144 from kazu9su/masterGeorge Claghorn2018-05-221-0/+4
|\ | | | | Add ActiveStorage::Service::DiskService#url_for_direct_upload test
| * Add ActiveStorage::Service::DiskService#url_for_direct_upload testtommy2018-03-011-0/+4
| |
* | Support streaming downloads from Google Cloud StorageGeorge Claghorn2018-05-011-5/+13
| |
* | Use a current model to provide the host for service urlsAndrew White2018-04-061-1/+1
| | | | | | | | | | | | | | Trying to pass the current request down to the service so that it can create full urls instead of paths makes the API messy so use a model based on ActiveSupport::CurrentAttributes to provide the current host to services that need it (primarily the disk service).
* | Allow full use of the AWS S3 SDK authentication options (#32270)Brian Knight2018-03-191-1/+1
| | | | | | | | | | | | | | | | | | If an explicit AWS key pair and/or region is not provided in config/storage.yml, attempt to use environment variables, shared credentials, or IAM role credentials. Order of precedence is determined by the AWS SDK[1]. [1]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html
* | Update ASt test services configGeorge Claghorn2018-03-121-0/+0
| |
* | Remove path config option from Azure serviceAndrew White2018-03-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | The Active Storage service for Azure Storage has an option called `path` that is ambiguous in meaning. It needs to be set to the primary blob storage endpoint but that can be determined from the blobs client anyway. To simplify the configuration this commit removes the `path` option and gets the endpoint from the blobs client instead. Closes #32225.
* | Generate root-relative paths in Active Storage disk service URL methodsGeorge Claghorn2018-03-052-2/+5
|/ | | | Fixes #32129.
* Avoid specifying content types for direct uploads to Google Cloud StorageGeorge Claghorn2018-02-261-1/+1
| | | | Fix customizing the download Content-Type for a directly-uploaded blob via a signed URL. See e8286ee.
* Allow S3 tests against buckets in other regionsAndrew White2018-02-211-1/+1
| | | | | Only us-east-1 gives URLs like bucket.s3.amazonaws.com whereas other regions have URLs like s3-eu-west-1.amazonaws.com/ubxd-rails
* Eliminate ActiveStorage::Service::MirrorServiceTest#uploadShuhei Kitagawa2018-01-271-16/+16
|
* Use assert_predicate and assert_not_predicateDaniel Colson2018-01-251-1/+1
|
* Provide a sensible default hostGeorge Claghorn2018-01-163-5/+4
|
* Extract content types from blob dataGeorge Claghorn2018-01-153-5/+9
|
* Fix customizing Content-Type via GCS service URLsGeorge Claghorn2017-12-071-0/+14
|
* Purge variants with their blobsGeorge Claghorn2017-12-021-0/+17
|
* Use `credentials` instead of `keyfile` in GCS seviceyuuji.yaginuma2017-11-291-1/+1
| | | | | | | | | | | | | The `keyfile` was renamed to `credentials` in `google-cloud-storage` 1.8.0. https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/google-cloud-storage/CHANGELOG.md#180--2017-11-14 Although `keyfile` can still be used, but it looks like deprecate. https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/ddf7b2a856d676316525eb581c1a4cc83ca6097b/google-cloud-storage/lib/google/cloud/storage.rb#L589...L590 Therefore, I think that should use `credentials` in newly generated applications. Ref: https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/1802
* Avoid connecting to GCS during app bootGeorge Claghorn2017-11-231-7/+2
|
* Fix streaming downloads from S3/Azure StorageGeorge Claghorn2017-11-061-0/+10
| | | Closes #31073.
* Fix `test "signed URL generation"` failureRyuta Kamizono2017-09-301-1/+1
| | | | https://travis-ci.org/rails/rails/jobs/281044755#L5582-L5586
* Preview PDFs and videosGeorge Claghorn2017-09-285-7/+9
|
* Rename activestorage/test/service/configurations.yml to ↵George Claghorn2017-09-111-0/+0
| | | | activestorage/test/service/configurations.example.yml
* Fix order of Active Storage DiskService URL parametersKoichi ITO2017-08-261-1/+1
| | | | `content_type` parameter is before `disposition` parameter.
* Update regexGeorge Claghorn2017-08-201-1/+1
|
* Fix testsGeorge Claghorn2017-08-204-4/+4
|
* Run Active Storage service tests in CIGeorge Claghorn2017-08-141-0/+0
|
* Use frozen string literal in Active StorageKoichi ITO2017-08-127-1/+15
|
* Run Active Storage tests in CI (#30144)George Claghorn2017-08-101-7/+7
|
* Merge pull request #30135 from ffmike/azure-storage-fix-content-typeRafael Mendonça França2017-08-081-1/+8
|\ | | | | | | Support content_type in AzureStorageService#url
| * Support content_type in AzureStorageService#urlMike Gunderloy2017-08-081-0/+9
|/ | | | | | | | Add in the content_type option, which is defined as part of the generic ActiveStorage::Service class. Without this option, attempts to generate a URL for an attached file fail with "ArgumentError (unknown keyword: content_type)"
* Fix ruby warningsyuuji.yaginuma2017-08-052-3/+3
| | | | | | | | | | This fixes following warnings: ``` test/models/variant_test.rb:11: warning: ambiguous first argument; put parentheses or a space even after `/' operator lib/active_storage/attached/macros.rb:63: warning: instance variable @active_storage_attached_highlights not initialized lib/active_storage/attached/macros.rb:25: warning: instance variable @active_storage_attached_avatar not initialized ```
* Rename Azure to AzureStorage (#30057)Dino Maric2017-08-042-3/+3
|
* Fix tests for AWS buckets that include a . (#30059)Claudio B2017-08-041-2/+5
| | | | | | | | | If an AWS bucket name includes a `.` (e.g. `bucket.name`), then the canonical URL for an object will start with "https://s3.amazonaws.com/bucket.name/" and not with "https://bucket.name.s3.amazonaws.com/". The URL tests have now been separated into two separate asserts, to ensure that both the "s3.amazonaws.com" and the "bucket.name" components are included, but not specifically in that order.