pubnub 4.7.1 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pubnub might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c52a9cfe08cbc90c671a74610beb900b5627c81e9f24da57e0c60530aa05c5b9
4
- data.tar.gz: 5dd3300e2b6667e2364ab3e6d56f6583d3ca1eb71caa1839e9e97d3dbe68ec50
3
+ metadata.gz: 3f831ff43edccdc424ceea6408dae5d704d30c35fccb7e496d4e328a884169b6
4
+ data.tar.gz: c12621f317beac91d53b3008a5ba32a02557aff54e998f1b6e8ff3c27c2e88c0
5
5
  SHA512:
6
- metadata.gz: 3385c44fe3b07c3f84ff233e3bc42456e0907ff56e2fd65bd6197b2bcaa6edd75c3d53268959bb1491b88e7eaf3e49308a3afbed86a3bbebc2062364336b95be
7
- data.tar.gz: 50506cf261d7d8c8240b8a25683dbe1032ebbb99b4f9dc3ba609228672fb8e3609ee43c3a0cc94052e8d80177e7e3554ee8b57458275d5a9865b37b7ad81ca1a
6
+ metadata.gz: 7d575ef625dcdbc6fd15158740f557cc8914789de48ecfa6885e25c6d35ca86d7fa3bb09a1e85d871e5ae734e52ca8df5b96a85579be7bb784803d47dfb1d503
7
+ data.tar.gz: 2ec1515df9563f963bf3bfe664e8e4911a8737e72dbe44dde7d161008f11b3684d19e7c0e05bbd1dab6d2941fd8f442652bf16fe2fbe7b068b404a08bd7cc100
@@ -25,10 +25,10 @@ jobs:
25
25
  sudo gem install bundler &&
26
26
  bundle install
27
27
  - name: Run acceptance tests (optional)
28
- run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_beta -p report_beta
28
+ run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_beta -p report_beta -f pretty
29
29
  continue-on-error: true
30
30
  - name: Run acceptance tests (required)
31
- run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_main -p report_main
31
+ run: bundle exec cucumber sdk-specifications/features/ -p mock -p run_main -p report_main -f pretty
32
32
  - name: Combine test results
33
33
  if: always()
34
34
  run: |
data/.pubnub.yml CHANGED
@@ -1,6 +1,11 @@
1
1
  ---
2
- version: "4.7.1"
2
+ version: "4.8.0"
3
3
  changelog:
4
+ - date: 2021-12-16
5
+ version: v4.8.0
6
+ changes:
7
+ - type: feature
8
+ text: "Add revoke token feature."
4
9
  - date: 2021-11-24
5
10
  version: v4.7.1
6
11
  changes:
@@ -403,6 +408,10 @@ features:
403
408
  access:
404
409
  - ACCESS-GRANT
405
410
  - ACCESS-SECRET-KEY-ALL-ACCESS
411
+ - ACCESS-GRANT-TOKEN
412
+ - ACCESS-PARSE-TOKEN
413
+ - ACCESS-SET-TOKEN
414
+ - ACCESS-REVOKE-TOKEN
406
415
  channel-groups:
407
416
  - CHANNEL-GROUPS-ADD-CHANNELS
408
417
  - CHANNEL-GROUPS-REMOVE-CHANNELS
@@ -612,7 +621,7 @@ sdks:
612
621
  - x86-64
613
622
  - distribution-type: package
614
623
  distribution-repository: RubyGems
615
- package-name: pubnub-4.7.1.gem
624
+ package-name: pubnub-4.8.0.gem
616
625
  location: https://rubygems.org/gems/pubnub
617
626
  requires:
618
627
  - name: addressable
@@ -717,8 +726,8 @@ sdks:
717
726
  - x86-64
718
727
  - distribution-type: library
719
728
  distribution-repository: GitHub release
720
- package-name: pubnub-4.7.1.gem
721
- location: https://github.com/pubnub/ruby/releases/download/v4.7.1/pubnub-4.7.1.gem
729
+ package-name: pubnub-4.8.0.gem
730
+ location: https://github.com/pubnub/ruby/releases/download/v4.8.0/pubnub-4.8.0.gem
722
731
  requires:
723
732
  - name: addressable
724
733
  min-version: 2.0.0
data/CHANGELOG.md CHANGED
@@ -1,12 +1,18 @@
1
- ## v4.7.1
2
- November 24 2021
3
-
4
- #### Added
5
- - Add new method `all_history_messages` which return messages from requested interval or `since` / `before` date in single object.
6
-
7
- #### Fixed
8
- - Fix exception raised when optional start / end not passed to `paged_history`.
9
-
1
+ ## v4.8.0
2
+ December 16 2021
3
+
4
+ #### Added
5
+ - Add revoke token feature.
6
+
7
+ ## v4.7.1
8
+ November 24 2021
9
+
10
+ #### Added
11
+ - Add new method `all_history_messages` which return messages from requested interval or `since` / `before` date in single object.
12
+
13
+ #### Fixed
14
+ - Fix exception raised when optional start / end not passed to `paged_history`.
15
+
10
16
  ## v4.7.0
11
17
  November 09 2021
12
18
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pubnub (4.7.1)
4
+ pubnub (4.8.0)
5
5
  addressable (>= 2.0.0)
6
6
  concurrent-ruby (~> 1.1.5)
7
7
  concurrent-ruby-edge (~> 0.5.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.7.1
1
+ 4.8.0
@@ -16,6 +16,18 @@ Given('I have a keyset with access manager enabled') do
16
16
  @pubnub = Pubnub.new(@pn_configuration)
17
17
  end
18
18
 
19
+ Given('I have a keyset with access manager enabled - without secret key') do
20
+ expect(ENV['PAM_SUB_KEY']).not_to be_nil
21
+ expect(ENV['PAM_PUB_KEY']).not_to be_nil
22
+ @pn_configuration['subscribe_key'] = ENV['PAM_SUB_KEY']
23
+ @pn_configuration['publish_key'] = ENV['PAM_PUB_KEY']
24
+ logger = Logger.new(STDOUT)
25
+ logger.level = Logger::DEBUG
26
+ @pn_configuration['logger'] = logger
27
+
28
+ @pubnub = Pubnub.new(@pn_configuration)
29
+ end
30
+
19
31
  Given('the authorized UUID {string}') do |uuid|
20
32
  @grant_token_state[:authorized_uuid] = uuid
21
33
  end
@@ -48,17 +60,56 @@ Given('the {string} {resourceType} pattern access permissions') do |pattern, res
48
60
  }
49
61
  end
50
62
 
63
+ Given('a valid token with permissions to publish with channel {string}') do |string|
64
+ @grant_token_state[:token] = token_with_all
65
+ end
66
+
67
+ Given('a token') do
68
+ @grant_token_state[:token] = token_with_all
69
+ end
70
+
71
+ Given('an expired token with permissions to publish with channel {string}') do |string|
72
+ @grant_token_state[:token] = token_with_all
73
+ end
74
+
51
75
  And('grant pattern permission {permissionType}') do |permission_type|
52
76
  current_pattern = @grant_token_state[:current_pattern]
53
77
  @grant_token_state[:current_grant][current_pattern][:permission_type].push(permission_type)
54
78
  end
55
79
 
56
-
57
80
  When('I grant a token specifying those permissions') do
58
81
  res = call_grant_token(@pubnub, @grant_token_state)
59
82
  @grant_token_state[:parsed_token] = @pubnub.parse_token(res.result[:data]["token"])
60
83
  end
61
84
 
85
+ When('I publish a message using that auth token with channel {string}') do |channel|
86
+ @pubnub.set_token(@grant_token_state[:token])
87
+ res = @pubnub.publish(
88
+ message: "This is message",
89
+ channel: channel,
90
+ http_sync: true
91
+ )
92
+ @global_state[:last_call_res] = res
93
+ end
94
+
95
+ When('I attempt to publish a message using that auth token with channel {string}') do |channel|
96
+ @pubnub.set_token(@grant_token_state[:token])
97
+ res = @pubnub.publish(
98
+ message: "This is message",
99
+ channel: channel,
100
+ http_sync: true
101
+ )
102
+ @global_state[:last_call_res] = res
103
+ end
104
+
105
+ When('I revoke a token') do
106
+ res = @pubnub.revoke_token(
107
+ token: @grant_token_state[:token],
108
+ http_sync: true
109
+ )
110
+ @global_state[:last_call_res] = res
111
+ end
112
+
62
113
  Then('the token contains the authorized UUID {string}') do |expected_uuid|
63
114
  expect(@grant_token_state[:parsed_token]["uuid"]).to eq expected_uuid
64
115
  end
@@ -115,35 +166,37 @@ Given('deny resource permission {permissionType}') do |permission_type|
115
166
  end
116
167
 
117
168
  When('I attempt to grant a token specifying those permissions') do
118
- @grant_token_state[:error_response] = call_grant_token(@pubnub, @grant_token_state)
169
+ @global_state[:last_call_res] = call_grant_token(@pubnub, @grant_token_state)
119
170
  end
120
171
 
121
172
  Then('an error is returned') do
122
- expect(@grant_token_state[:error_response]).not_to eq nil
173
+ envelope = @global_state[:last_call_res]
174
+ expect(envelope).not_to eq nil
175
+ expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
123
176
  end
124
177
 
125
178
  Then('the error status code is {int}') do |code|
126
- expect(@grant_token_state[:error_response].status[:code]).to eq code
179
+ expect(@global_state[:last_call_res].status[:code]).to eq code
127
180
  end
128
181
 
129
182
  Then('the error message is {string}') do |error_message|
130
- expect(parse_error_body(@grant_token_state[:error_response])["error"]["message"]).to eq error_message
183
+ expect(parse_error_body(@global_state[:last_call_res])["error"]["message"]).to eq error_message
131
184
  end
132
185
 
133
186
  Then('the error source is {string}') do |error_source|
134
- expect(parse_error_body(@grant_token_state[:error_response])["error"]["source"]).to eq error_source
187
+ expect(parse_error_body(@global_state[:last_call_res])["error"]["source"]).to eq error_source
135
188
  end
136
189
 
137
190
  Then('the error detail message is {string}') do |details_message|
138
- expect(parse_error_body(@grant_token_state[:error_response])["error"]["details"][0]["message"]).to eq details_message
191
+ expect(parse_error_body(@global_state[:last_call_res])["error"]["details"][0]["message"]).to eq details_message
139
192
  end
140
193
 
141
194
  Then('the error detail location is {string}') do |details_location|
142
- expect(parse_error_body(@grant_token_state[:error_response])["error"]["details"][0]["location"]).to eq details_location
195
+ expect(parse_error_body(@global_state[:last_call_res])["error"]["details"][0]["location"]).to eq details_location
143
196
  end
144
197
 
145
198
  Then('the error detail location type is {string}') do |location_type|
146
- expect(parse_error_body(@grant_token_state[:error_response])["error"]["details"][0]["locationType"]).to eq location_type
199
+ expect(parse_error_body(@global_state[:last_call_res])["error"]["details"][0]["locationType"]).to eq location_type
147
200
  end
148
201
 
149
202
  Given('I have a known token containing an authorized UUID') do
@@ -165,3 +218,39 @@ end
165
218
  Given('I have a known token containing UUID pattern Permissions') do
166
219
  @grant_token_state[:token] = token_with_all
167
220
  end
221
+
222
+ Given('the token string {string}') do |token|
223
+ @grant_token_state[:token] = token
224
+ end
225
+
226
+ Then('the result is successful') do
227
+ envelope = @global_state[:last_call_res]
228
+ expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq false
229
+ expect(envelope.status[:code]).to eq 200
230
+ end
231
+
232
+ Then('an auth error is returned') do
233
+ envelope = @global_state[:last_call_res]
234
+ expect(envelope).not_to eq nil
235
+ expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq true
236
+ end
237
+
238
+ Then('the auth error message is {string}') do |error_message|
239
+ expect(parse_error_body(@global_state[:last_call_res])["message"]).to eq error_message
240
+ end
241
+
242
+ Then('the error service is {string}') do |service|
243
+ expect(parse_error_body(@global_state[:last_call_res])["service"]).to eq service
244
+ end
245
+
246
+ Then('I get confirmation that token has been revoked') do
247
+ envelope = @global_state[:last_call_res]
248
+ expect(envelope.is_a?(Pubnub::ErrorEnvelope)).to eq false
249
+ expect(envelope.status[:code]).to eq 200
250
+ end
251
+
252
+ Then('the error detail message is not empty') do
253
+ expect(parse_error_body(@global_state[:last_call_res])["error"]["message"].empty?).to eq false
254
+ end
255
+
256
+
@@ -3,6 +3,7 @@ require 'json'
3
3
 
4
4
  Before do |scenario|
5
5
  @grant_token_state = {}
6
+ @global_state = {}
6
7
  @grant_token_state[:current_grant] = {}
7
8
  @pn_configuration = {}
8
9
 
@@ -4,7 +4,7 @@ module Pubnub
4
4
  class Client
5
5
  # Module that holds generator for all events
6
6
  module Events
7
- EVENTS = %w[publish subscribe presence leave history here_now audit grant grant_token delete_messages
7
+ EVENTS = %w[publish subscribe presence leave history here_now audit grant grant_token revoke_token delete_messages
8
8
  revoke time heartbeat where_now set_state state channel_registration message_counts signal
9
9
  add_channels_to_push list_push_provisions remove_channels_from_push remove_device_from_push
10
10
  set_uuid_metadata set_channel_metadata remove_uuid_metadata remove_channel_metadata
data/lib/pubnub/client.rb CHANGED
@@ -37,6 +37,7 @@ require 'pubnub/validators/audit'
37
37
  require 'pubnub/validators/channel_registration'
38
38
  require 'pubnub/validators/grant'
39
39
  require 'pubnub/validators/grant_token'
40
+ require 'pubnub/validators/revoke_token'
40
41
  require 'pubnub/validators/heartbeat'
41
42
  require 'pubnub/validators/here_now'
42
43
  require 'pubnub/validators/history'
@@ -58,6 +58,7 @@ module Pubnub
58
58
  OPERATION_AUDIT = :audit
59
59
  OPERATION_GRANT = :grant
60
60
  OPERATION_GRANT_TOKEN = :grant_token
61
+ OPERATION_REVOKE_TOKEN = :revoke_token
61
62
  OPERATION_REVOKE = :revoke
62
63
  OPERATION_DELETE = :delete
63
64
  OPERATION_LIST_ALL_CHANNEL_GROUPS = :list_all_channel_groups
data/lib/pubnub/event.rb CHANGED
@@ -112,7 +112,8 @@ module Pubnub
112
112
 
113
113
  def operation_http_method
114
114
  case @event
115
- when Pubnub::Constants::OPERATION_DELETE, Pubnub::Constants::OPERATION_REMOVE_CHANNEL_METADATA, Pubnub::Constants::OPERATION_REMOVE_UUID_METADATA
115
+ when Pubnub::Constants::OPERATION_DELETE, Pubnub::Constants::OPERATION_REMOVE_CHANNEL_METADATA,
116
+ Pubnub::Constants::OPERATION_REMOVE_UUID_METADATA, Pubnub::Constants::OPERATION_REVOKE_TOKEN
116
117
  "delete"
117
118
  when Pubnub::Constants::OPERATION_SET_UUID_METADATA, Pubnub::Constants::OPERATION_SET_CHANNEL_METADATA,
118
119
  Pubnub::Constants::OPERATION_SET_CHANNEL_MEMBERS, Pubnub::Constants::OPERATION_SET_MEMBERSHIPS,
@@ -174,6 +175,7 @@ module Pubnub
174
175
  state channel_group channel_groups compressed meta customs include_token
175
176
  replicate with_presence cipher_key_selector include_meta join update get
176
177
  add remove push_token push_gateway environment topic authorized_uuid
178
+ token
177
179
  ]
178
180
 
179
181
  options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last }
@@ -0,0 +1,66 @@
1
+ module Pubnub
2
+ # Holds revoke token functionality
3
+ class RevokeToken < SingleEvent
4
+ include Concurrent::Async
5
+ include Pubnub::Validator::RevokeToken
6
+
7
+ def initialize(options, app)
8
+ @event = :revoke_token
9
+ super
10
+ @token = @token.split(' ')
11
+ .map{ |part| CGI.escape(part) }
12
+ .join("%20")
13
+ end
14
+
15
+ private
16
+
17
+ def current_operation
18
+ Pubnub::Constants::OPERATION_GRANT_TOKEN
19
+ end
20
+
21
+ def valid_envelope(parsed_response, req_res_objects)
22
+ Pubnub::Envelope.new(
23
+ event: @event,
24
+ event_options: @given_options,
25
+ timetoken: nil,
26
+ status: {
27
+ code: req_res_objects[:response].code,
28
+ client_request: req_res_objects[:request],
29
+ server_response: req_res_objects[:response],
30
+ category: Pubnub::Constants::STATUS_ACK,
31
+ error: false,
32
+ auto_retried: false,
33
+
34
+ current_timetoken: nil,
35
+ last_timetoken: nil,
36
+ subscribed_channels: nil,
37
+ subscribed_channel_groups: nil,
38
+
39
+ data: nil,
40
+
41
+ config: get_config
42
+
43
+ },
44
+ result: {
45
+ code: req_res_objects[:response].code,
46
+ operation: current_operation,
47
+ client_request: req_res_objects[:request],
48
+ server_response: req_res_objects[:response],
49
+
50
+ data: parsed_response['data']
51
+ }
52
+ )
53
+ end
54
+
55
+
56
+ def path
57
+ '/' + [
58
+ 'v3',
59
+ 'pam',
60
+ @subscribe_key,
61
+ 'grant',
62
+ @token
63
+ ].join('/')
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,31 @@
1
+ # Toplevel Pubnub module.
2
+ module Pubnub
3
+ # Validator module that holds all validators modules
4
+ module Validator
5
+ # Validator for Grant event
6
+ module RevokeToken
7
+ include CommonValidator
8
+
9
+ def validate!
10
+ validate_keys!
11
+ validate_token!
12
+ end
13
+
14
+ private
15
+
16
+ def validate_keys!
17
+ raise(
18
+ ArgumentError.new(object: self, message: ':subscribe_key is required for revoke token event.'),
19
+ ':subscribe_key is required for grant token event.'
20
+ ) if @subscribe_key.nil? || @subscribe_key.empty?
21
+ end
22
+
23
+ def validate_token!
24
+ raise(
25
+ ArgumentError.new(object: self, message: ':token is required for revoke token event.'),
26
+ ':token is required for revoke token event.'
27
+ ) if @token.nil? || @token.empty?
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,4 +1,4 @@
1
1
  # Toplevel Pubnub module.
2
2
  module Pubnub
3
- VERSION = '4.7.1'.freeze
3
+ VERSION = '4.8.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubnub
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.1
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PubNub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2021-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -151,7 +151,7 @@ files:
151
151
  - VERSION
152
152
  - config/cucumber.yml
153
153
  - docs.md
154
- - features/step_definitions/grant_token_steps.rb
154
+ - features/step_definitions/access_steps.rb
155
155
  - features/support/env.rb
156
156
  - features/support/helper.rb
157
157
  - features/support/hooks.rb
@@ -206,6 +206,7 @@ files:
206
206
  - lib/pubnub/events/remove_memberships.rb
207
207
  - lib/pubnub/events/remove_uuid_metadata.rb
208
208
  - lib/pubnub/events/revoke.rb
209
+ - lib/pubnub/events/revoke_token.rb
209
210
  - lib/pubnub/events/set_channel_members.rb
210
211
  - lib/pubnub/events/set_channel_metadata.rb
211
212
  - lib/pubnub/events/set_memberships.rb
@@ -262,6 +263,7 @@ files:
262
263
  - lib/pubnub/validators/remove_memberships.rb
263
264
  - lib/pubnub/validators/remove_uuid_metadata.rb
264
265
  - lib/pubnub/validators/revoke.rb
266
+ - lib/pubnub/validators/revoke_token.rb
265
267
  - lib/pubnub/validators/set_channel_members.rb
266
268
  - lib/pubnub/validators/set_channel_metadata.rb
267
269
  - lib/pubnub/validators/set_memberships.rb
@@ -298,7 +300,7 @@ signing_key:
298
300
  specification_version: 4
299
301
  summary: PubNub Official Ruby gem.
300
302
  test_files:
301
- - features/step_definitions/grant_token_steps.rb
303
+ - features/step_definitions/access_steps.rb
302
304
  - features/support/env.rb
303
305
  - features/support/helper.rb
304
306
  - features/support/hooks.rb