ably-rest 1.1.4.rc → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/MAINTAINERS.md +1 -0
  3. data/ably-rest.gemspec +6 -6
  4. data/lib/submodules/ably-ruby/.github/workflows/check.yml +27 -0
  5. data/lib/submodules/ably-ruby/CHANGELOG.md +35 -0
  6. data/lib/submodules/ably-ruby/COPYRIGHT +1 -0
  7. data/lib/submodules/ably-ruby/LICENSE +173 -10
  8. data/lib/submodules/ably-ruby/MAINTAINERS.md +1 -0
  9. data/lib/submodules/ably-ruby/README.md +2 -10
  10. data/lib/submodules/ably-ruby/SPEC.md +944 -914
  11. data/lib/submodules/ably-ruby/ably.gemspec +4 -4
  12. data/lib/submodules/ably-ruby/lib/ably/auth.rb +12 -2
  13. data/lib/submodules/ably-ruby/lib/ably/realtime/channel.rb +7 -11
  14. data/lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_manager.rb +2 -2
  15. data/lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_properties.rb +24 -0
  16. data/lib/submodules/ably-ruby/lib/ably/realtime/client.rb +8 -0
  17. data/lib/submodules/ably-ruby/lib/ably/realtime/connection.rb +5 -4
  18. data/lib/submodules/ably-ruby/lib/ably/realtime/connection/websocket_transport.rb +67 -1
  19. data/lib/submodules/ably-ruby/lib/ably/realtime/presence.rb +0 -14
  20. data/lib/submodules/ably-ruby/lib/ably/rest/client.rb +9 -15
  21. data/lib/submodules/ably-ruby/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb +1 -4
  22. data/lib/submodules/ably-ruby/lib/ably/version.rb +1 -1
  23. data/lib/submodules/ably-ruby/spec/acceptance/realtime/channel_spec.rb +10 -0
  24. data/lib/submodules/ably-ruby/spec/acceptance/realtime/client_spec.rb +72 -16
  25. data/lib/submodules/ably-ruby/spec/acceptance/realtime/connection_spec.rb +28 -12
  26. data/lib/submodules/ably-ruby/spec/acceptance/realtime/presence_history_spec.rb +0 -58
  27. data/lib/submodules/ably-ruby/spec/acceptance/realtime/presence_spec.rb +54 -0
  28. data/lib/submodules/ably-ruby/spec/acceptance/realtime/push_admin_spec.rb +3 -19
  29. data/lib/submodules/ably-ruby/spec/acceptance/rest/auth_spec.rb +6 -75
  30. data/lib/submodules/ably-ruby/spec/acceptance/rest/client_spec.rb +72 -12
  31. data/lib/submodules/ably-ruby/spec/acceptance/rest/push_admin_spec.rb +3 -19
  32. data/lib/submodules/ably-ruby/spec/shared/client_initializer_behaviour.rb +0 -8
  33. data/lib/submodules/ably-ruby/spec/spec_helper.rb +1 -0
  34. data/lib/submodules/ably-ruby/spec/support/serialization_helper.rb +21 -0
  35. data/lib/submodules/ably-ruby/spec/unit/realtime/client_spec.rb +19 -6
  36. metadata +30 -25
  37. data/lib/submodules/ably-ruby/.travis.yml +0 -18
@@ -12,7 +12,7 @@ describe Ably::Rest::Client do
12
12
  http_defaults = Ably::Rest::Client::HTTP_DEFAULTS
13
13
 
14
14
  def encode64(text)
15
- Base64.encode64(text).gsub("\n", '')
15
+ Base64.urlsafe_encode64(text)
16
16
  end
17
17
 
18
18
  context '#initialize' do
@@ -56,14 +56,6 @@ describe Ably::Rest::Client do
56
56
  end
57
57
  end
58
58
 
59
- context 'with a :client_id configured' do
60
- let(:client) { Ably::Rest::Client.new(client_options.merge(key: api_key, client_id: random_str)) }
61
-
62
- it 'uses token authentication' do
63
- expect(client.auth).to be_using_token_auth
64
- end
65
- end
66
-
67
59
  context 'with a non string :client_id' do
68
60
  let(:client) { Ably::Rest::Client.new(client_options.merge(key: api_key, client_id: 1)) }
69
61
 
@@ -144,11 +136,12 @@ describe Ably::Rest::Client do
144
136
  let(:history_querystring) { history_params.map { |k, v| "#{k}=#{v}" }.join("&") }
145
137
 
146
138
  context 'with basic auth', webmock: true do
147
- let(:client_options) { default_options.merge(key: api_key) }
139
+ let(:client_options) { default_options.merge(key: api_key, client_id: client_id) }
148
140
 
149
141
  let!(:get_message_history_stub) do
150
- stub_request(:get, "https://#{environment}-#{Ably::Rest::Client::DOMAIN}/channels/#{channel_name}/messages?#{history_querystring}").
151
- to_return(body: [], headers: { 'Content-Type' => 'application/json' })
142
+ stub_request(:get, "https://#{environment}-#{Ably::Rest::Client::DOMAIN}/channels/#{channel_name}/messages?#{history_querystring}")
143
+ .with(headers: { 'X-Ably-ClientId' => encode64(client_id) })
144
+ .to_return(body: [], headers: { 'Content-Type' => 'application/json' })
152
145
  end
153
146
 
154
147
  it 'sends the API key in authentication part of the secure URL (the Authorization: Basic header is not used with the Faraday HTTP library by default)' do
@@ -1091,6 +1084,8 @@ describe Ably::Rest::Client do
1091
1084
 
1092
1085
  context '#request (#RSC19*)' do
1093
1086
  let(:client_options) { default_options.merge(key: api_key) }
1087
+ let(:device_id) { random_str }
1088
+ let(:endpoint) { client.endpoint }
1094
1089
 
1095
1090
  context 'get' do
1096
1091
  it 'returns an HttpPaginatedResponse object' do
@@ -1130,6 +1125,71 @@ describe Ably::Rest::Client do
1130
1125
  end
1131
1126
  end
1132
1127
  end
1128
+
1129
+ context 'post', :webmock do
1130
+ before do
1131
+ stub_request(:delete, "#{endpoint}/push/deviceRegistrations/#{device_id}/resetUpdateToken").
1132
+ to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
1133
+ end
1134
+
1135
+ it 'supports post' do
1136
+ response = client.request(:delete, "push/deviceRegistrations/#{device_id}/resetUpdateToken")
1137
+
1138
+ expect(response).to be_success
1139
+ end
1140
+ end
1141
+
1142
+ context 'delete', :webmock do
1143
+ before do
1144
+ stub_request(:delete, "#{endpoint}/push/channelSubscriptions?deviceId=#{device_id}").
1145
+ to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
1146
+ end
1147
+
1148
+ it 'supports delete' do
1149
+ response = client.request(:delete, "/push/channelSubscriptions", { deviceId: device_id})
1150
+
1151
+ expect(response).to be_success
1152
+ end
1153
+ end
1154
+
1155
+ context 'patch', :webmock do
1156
+ let(:body_params) { { 'metadata' => { 'key' => 'value' } } }
1157
+
1158
+ before do
1159
+ stub_request(:patch, "#{endpoint}/push/deviceRegistrations/#{device_id}")
1160
+ .with(body: serialize_body(body_params, protocol))
1161
+ .to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
1162
+ end
1163
+
1164
+ it 'supports patch' do
1165
+ response = client.request(:patch, "/push/deviceRegistrations/#{device_id}", {}, body_params)
1166
+
1167
+ expect(response).to be_success
1168
+ end
1169
+ end
1170
+
1171
+ context 'put', :webmock do
1172
+ let(:body_params) do
1173
+ {
1174
+ 'id' => random_str,
1175
+ 'platform' => 'ios',
1176
+ 'formFactor' => 'phone',
1177
+ 'metadata' => { 'key' => 'value' }
1178
+ }
1179
+ end
1180
+
1181
+ before do
1182
+ stub_request(:put, "#{endpoint}/push/deviceRegistrations/#{device_id}")
1183
+ .with(body: serialize_body(body_params, protocol))
1184
+ .to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
1185
+ end
1186
+
1187
+ it 'supports put' do
1188
+ response = client.request(:put, "/push/deviceRegistrations/#{device_id}", {}, body_params)
1189
+
1190
+ expect(response).to be_success
1191
+ end
1192
+ end
1133
1193
  end
1134
1194
 
1135
1195
  context 'request_id generation' do
@@ -89,31 +89,15 @@ describe Ably::Rest::Push::Admin do
89
89
  end
90
90
  end
91
91
 
92
- def request_body(request, protocol)
93
- if protocol == :msgpack
94
- MessagePack.unpack(request.body)
95
- else
96
- JSON.parse(request.body)
97
- end
98
- end
99
-
100
- def serialize(object, protocol)
101
- if protocol == :msgpack
102
- MessagePack.pack(object)
103
- else
104
- JSON.dump(object)
105
- end
106
- end
107
-
108
92
  let!(:publish_stub) do
109
93
  stub_request(:post, "#{client.endpoint}/push/publish").
110
94
  with do |request|
111
- expect(request_body(request, protocol)['recipient']['camelCase']['secondLevelCamelCase']).to eql('val')
112
- expect(request_body(request, protocol)['recipient']).to_not have_key('camel_case')
95
+ expect(deserialize_body(request.body, protocol)['recipient']['camelCase']['secondLevelCamelCase']).to eql('val')
96
+ expect(deserialize_body(request.body, protocol)['recipient']).to_not have_key('camel_case')
113
97
  true
114
98
  end.to_return(
115
99
  :status => 201,
116
- :body => serialize({}, protocol),
100
+ :body => serialize_body({}, protocol),
117
101
  :headers => { 'Content-Type' => content_type }
118
102
  )
119
103
  end
@@ -69,14 +69,6 @@ shared_examples 'a client initializer' do
69
69
  expect { subject }.to raise_error(ArgumentError, /key and key_name or key_secret are mutually exclusive/)
70
70
  end
71
71
  end
72
-
73
- context 'client_id as only option' do
74
- let(:client_options) { { client_id: 'valid' } }
75
-
76
- it 'requires a valid key' do
77
- expect { subject }.to raise_error(ArgumentError, /client_id cannot be provided without a complete API key or means to authenticate/)
78
- end
79
- end
80
72
  end
81
73
 
82
74
  context 'with valid arguments' do
@@ -19,6 +19,7 @@ require 'support/event_emitter_helper'
19
19
  require 'support/private_api_formatter'
20
20
  require 'support/protocol_helper'
21
21
  require 'support/random_helper'
22
+ require 'support/serialization_helper'
22
23
  require 'support/test_logger_helper'
23
24
 
24
25
  require 'rspec_config'
@@ -0,0 +1,21 @@
1
+ module SerializationHelper
2
+ def serialize_body(object, protocol)
3
+ if protocol == :msgpack
4
+ MessagePack.pack(object)
5
+ else
6
+ JSON.dump(object)
7
+ end
8
+ end
9
+
10
+ def deserialize_body(object, protocol)
11
+ if protocol == :msgpack
12
+ MessagePack.unpack(object)
13
+ else
14
+ JSON.parse(object)
15
+ end
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.include self
20
+ end
21
+ end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  require 'shared/client_initializer_behaviour'
4
4
 
5
5
  describe Ably::Realtime::Client do
6
- subject do
6
+ subject(:realtime_client) do
7
7
  Ably::Realtime::Client.new(client_options)
8
8
  end
9
9
 
@@ -15,28 +15,41 @@ describe Ably::Realtime::Client do
15
15
  it 'passes on the options to the initializer' do
16
16
  rest_client = instance_double('Ably::Rest::Client', auth: instance_double('Ably::Auth'), options: client_options, environment: 'production', use_tls?: true, custom_tls_port: nil)
17
17
  expect(Ably::Rest::Client).to receive(:new).with(hash_including(client_options)).and_return(rest_client)
18
- subject
18
+ realtime_client
19
19
  end
20
20
 
21
21
  context 'for attribute' do
22
22
  [:environment, :use_tls?, :log_level, :custom_host].each do |attribute|
23
23
  specify "##{attribute}" do
24
- expect(subject.rest_client).to receive(attribute)
25
- subject.public_send attribute
24
+ expect(realtime_client.rest_client).to receive(attribute)
25
+ realtime_client.public_send attribute
26
26
  end
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
+ context 'when :transport_params option is passed' do
32
+ let(:expected_transport_params) do
33
+ { 'heartbeats' => 'true', 'v' => '1.0', 'extra_param' => 'extra_param' }
34
+ end
35
+ let(:client_options) do
36
+ { key: 'appid.keyuid:keysecret', transport_params: { heartbeats: true, v: 1.0, extra_param: 'extra_param'} }
37
+ end
38
+
39
+ it 'converts options to strings' do
40
+ expect(realtime_client.transport_params).to eq(expected_transport_params)
41
+ end
42
+ end
43
+
31
44
  context 'push' do
32
45
  let(:client_options) { { key: 'appid.keyuid:keysecret' } }
33
46
 
34
47
  specify '#device is not supported and raises an exception' do
35
- expect { subject.device }.to raise_error Ably::Exceptions::PushNotificationsNotSupported
48
+ expect { realtime_client.device }.to raise_error Ably::Exceptions::PushNotificationsNotSupported
36
49
  end
37
50
 
38
51
  specify '#push returns a Push object' do
39
- expect(subject.push).to be_a(Ably::Realtime::Push)
52
+ expect(realtime_client.push).to be_a(Ably::Realtime::Push)
40
53
  end
41
54
  end
42
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ably-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4.rc
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew O'Riordan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '0.12'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '0.12'
27
27
  - !ruby/object:Gem::Dependency
28
- name: typhoeus
28
+ name: excon
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.4'
33
+ version: '0.55'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.4'
40
+ version: '0.55'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +81,33 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.0.0
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
84
+ name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '13.0'
89
+ version: 1.3.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '13.0'
96
+ version: 1.3.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: bundler
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.2.1
103
+ version: '11.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.2.1
110
+ version: '11.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: redcarpet
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,28 +128,28 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.10.0
131
+ version: 3.2.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.10.0
138
+ version: 3.2.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec-retry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0.6'
145
+ version: '0.4'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.6'
152
+ version: '0.4'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -235,6 +235,7 @@ files:
235
235
  - CHANGELOG.md
236
236
  - Gemfile
237
237
  - LICENSE
238
+ - MAINTAINERS.md
238
239
  - README.md
239
240
  - Rakefile
240
241
  - SPEC.md
@@ -242,13 +243,15 @@ files:
242
243
  - lib/ably-rest.rb
243
244
  - lib/ably-rest/modules/eventmachine_deferrable.rb
244
245
  - lib/submodules/ably-ruby/.editorconfig
246
+ - lib/submodules/ably-ruby/.github/workflows/check.yml
245
247
  - lib/submodules/ably-ruby/.gitignore
246
248
  - lib/submodules/ably-ruby/.gitmodules
247
249
  - lib/submodules/ably-ruby/.rspec
248
- - lib/submodules/ably-ruby/.travis.yml
249
250
  - lib/submodules/ably-ruby/CHANGELOG.md
251
+ - lib/submodules/ably-ruby/COPYRIGHT
250
252
  - lib/submodules/ably-ruby/Gemfile
251
253
  - lib/submodules/ably-ruby/LICENSE
254
+ - lib/submodules/ably-ruby/MAINTAINERS.md
252
255
  - lib/submodules/ably-ruby/README.md
253
256
  - lib/submodules/ably-ruby/Rakefile
254
257
  - lib/submodules/ably-ruby/SPEC.md
@@ -305,6 +308,7 @@ files:
305
308
  - lib/submodules/ably-ruby/lib/ably/realtime/auth.rb
306
309
  - lib/submodules/ably-ruby/lib/ably/realtime/channel.rb
307
310
  - lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_manager.rb
311
+ - lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_properties.rb
308
312
  - lib/submodules/ably-ruby/lib/ably/realtime/channel/channel_state_machine.rb
309
313
  - lib/submodules/ably-ruby/lib/ably/realtime/channel/publisher.rb
310
314
  - lib/submodules/ably-ruby/lib/ably/realtime/channel/push_channel.rb
@@ -388,6 +392,7 @@ files:
388
392
  - lib/submodules/ably-ruby/spec/support/protocol_helper.rb
389
393
  - lib/submodules/ably-ruby/spec/support/random_helper.rb
390
394
  - lib/submodules/ably-ruby/spec/support/rest_testapp_before_retry.rb
395
+ - lib/submodules/ably-ruby/spec/support/serialization_helper.rb
391
396
  - lib/submodules/ably-ruby/spec/support/test_app.rb
392
397
  - lib/submodules/ably-ruby/spec/support/test_logger_helper.rb
393
398
  - lib/submodules/ably-ruby/spec/unit/auth_spec.rb
@@ -447,7 +452,7 @@ homepage: http://github.com/ably/ably-ruby-rest
447
452
  licenses:
448
453
  - Apache 2
449
454
  metadata: {}
450
- post_install_message:
455
+ post_install_message:
451
456
  rdoc_options: []
452
457
  require_paths:
453
458
  - lib
@@ -458,12 +463,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
458
463
  version: '0'
459
464
  required_rubygems_version: !ruby/object:Gem::Requirement
460
465
  requirements:
461
- - - ">"
466
+ - - ">="
462
467
  - !ruby/object:Gem::Version
463
- version: 1.3.1
468
+ version: '0'
464
469
  requirements: []
465
470
  rubygems_version: 3.0.3
466
- signing_key:
471
+ signing_key:
467
472
  specification_version: 4
468
473
  summary: A Ruby REST only client library for ably.io realtime messaging
469
474
  test_files:
@@ -1,18 +0,0 @@
1
- env:
2
- - RSPEC_RETRY=true PARALLEL_TEST_PROCESSORS=2 PROTOCOL=json
3
- - RSPEC_RETRY=true PARALLEL_TEST_PROCESSORS=2 PROTOCOL=msgpack
4
- language: ruby
5
- rvm:
6
- - 1.9.3
7
- - 2.1.10
8
- - 2.2.10
9
- - 2.3.8
10
- - 2.5.5
11
- - 2.6.0
12
- - 2.6.1
13
- - 2.6.2
14
- - 2.6.3
15
- script: spec/run_parallel_tests
16
- notifications:
17
- slack:
18
- secure: Xe8MwDcV2C8XLGk6O6Co31LpQiRSxsmS7Toy5vM7rHds5fnVRBNn5iX6Q5mXMdLOlnsMhjKLt7zl4fsBOZv+siQ+Us0omZSIYpXCYSCIj8nofReF0Lj8M4oa6lFSL5OuygO7PH+wLKTRxQURGZ6Pi1nHU+RE5izRmsewQHkhtY0=