rhoconnect 5.5.18 → 7.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +18 -11
- data/Gemfile.lock +178 -100
- data/README.md +2 -0
- data/Rakefile +4 -3
- data/commands/dtach/dtach_install.rb +29 -24
- data/commands/rhoconnect/start.rb +5 -4
- data/generators/templates/application/rcgemfile +1 -1
- data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +1 -1
- data/lib/rhoconnect/ping/fcm.rb +74 -0
- data/lib/rhoconnect/ping.rb +1 -1
- data/lib/rhoconnect/store.rb +3 -3
- data/lib/rhoconnect/version.rb +1 -1
- data/rhoconnect.gemspec +15 -11
- data/spec/api/client/get_client_params_spec.rb +4 -0
- data/spec/apps/rhotestapp/models/ruby/sample_adapter.rb +1 -1
- data/spec/client_sync_spec.rb +7 -7
- data/spec/dynamic_adapter_spec.rb +13 -13
- data/spec/generator/generator_spec.rb +7 -7
- data/spec/jobs/ping_job_spec.rb +229 -105
- data/spec/perf/perf_spec_helper.rb +5 -5
- data/spec/ping/apple_spec.rb +24 -26
- data/spec/ping/fcm_spec.rb +116 -0
- data/spec/ping/gcm_spec.rb +27 -29
- data/spec/ping/rhoconnect_push_spec.rb +13 -13
- data/spec/rhoconnect_spec.rb +2 -2
- data/spec/server/cors_spec.rb +22 -22
- data/spec/server/server_spec.rb +308 -310
- data/spec/server/stats_spec.rb +7 -7
- data/spec/server/x_domain_session_wrapper_spec.rb +40 -40
- data/spec/source_adapter_spec.rb +2 -2
- data/spec/source_sync_spec.rb +4 -4
- data/spec/spec_helper.rb +8 -8
- data/spec/stats/record_spec.rb +7 -7
- data/spec/store_orm_spec.rb +97 -94
- data/spec/store_spec.rb +23 -23
- data/spec/user_spec.rb +3 -3
- metadata +98 -27
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Ping Android FCM" do
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
allow( Google::Auth).to receive(:get_application_default)
|
8
|
+
@params = {"device_pin" => @c.device_pin,
|
9
|
+
"sources" => [@s.name], "message" => 'hello world',
|
10
|
+
"vibrate" => '5', "badge" => '5', "sound" => 'hello.mp3'}
|
11
|
+
@response = double('response')
|
12
|
+
Rhoconnect.settings[:fcm_project_id] = 'valid_project_id'
|
13
|
+
Rhoconnect.settings[:package_name] = 'valid_package_name'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should ping fcm successfully" do
|
17
|
+
stub_request(:post, "https://fcm.googleapis.com/v1/projects/valid_project_id/messages:send").with { |request|
|
18
|
+
hash = JSON.parse request.body
|
19
|
+
valid = hash["message"]["token"] == "abcd"
|
20
|
+
valid = valid && hash["message"]["topic"] == nil
|
21
|
+
valid = valid && hash["message"]["android"]["restricted_package_name"] == "valid_package_name"
|
22
|
+
valid
|
23
|
+
}
|
24
|
+
Fcm.ping(@params)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should raise error on missing fcm_project_id setting" do
|
28
|
+
key = Rhoconnect.settings[:fcm_project_id.dup]
|
29
|
+
Rhoconnect.settings[:fcm_project_id] = nil
|
30
|
+
expect(lambda { Fcm.ping(@params) }).to raise_error(Fcm::InvalidProjectId, 'Missing `:fcm_project_id:` option in settings/settings.yml')
|
31
|
+
Rhoconnect.settings[:fcm_project_id] = key
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise error on missing package_name setting" do
|
35
|
+
key = Rhoconnect.settings[:package_name.dup]
|
36
|
+
Rhoconnect.settings[:package_name] = nil
|
37
|
+
expect(lambda { Fcm.ping(@params) }).to raise_error(Fcm::InvalidPackageName, 'Missing `:package_name:` option in settings/settings.yml')
|
38
|
+
Rhoconnect.settings[:package_name] = key
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should ping fcm with 503 connection error" do
|
42
|
+
stub_request(:post, "https://fcm.googleapis.com/v1/projects/valid_project_id/messages:send").to_raise(RestClient::Exception.new(nil,503))
|
43
|
+
expect(lambda { Fcm.ping(@params) }).to raise_error(RestClient::Exception)
|
44
|
+
end
|
45
|
+
|
46
|
+
xit "should ping fcm with 200 error message" do
|
47
|
+
allow( Google::Auth).to receive(:get_application_default)
|
48
|
+
|
49
|
+
error = 'error:DeviceMessageRateExceeded'
|
50
|
+
allow(@response).to receive(:code).and_return(200)
|
51
|
+
allow(@response).to receive(:body).and_return(error)
|
52
|
+
allow(@response).to receive(:headers).and_return(nil)
|
53
|
+
stub_request(:post, "https://fcm.googleapis.com/v1/projects/valid_project_id/messages:send").to_raise(RestClient::Exception.new(@response,200))
|
54
|
+
expect(lambda { Fcm.ping(@params) }).to raise_error(Fcm::FCMPingError, "FCM ping error: DeviceMessageRateExceeded")
|
55
|
+
end
|
56
|
+
|
57
|
+
xit "should fail to ping with bad authentication" do
|
58
|
+
error = 'Error=BadAuthentication'
|
59
|
+
allow(@response).to receive(:code).and_return(403)
|
60
|
+
allow(@response).to receive(:body).and_return(error)
|
61
|
+
allow(@response).to receive(:headers).and_return({})
|
62
|
+
setup_post_yield(@response)
|
63
|
+
expect(Fcm).to receive(:log).twice
|
64
|
+
expect(lambda { Fcm.ping(@params) }).to raise_error(
|
65
|
+
Fcm::InvalidProjectId, "Invalid FCM project id. Obtain new api key from FCM service."
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
xit "should ping fcm with 401 error message" do
|
70
|
+
allow(@response).to receive(:code).and_return(401)
|
71
|
+
allow(@response).to receive(:body).and_return('')
|
72
|
+
setup_post_yield(@response)
|
73
|
+
expect(Fcm).to receive(:log).twice
|
74
|
+
expect(lambda { Fcm.ping(@params) }).to raise_error(
|
75
|
+
Fcm::InvalidProjectId, "Invalid FCM project id. Obtain new api key from FCM service."
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should compute fcm_message" do
|
80
|
+
expect(Google::Apis::Messages::Message).to receive(:new) do |options|
|
81
|
+
expect(options[:token]).to eq(@c.device_pin)
|
82
|
+
expect(options[:android]["priority"]).to eq("high")
|
83
|
+
expect(options[:android]["restricted_package_name"]).to eq(Rhoconnect.settings[:package_name])
|
84
|
+
expect(options[:android]["data"]["do_sync"]).to eq(@s.name)
|
85
|
+
expect(options[:android]["data"]["alert"]).to eq("hello world")
|
86
|
+
expect(options[:android]["data"]["vibrate"]).to eq("5")
|
87
|
+
expect(options[:android]["data"]["sound"]).to eq("hello.mp3")
|
88
|
+
expect(options[:android]["notification"]["body"]).to eq("hello world")
|
89
|
+
end
|
90
|
+
|
91
|
+
Fcm.fcm_message(Rhoconnect.settings[:package_name], @params)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should trim empty or nil params from fcm_message" do
|
95
|
+
expect(Google::Apis::Messages::Message).to receive(:new) do |options|
|
96
|
+
expect(options[:token]).to eq(@c.device_pin)
|
97
|
+
expect(options[:android]["priority"]).to eq("high")
|
98
|
+
expect(options[:android]["restricted_package_name"]).to eq(Rhoconnect.settings[:package_name])
|
99
|
+
expect(options[:android]["data"]["do_sync"]).to eq('')
|
100
|
+
expect(options[:android]["data"]["alert"]).to eq(nil)
|
101
|
+
expect(options[:android]["data"]["vibrate"]).to eq("5")
|
102
|
+
expect(options[:android]["data"]["sound"]).to eq("hello.mp3")
|
103
|
+
expect(options[:android]["notification"]["body"]).to eq(nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
params = {
|
107
|
+
"device_pin" => @c.device_pin,
|
108
|
+
"sources" => [],
|
109
|
+
"message" => '',
|
110
|
+
"vibrate" => '5',
|
111
|
+
"sound" => 'hello.mp3'
|
112
|
+
}
|
113
|
+
|
114
|
+
Fcm.fcm_message(Rhoconnect.settings[:package_name], params)
|
115
|
+
end
|
116
|
+
end
|
data/spec/ping/gcm_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','spec_helper')
|
2
2
|
|
3
|
-
|
3
|
+
xdescribe "Ping Android GCM" do
|
4
4
|
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
5
5
|
|
6
6
|
before(:each) do
|
@@ -13,59 +13,57 @@ describe "Ping Android GCM" do
|
|
13
13
|
|
14
14
|
it "should ping gcm successfully" do
|
15
15
|
result = 'id=0:34234234134254%abc123\n'
|
16
|
-
@response.
|
17
|
-
@response.
|
18
|
-
@response.
|
19
|
-
@response.
|
16
|
+
allow(@response).to receive(:code).and_return(200)
|
17
|
+
allow(@response).to receive(:body).and_return(result)
|
18
|
+
allow(@response).to receive(:headers).and_return({})
|
19
|
+
allow(@response).to receive(:return!).and_return(@response)
|
20
20
|
setup_post_yield(@response)
|
21
|
-
Gcm.ping(@params).body.
|
21
|
+
expect(Gcm.ping(@params).body).to eq(result)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should raise error on missing gcm_api_key setting" do
|
25
25
|
key = Rhoconnect.settings[:gcm_api_key].dup
|
26
26
|
Rhoconnect.settings[:gcm_api_key] = nil
|
27
|
-
lambda { Gcm.ping(@params) }.
|
28
|
-
Gcm::InvalidApiKey, 'Missing `:gcm_api_key:` option in settings/settings.yml'
|
29
|
-
)
|
27
|
+
expect(lambda { Gcm.ping(@params) }).to raise_error(Gcm::InvalidApiKey, 'Missing `:gcm_api_key:` option in settings/settings.yml')
|
30
28
|
Rhoconnect.settings[:gcm_api_key] = key
|
31
29
|
end
|
32
30
|
|
33
31
|
it "should ping gcm with 503 connection error" do
|
34
32
|
error = 'Connection refused'
|
35
|
-
@response.
|
36
|
-
RestClient.
|
37
|
-
Gcm.
|
38
|
-
lambda { Gcm.ping(@params) }.
|
33
|
+
allow(@response).to receive(:body).and_return(error)
|
34
|
+
allow(RestClient).to receive(:post).and_raise(RestClient::Exception.new(@response,503))
|
35
|
+
allow(Gcm).to receive(:log).twice
|
36
|
+
expect(lambda { Gcm.ping(@params) }).to raise_error(RestClient::Exception)
|
39
37
|
end
|
40
38
|
|
41
39
|
it "should ping gcm with 200 error message" do
|
42
40
|
error = 'Error=QuotaExceeded'
|
43
|
-
@response.
|
44
|
-
@response.
|
45
|
-
@response.
|
41
|
+
allow(@response).to receive(:code).and_return(200)
|
42
|
+
allow(@response).to receive(:body).and_return(error)
|
43
|
+
allow(@response).to receive(:headers).and_return(nil)
|
46
44
|
setup_post_yield(@response)
|
47
|
-
Gcm.
|
48
|
-
lambda { Gcm.ping(@params) }.
|
45
|
+
expect(Gcm).to receive(:log).twice
|
46
|
+
expect(lambda { Gcm.ping(@params) }).to raise_error(Gcm::GCMPingError, "GCM ping error: QuotaExceeded")
|
49
47
|
end
|
50
48
|
|
51
49
|
it "should fail to ping with bad authentication" do
|
52
50
|
error = 'Error=BadAuthentication'
|
53
|
-
@response.
|
54
|
-
@response.
|
55
|
-
@response.
|
51
|
+
allow(@response).to receive(:code).and_return(403)
|
52
|
+
allow(@response).to receive(:body).and_return(error)
|
53
|
+
allow(@response).to receive(:headers).and_return({})
|
56
54
|
setup_post_yield(@response)
|
57
|
-
Gcm.
|
58
|
-
lambda { Gcm.ping(@params) }.
|
55
|
+
expect(Gcm).to receive(:log).twice
|
56
|
+
expect(lambda { Gcm.ping(@params) }).to raise_error(
|
59
57
|
Gcm::InvalidApiKey, "Invalid GCM api key. Obtain new api key from GCM service."
|
60
58
|
)
|
61
59
|
end
|
62
60
|
|
63
61
|
it "should ping gcm with 401 error message" do
|
64
|
-
@response.
|
65
|
-
@response.
|
62
|
+
allow(@response).to receive(:code).and_return(401)
|
63
|
+
allow(@response).to receive(:body).and_return('')
|
66
64
|
setup_post_yield(@response)
|
67
|
-
Gcm.
|
68
|
-
lambda { Gcm.ping(@params) }.
|
65
|
+
expect(Gcm).to receive(:log).twice
|
66
|
+
expect(lambda { Gcm.ping(@params) }).to raise_error(
|
69
67
|
Gcm::InvalidApiKey, "Invalid GCM api key. Obtain new api key from GCM service."
|
70
68
|
)
|
71
69
|
end
|
@@ -83,7 +81,7 @@ describe "Ping Android GCM" do
|
|
83
81
|
}
|
84
82
|
actual = Gcm.gcm_message(@params)
|
85
83
|
actual['collapse_key'] = "RAND_KEY" unless actual['collapse_key'].nil?
|
86
|
-
actual.
|
84
|
+
expect(actual).to eq(expected)
|
87
85
|
end
|
88
86
|
|
89
87
|
it "should trim empty or nil params from gcm_message" do
|
@@ -93,6 +91,6 @@ describe "Ping Android GCM" do
|
|
93
91
|
"sources" => [], "message" => '', "vibrate" => '5', "sound" => 'hello.mp3'}
|
94
92
|
actual = Gcm.gcm_message(params)
|
95
93
|
actual['collapse_key'] = "RAND_KEY" unless actual['collapse_key'].nil?
|
96
|
-
actual.
|
94
|
+
expect(actual).to eq(expected)
|
97
95
|
end
|
98
96
|
end
|
@@ -13,18 +13,18 @@ describe "Ping using RhoConnect push" do
|
|
13
13
|
|
14
14
|
it "should ping rhoconnect push successfully" do
|
15
15
|
result = ''
|
16
|
-
@response.
|
17
|
-
@response.
|
18
|
-
@response.
|
19
|
-
RestClient.
|
16
|
+
allow(@response).to receive(:code).and_return(204)
|
17
|
+
allow(@response).to receive(:body).and_return(result)
|
18
|
+
allow(@response).to receive(:return!).and_return(@response)
|
19
|
+
allow(RestClient).to receive(:post).and_return(@response)
|
20
20
|
res = RhoconnectPush.ping(@params)
|
21
|
-
res.body.
|
22
|
-
res.code.
|
21
|
+
expect(res.body).to eq(result)
|
22
|
+
expect(res.code).to eq(204)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should ping rhoconnect push with missing push_server property" do
|
26
|
-
RhoconnectPush.
|
27
|
-
lambda { RhoconnectPush.ping(@params) }.
|
26
|
+
allow(RhoconnectPush).to receive(:get_config).and_return({:test => {}})
|
27
|
+
expect(lambda { RhoconnectPush.ping(@params) }).to raise_error(
|
28
28
|
RhoconnectPush::InvalidPushServer, "Missing or invalid `:push_server` in settings/settings.yml."
|
29
29
|
)
|
30
30
|
end
|
@@ -32,11 +32,11 @@ describe "Ping using RhoConnect push" do
|
|
32
32
|
|
33
33
|
it "should ping rhoconnect push with 400 response" do
|
34
34
|
result = ''
|
35
|
-
@response.
|
36
|
-
@response.
|
37
|
-
@response.
|
35
|
+
allow(@response).to receive(:code).and_return(400)
|
36
|
+
allow(@response).to receive(:body).and_return(result)
|
37
|
+
allow(@response).to receive(:return!).and_return(@response)
|
38
38
|
setup_post_yield(@response)
|
39
|
-
lambda { RhoconnectPush.ping(@params) }.
|
39
|
+
expect(lambda { RhoconnectPush.ping(@params) }).to raise_error(
|
40
40
|
RhoconnectPush::InvalidPushRequest, "Invalid push request."
|
41
41
|
)
|
42
42
|
end
|
@@ -52,6 +52,6 @@ describe "Ping using RhoConnect push" do
|
|
52
52
|
}
|
53
53
|
}
|
54
54
|
actual = RhoconnectPush.push_message(@params)
|
55
|
-
JSON.parse(actual).
|
55
|
+
expect(JSON.parse(actual)).to eq(expected)
|
56
56
|
end
|
57
57
|
end
|
data/spec/rhoconnect_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe "Rhoconnect" do
|
|
22
22
|
Rhoconnect.environment.should == :test
|
23
23
|
Rhoconnect.stats.should == false
|
24
24
|
Rhoconnect.cookie_expire.should == 9999999
|
25
|
-
App.is_exist?(test_app_name).should
|
25
|
+
App.is_exist?(test_app_name).should be true
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should bootstrap Rhoconnect with RHO_ENV provided" do
|
@@ -69,4 +69,4 @@ describe "Rhoconnect" do
|
|
69
69
|
s = Source.load('SampleAdapter',{:app_id => test_app_name,:user_id => '*'})
|
70
70
|
s.has_many.should == "FixedSchemaAdapter,brand"
|
71
71
|
end
|
72
|
-
end
|
72
|
+
end
|
data/spec/server/cors_spec.rb
CHANGED
@@ -53,9 +53,9 @@ describe "CORS middleware" do
|
|
53
53
|
allow.resource nil, :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
54
54
|
rescue Exception => e
|
55
55
|
exception_happens = true
|
56
|
-
e.is_a?(TypeError).
|
56
|
+
expect(e.is_a?(TypeError)).to be true
|
57
57
|
end
|
58
|
-
exception_happens.
|
58
|
+
expect(exception_happens).to be true
|
59
59
|
|
60
60
|
allow.resource "/*", :headers => :any, :methods => [:get, :post, :put, :delete], :credentials => true
|
61
61
|
end
|
@@ -68,8 +68,8 @@ describe "CORS middleware" do
|
|
68
68
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
69
69
|
}
|
70
70
|
status, headers, body = mv.call(env)
|
71
|
-
200.
|
72
|
-
headers['Access-Control-Allow-Origin'].
|
71
|
+
expect(200).to eq(status)
|
72
|
+
expect(headers['Access-Control-Allow-Origin']).to eq('*')
|
73
73
|
end
|
74
74
|
|
75
75
|
it "preflight check should disable unknown origins" do
|
@@ -80,8 +80,8 @@ describe "CORS middleware" do
|
|
80
80
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
81
81
|
}
|
82
82
|
status, headers, body = @middleware.call(env)
|
83
|
-
200.
|
84
|
-
headers['Access-Control-Allow-Origin'].
|
83
|
+
expect(200).to eq(status)
|
84
|
+
expect(headers['Access-Control-Allow-Origin']).not_to eq('wrong_origin')
|
85
85
|
end
|
86
86
|
|
87
87
|
it "preflight check should allow known origins" do
|
@@ -92,8 +92,8 @@ describe "CORS middleware" do
|
|
92
92
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
93
93
|
}
|
94
94
|
status, headers, body = @middleware.call(env)
|
95
|
-
200.
|
96
|
-
headers['Access-Control-Allow-Origin'].
|
95
|
+
expect(200).to eq(status)
|
96
|
+
expect(headers['Access-Control-Allow-Origin']).to eq('allowed_origin')
|
97
97
|
end
|
98
98
|
|
99
99
|
it "able to use fallback X-ORIGIN request header if ORIGIN header is undefined" do
|
@@ -104,8 +104,8 @@ describe "CORS middleware" do
|
|
104
104
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
105
105
|
}
|
106
106
|
status, headers, body = @middleware.call(env)
|
107
|
-
200.
|
108
|
-
headers['Access-Control-Allow-Origin'].
|
107
|
+
expect(200).to eq(status)
|
108
|
+
expect(headers['Access-Control-Allow-Origin']).to eq('allowed_origin')
|
109
109
|
end
|
110
110
|
|
111
111
|
it "preflight check treats empty 'null' origin as 'file://' one" do
|
@@ -116,8 +116,8 @@ describe "CORS middleware" do
|
|
116
116
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
117
117
|
}
|
118
118
|
status, headers, body = @middleware.call(env)
|
119
|
-
200.
|
120
|
-
headers['Access-Control-Allow-Origin'].
|
119
|
+
expect(200).to eq(status)
|
120
|
+
expect(headers['Access-Control-Allow-Origin']).to eq('file://')
|
121
121
|
end
|
122
122
|
|
123
123
|
it "preflight check should enable allowed request headers" do
|
@@ -129,9 +129,9 @@ describe "CORS middleware" do
|
|
129
129
|
'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'allowed_header'
|
130
130
|
}
|
131
131
|
status, headers, body = @middleware.call(env)
|
132
|
-
200.
|
132
|
+
expect(200).to eq(status)
|
133
133
|
#headers['Access-Control-Allow-Origin'].should == 'allowed_origin'
|
134
|
-
headers['Access-Control-Allow-Headers'].
|
134
|
+
expect(headers['Access-Control-Allow-Headers']).to eq('allowed_header')
|
135
135
|
end
|
136
136
|
|
137
137
|
it "preflight check should disable not allowed request headers" do
|
@@ -143,9 +143,9 @@ describe "CORS middleware" do
|
|
143
143
|
'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'not_allowed_header'
|
144
144
|
}
|
145
145
|
status, headers, body = @middleware.call(env)
|
146
|
-
200.
|
146
|
+
expect(200).to eq(status)
|
147
147
|
#headers['Access-Control-Allow-Origin'].should == 'allowed_origin'
|
148
|
-
headers['Access-Control-Allow-Headers'].
|
148
|
+
expect(headers['Access-Control-Allow-Headers']).not_to eq('not_allowed_header')
|
149
149
|
end
|
150
150
|
|
151
151
|
it "preflight check should allow any request headers if configured so" do
|
@@ -157,9 +157,9 @@ describe "CORS middleware" do
|
|
157
157
|
'HTTP_ACCESS_CONTROL_REQUEST_HEADERS' => 'not_allowed_header'
|
158
158
|
}
|
159
159
|
status, headers, body = @middleware.call(env)
|
160
|
-
200.
|
160
|
+
expect(200).to eq(status)
|
161
161
|
#headers['Access-Control-Allow-Origin'].should == 'allowed_origin'
|
162
|
-
headers['Access-Control-Allow-Headers'].
|
162
|
+
expect(headers['Access-Control-Allow-Headers']).to eq('not_allowed_header')
|
163
163
|
end
|
164
164
|
|
165
165
|
|
@@ -171,8 +171,8 @@ describe "CORS middleware" do
|
|
171
171
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
172
172
|
}
|
173
173
|
status, headers, body = @middleware.call(env)
|
174
|
-
200.
|
175
|
-
headers['Access-Control-Expose-Headers'].
|
174
|
+
expect(200).to eq(status)
|
175
|
+
expect(headers['Access-Control-Expose-Headers']).to eq('Content-Length')
|
176
176
|
end
|
177
177
|
|
178
178
|
it "no response headers should be exposed by default" do
|
@@ -183,8 +183,8 @@ describe "CORS middleware" do
|
|
183
183
|
'HTTP_ACCESS_CONTROL_REQUEST_METHOD' => 'POST'
|
184
184
|
}
|
185
185
|
status, headers, body = @middleware.call(env)
|
186
|
-
200.
|
187
|
-
headers['Access-Control-Expose-Headers'].
|
186
|
+
expect(200).to eq(status)
|
187
|
+
expect(headers['Access-Control-Expose-Headers']).to eq('')
|
188
188
|
end
|
189
189
|
|
190
190
|
|