workarea-core 3.4.15 → 3.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca7289a6b90924018068c1ab8f800600ed3c714d63a08cf95217224efc8f069c
4
- data.tar.gz: 23a4f30485bb3d230669213d5f7acd258a605865ea0f1a94da9ce4321d941224
3
+ metadata.gz: b344edcc1824bf26da32d7d12bc44579c7199f6aac8b0c7475657f3ee7aac70b
4
+ data.tar.gz: bfe91752df68f85cf594bf84dea1f9639020ae25f51c9b0506f638fed86e1f99
5
5
  SHA512:
6
- metadata.gz: ac75f323f12f1e4ebfdf965edc82524219daa425fcf3fe90999e2ffc173ff18ec987616df95527328f0d568a7471fe570053ce1c73c511c3bce08202a076c8ad
7
- data.tar.gz: f4dd55dd0a19e1d3db07e6e181c5a349ec19ee40b5c91026b1286bb09419ecb2d9c4e80d9169d0975cef1f5efc22d38f81db358d2f6cd15df5820baeb2ccfa49
6
+ metadata.gz: 74cc0ecbd7977a33d887c5f1519f4bab35608869f8f46e1a0c74967f42bc8194b738bfc25f43788592fbfb5457fccb3d3a1964f925febbb4aa3f20ad8e60d60d
7
+ data.tar.gz: 5126befad7fff351d48d575f80ce336121341301c1303f970934e21162a932bd46e1af55862d4669b17d6ef9ed07b443789fbdb094263e084f035f974b3650a7
@@ -2,15 +2,16 @@ module Workarea
2
2
  class DirectUpload
3
3
  class InvalidTypeError < RuntimeError; end
4
4
 
5
- def self.ensure_cors!
6
- url = "http#{Rails.application.config.force_ssl ? 's' : ''}://"
7
- url += Workarea.config.host
5
+ def self.ensure_cors!(request_url)
6
+ uri = URI.parse(request_url)
7
+ url = "#{uri.scheme}://#{uri.host}"
8
+ url += ":#{uri.port}" unless uri.port.in? [80, 443]
8
9
 
9
10
  Workarea.s3.put_bucket_cors(
10
11
  Configuration::S3.bucket,
11
12
  'CORSConfiguration' => [
12
13
  {
13
- 'ID' => "direct_upload_#{Workarea.config.host}",
14
+ 'ID' => "direct_upload_#{url}",
14
15
  'AllowedMethod' => 'PUT',
15
16
  'AllowedOrigin' => url,
16
17
  'AllowedHeader' => '*'
@@ -2,7 +2,7 @@ module Workarea
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 4
5
- PATCH = 15
5
+ PATCH = 16
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
@@ -46,6 +46,47 @@ module Workarea
46
46
  refute(direct_upload.valid?)
47
47
  end
48
48
 
49
+ def test_ensure_cors
50
+ Workarea.s3.expects(:put_bucket_cors).with(
51
+ Configuration::S3.bucket,
52
+ 'CORSConfiguration' => [
53
+ {
54
+ 'ID' => "direct_upload_http://test.host",
55
+ 'AllowedMethod' => 'PUT',
56
+ 'AllowedOrigin' => 'http://test.host',
57
+ 'AllowedHeader' => '*'
58
+ }
59
+ ]
60
+ ).returns(true)
61
+ Workarea.s3.expects(:put_bucket_cors).with(
62
+ Configuration::S3.bucket,
63
+ 'CORSConfiguration' => [
64
+ {
65
+ 'ID' => "direct_upload_http://localhost:3000",
66
+ 'AllowedMethod' => 'PUT',
67
+ 'AllowedOrigin' => 'http://localhost:3000',
68
+ 'AllowedHeader' => '*'
69
+ }
70
+ ]
71
+ ).returns(true)
72
+ Workarea.s3.expects(:put_bucket_cors).with(
73
+ Configuration::S3.bucket,
74
+ 'CORSConfiguration' => [
75
+ {
76
+ 'ID' => "direct_upload_https://example.com",
77
+ 'AllowedMethod' => 'PUT',
78
+ 'AllowedOrigin' => 'https://example.com',
79
+ 'AllowedHeader' => '*'
80
+ }
81
+ ]
82
+ ).returns(true)
83
+
84
+
85
+ assert(DirectUpload.ensure_cors!('http://test.host/admin/content_assets'))
86
+ assert(DirectUpload.ensure_cors!('http://localhost:3000/admin/content_assets'))
87
+ assert(DirectUpload.ensure_cors!('https://example.com/admin/direct_uploads'))
88
+ end
89
+
49
90
  private
50
91
 
51
92
  def upload_file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.15
4
+ version: 3.4.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-04 00:00:00.000000000 Z
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler