pubnub 4.0.21 → 4.0.22
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 +4 -4
- data/.pubnub.yml +91 -84
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/lib/signatures/all-letters.yml +43 -0
- data/fixtures/vcr_cassettes/lib/signatures/channel_registration.yml +180 -0
- data/fixtures/vcr_cassettes/lib/signatures/heartbeat.yml +46 -0
- data/fixtures/vcr_cassettes/lib/signatures/here_now.yml +47 -0
- data/fixtures/vcr_cassettes/lib/signatures/history.yml +46 -0
- data/fixtures/vcr_cassettes/lib/signatures/leave.yml +46 -0
- data/fixtures/vcr_cassettes/lib/signatures/presence.yml +40 -0
- data/fixtures/vcr_cassettes/lib/signatures/publish.yml +40 -0
- data/fixtures/vcr_cassettes/lib/signatures/special.yml +43 -0
- data/fixtures/vcr_cassettes/lib/signatures/state.yml +92 -0
- data/fixtures/vcr_cassettes/lib/signatures/subscribe.yml +40 -0
- data/fixtures/vcr_cassettes/lib/signatures/where_now.yml +47 -0
- data/fixtures/vcr_cassettes/lib/signatures/wildcard.yml +43 -0
- data/lib/pubnub/event/signature.rb +1 -3
- data/lib/pubnub/events/channel_registration.rb +2 -2
- data/lib/pubnub/events/here_now.rb +1 -1
- data/lib/pubnub/events/history.rb +1 -1
- data/lib/pubnub/events/presence.rb +1 -1
- data/lib/pubnub/events/publish.rb +1 -1
- data/lib/pubnub/events/set_state.rb +1 -1
- data/lib/pubnub/events/state.rb +1 -1
- data/lib/pubnub/events/where_now.rb +1 -1
- data/lib/pubnub/formatter.rb +4 -4
- data/lib/pubnub/pam.rb +4 -7
- data/lib/pubnub/version.rb +1 -1
- data/spec/lib/event_spec.rb +52 -52
- data/spec/lib/signatures_spec.rb +277 -0
- metadata +18 -3
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://ps.pndsn.com/v2/presence/sub-key/sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe/uuid/a!@%23$%25%5E&()%C5%BB%C3%93%C5%81%5B%5D%7B%7D%22%22%3C%3E%3F%3F~%60Z?pnsdk=PubNub-Ruby/4.0.21&signature=8VW%2B4ZerzJsLIububJVrwrCiRILf%2BIkj4aovWsk0vNY=×tamp=1496402114&uuid=test
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.1.10 (2016-04-01))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Fri, 02 Jun 2017 11:15:14 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Fri, 02 Jun 2017 11:15:14 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset="UTF-8"
|
25
|
+
Content-Length:
|
26
|
+
- '129'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*"
|
31
|
+
Access-Control-Allow-Methods:
|
32
|
+
- OPTIONS, GET, POST
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
Accept-Ranges:
|
36
|
+
- bytes
|
37
|
+
Age:
|
38
|
+
- '0'
|
39
|
+
Server:
|
40
|
+
- Pubnub Presence
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"status": 200, "message": "OK", "payload": {"channels": ["a!@#$%^&()\u017b\u00d3\u0141[]{}\"\"<>??~`Z"]},
|
44
|
+
"service": "Presence"}'
|
45
|
+
http_version:
|
46
|
+
recorded_at: Fri, 02 Jun 2017 11:15:14 GMT
|
47
|
+
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://ps.pndsn.com/v1/auth/grant/sub-key/sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe?channel=demo.*&m=1&pnsdk=PubNub-Ruby/4.0.21&r=1&signature=DzBQYuME9z8fKIOtmo6ubv3rt-rsw9g9oc62lxmF6F0=×tamp=1496242823&ttl=1440&uuid=test&w=1
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- HTTPClient/1.0 (2.8.3, ruby 2.1.10 (2016-04-01))
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
Date:
|
15
|
+
- Wed, 31 May 2017 15:00:24 GMT
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 31 May 2017 15:00:24 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/javascript; charset=UTF-8
|
25
|
+
Content-Length:
|
26
|
+
- '205'
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Access-Control-Allow-Origin:
|
30
|
+
- "*"
|
31
|
+
Access-Control-Allow-Methods:
|
32
|
+
- GET
|
33
|
+
Access-Control-Allow-Headers:
|
34
|
+
- Origin, X-Requested-With, Content-Type, Accept
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache, no-store, must-revalidate
|
37
|
+
body:
|
38
|
+
encoding: UTF-8
|
39
|
+
string: '{"message":"Success","payload":{"level":"channel","subscribe_key":"sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe","ttl":1440,"channels":{"demo.*":{"r":1,"w":1,"m":1}}},"service":"Access
|
40
|
+
Manager","status":200}'
|
41
|
+
http_version:
|
42
|
+
recorded_at: Wed, 31 May 2017 15:00:24 GMT
|
43
|
+
recorded_with: VCR 3.0.1
|
@@ -13,11 +13,9 @@ module Pubnub
|
|
13
13
|
@app.env[:subscribe_key],
|
14
14
|
@app.env[:publish_key],
|
15
15
|
path,
|
16
|
-
variables_for_signature
|
16
|
+
variables_for_signature.gsub(/[!~'()*]/) { |char| '%' + char.ord.to_s(16).upcase } # Replace ! ~ * ' ( )
|
17
17
|
].join("\n")
|
18
18
|
|
19
|
-
message = message.gsub(/[!~'()]/) { |char| '%' + char.ord.to_s(16).upcase }
|
20
|
-
|
21
19
|
URI.encode_www_form_component(Base64.encode64(
|
22
20
|
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'),
|
23
21
|
@app.env[:secret_key].to_s, message)
|
@@ -16,11 +16,11 @@ module Pubnub
|
|
16
16
|
def parameters(*_args)
|
17
17
|
parameters = super
|
18
18
|
if @action == :add && !@channel.blank?
|
19
|
-
parameters.merge!(add: @channel
|
19
|
+
parameters.merge!(add: Formatter.channels_for_url(@channel, false))
|
20
20
|
end
|
21
21
|
|
22
22
|
if @action == :remove && !@channel.blank?
|
23
|
-
parameters.merge!(remove: @channel
|
23
|
+
parameters.merge!(remove: Formatter.channels_for_url(@channel, false))
|
24
24
|
end
|
25
25
|
|
26
26
|
parameters
|
data/lib/pubnub/events/state.rb
CHANGED
data/lib/pubnub/formatter.rb
CHANGED
@@ -6,12 +6,12 @@ module Pubnub
|
|
6
6
|
class << self
|
7
7
|
# Returns array of encoded channels if should_encode is true,
|
8
8
|
# otherwise returns just array of channels
|
9
|
-
def format_channel(channel, should_encode =
|
9
|
+
def format_channel(channel, should_encode = false)
|
10
10
|
make_channel_array(channel).map do |chan|
|
11
11
|
if should_encode
|
12
12
|
encode(chan)
|
13
13
|
else
|
14
|
-
chan
|
14
|
+
chan.to_s
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -92,8 +92,8 @@ module Pubnub
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# Returns string with all channels separated by comma or single coma
|
95
|
-
def channels_for_url(channels)
|
96
|
-
channel = channels.sort.join(',')
|
95
|
+
def channels_for_url(channels, should_encode = true)
|
96
|
+
channel = channels.map{ |c| should_encode ? encode(c) : c }.sort.join(',')
|
97
97
|
channel = ',' if channel.empty?
|
98
98
|
channel
|
99
99
|
end
|
data/lib/pubnub/pam.rb
CHANGED
@@ -7,9 +7,9 @@ module Pubnub
|
|
7
7
|
|
8
8
|
@auth_key = options[:auth_key]
|
9
9
|
|
10
|
-
@channel += format_channels(options[:presence]).map do |c|
|
11
|
-
|
12
|
-
end if options[:presence].present?
|
10
|
+
# @channel += format_channels(options[:presence]).map do |c|
|
11
|
+
# c + '-pnpres'
|
12
|
+
# end if options[:presence].present?
|
13
13
|
end
|
14
14
|
|
15
15
|
def signature
|
@@ -17,12 +17,9 @@ module Pubnub
|
|
17
17
|
@subscribe_key,
|
18
18
|
@publish_key,
|
19
19
|
@event,
|
20
|
-
variables_for_signature
|
20
|
+
variables_for_signature.gsub(/[!~'()*]/) { |char| '%' + char.ord.to_s(16).upcase } # Replace ! ~ * ' ( )
|
21
21
|
].join("\n")
|
22
22
|
|
23
|
-
# Replace ! ~ * ' ( )
|
24
|
-
message = message.gsub(/[!~'()]/) { |char| '%' + char.ord.to_s(16).upcase }
|
25
|
-
|
26
23
|
Base64.urlsafe_encode64(
|
27
24
|
OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'),
|
28
25
|
@secret_key.to_s, message)
|
data/lib/pubnub/version.rb
CHANGED
data/spec/lib/event_spec.rb
CHANGED
@@ -83,59 +83,59 @@ shared_examples 'an event' do
|
|
83
83
|
.to eq Array
|
84
84
|
end
|
85
85
|
|
86
|
-
it 'is formatted when given as string' do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'is formatted when given as symbol' do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'is formatted when given as array' do
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
86
|
+
# it 'is formatted when given as string' do
|
87
|
+
# event = described_class.new({ channel: '!with spec&', skip_validate: true }, pubnub_client)
|
88
|
+
# expect(event.instance_variable_get(:@channel))
|
89
|
+
# .to eq ['%21with%20spec%26-pnpres']
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# it 'is formatted when given as symbol' do
|
93
|
+
# event = described_class.new({ channel: :demo, skip_validate: true }, pubnub_client)
|
94
|
+
# expect(event.instance_variable_get(:@channel))
|
95
|
+
# .to eq ['demo-pnpres']
|
96
|
+
# end
|
97
|
+
#
|
98
|
+
# it 'is formatted when given as array' do
|
99
|
+
# event = described_class.new(
|
100
|
+
# { channel: ['!with spec&', 'othe&r', 'th ir*!d', :four], skip_validate: true },
|
101
|
+
# pubnub_client
|
102
|
+
# )
|
103
|
+
# expect(event.instance_variable_get(:@channel))
|
104
|
+
# .to eq ['%21with%20spec%26-pnpres', 'othe%26r-pnpres', 'th%20ir*%21d-pnpres', 'four-pnpres']
|
105
|
+
# end
|
106
106
|
else
|
107
|
-
it 'is set properly when passed as :channels' do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'is formatted to be an array' do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'is formatted when given as string' do
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'is formatted when given as symbol' do
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'is formatted when given as array' do
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
107
|
+
# it 'is set properly when passed as :channels' do
|
108
|
+
# event = described_class.new({ channels: 'chan', skip_validate: true }, pubnub_client)
|
109
|
+
# expect(event.instance_variable_get(:@channel))
|
110
|
+
# .to eq ['chan']
|
111
|
+
# end
|
112
|
+
#
|
113
|
+
# it 'is formatted to be an array' do
|
114
|
+
# event = described_class.new({ channel: 'chan', skip_validate: true }, pubnub_client)
|
115
|
+
# expect(event.instance_variable_get(:@channel).class)
|
116
|
+
# .to eq Array
|
117
|
+
# end
|
118
|
+
#
|
119
|
+
# it 'is formatted when given as string' do
|
120
|
+
# event = described_class.new({ channel: '!with spec&', skip_validate: true }, pubnub_client)
|
121
|
+
# expect(event.instance_variable_get(:@channel))
|
122
|
+
# .to eq ['%21with%20spec%26']
|
123
|
+
# end
|
124
|
+
#
|
125
|
+
# it 'is formatted when given as symbol' do
|
126
|
+
# event = described_class.new({ channel: :demo, skip_validate: true }, pubnub_client)
|
127
|
+
# expect(event.instance_variable_get(:@channel))
|
128
|
+
# .to eq ['demo']
|
129
|
+
# end
|
130
|
+
#
|
131
|
+
# it 'is formatted when given as array' do
|
132
|
+
# event = described_class.new(
|
133
|
+
# { channel: ['!with spec&', 'othe&r', 'th ir*!d', :four], skip_validate: true },
|
134
|
+
# pubnub_client
|
135
|
+
# )
|
136
|
+
# expect(event.instance_variable_get(:@channel))
|
137
|
+
# .to eq ['%21with%20spec%26', 'othe%26r', 'th%20ir*%21d', 'four']
|
138
|
+
# end
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -0,0 +1,277 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Signatures' do
|
4
|
+
|
5
|
+
around :each do |example|
|
6
|
+
Celluloid.boot
|
7
|
+
example.run
|
8
|
+
Celluloid.shutdown
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'works all letters channel' do
|
12
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
13
|
+
Pubnub::Grant.any_instance.stub(:current_time).and_return(1496242823)
|
14
|
+
|
15
|
+
pubnub = Pubnub.new(
|
16
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
17
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
18
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
19
|
+
uuid: 'test'
|
20
|
+
)
|
21
|
+
|
22
|
+
VCR.use_cassette('lib/signatures/all-letters', record: :once) do
|
23
|
+
envelope = pubnub.grant(channel: 'demo', http_sync: true)
|
24
|
+
expect(envelope.status[:code]).to eq 200
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'works with wildcard' do
|
29
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
30
|
+
Pubnub::Grant.any_instance.stub(:current_time).and_return(1496242823)
|
31
|
+
|
32
|
+
pubnub = Pubnub.new(
|
33
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
34
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
35
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
36
|
+
uuid: 'test'
|
37
|
+
)
|
38
|
+
|
39
|
+
VCR.use_cassette('lib/signatures/wildcard', record: :once) do
|
40
|
+
envelope = pubnub.grant(channel: 'demo.*', http_sync: true)
|
41
|
+
expect(envelope.status[:code]).to eq 200
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with various special characters' do
|
46
|
+
it 'grant works' do
|
47
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
48
|
+
Pubnub::Grant.any_instance.stub(:current_time).and_return(1496242824)
|
49
|
+
|
50
|
+
pubnub = Pubnub.new(
|
51
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
52
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
53
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
54
|
+
uuid: 'test'
|
55
|
+
)
|
56
|
+
|
57
|
+
VCR.use_cassette('lib/signatures/special', record: :once) do
|
58
|
+
envelope = pubnub.grant(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
59
|
+
expect(envelope.status[:code]).to eq 200
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'publish works' do
|
64
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
65
|
+
Pubnub::Publish.any_instance.stub(:current_time).and_return 1496396127
|
66
|
+
Pubnub::Client.any_instance.stub(:generate_ortt).and_return 14963961271418600
|
67
|
+
|
68
|
+
pubnub = Pubnub.new(
|
69
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
70
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
71
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
72
|
+
uuid: 'test'
|
73
|
+
)
|
74
|
+
|
75
|
+
VCR.use_cassette('lib/signatures/publish', record: :once) do
|
76
|
+
envelope = pubnub.publish(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', message: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
77
|
+
expect(envelope.status[:code]).to eq 200
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'subscribe works' do
|
82
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
83
|
+
Pubnub::Subscribe.any_instance.stub(:current_time).and_return 1496397558
|
84
|
+
|
85
|
+
pubnub = Pubnub.new(
|
86
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
87
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
88
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
89
|
+
uuid: 'test'
|
90
|
+
)
|
91
|
+
|
92
|
+
VCR.use_cassette('lib/signatures/subscribe', record: :once) do
|
93
|
+
envelope = pubnub.subscribe(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
94
|
+
expect(envelope.first.status[:code]).to eq 200
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'presence works' do
|
99
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
100
|
+
Pubnub::Presence.any_instance.stub(:current_time).and_return 1496401532
|
101
|
+
|
102
|
+
pubnub = Pubnub.new(
|
103
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
104
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
105
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
106
|
+
uuid: 'test'
|
107
|
+
)
|
108
|
+
|
109
|
+
VCR.use_cassette('lib/signatures/presence', record: :once) do
|
110
|
+
envelope = pubnub.presence(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
111
|
+
expect(envelope.first.status[:code]).to eq 200
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'leave works' do
|
116
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
117
|
+
Pubnub::Leave.any_instance.stub(:current_time).and_return 1496401409
|
118
|
+
|
119
|
+
pubnub = Pubnub.new(
|
120
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
121
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
122
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
123
|
+
uuid: 'test'
|
124
|
+
)
|
125
|
+
|
126
|
+
VCR.use_cassette('lib/signatures/leave', record: :once) do
|
127
|
+
envelope = pubnub.leave(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
128
|
+
expect(envelope.status[:code]).to eq 200
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'history works' do
|
133
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
134
|
+
Pubnub::History.any_instance.stub(:current_time).and_return 1496396745
|
135
|
+
|
136
|
+
pubnub = Pubnub.new(
|
137
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
138
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
139
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
140
|
+
uuid: 'test'
|
141
|
+
)
|
142
|
+
|
143
|
+
VCR.use_cassette('lib/signatures/history', record: :once) do
|
144
|
+
envelope = pubnub.history(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
145
|
+
expect(envelope.status[:code]).to eq 200
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'here-now works' do
|
150
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
151
|
+
Pubnub::HereNow.any_instance.stub(:current_time).and_return 1496401140
|
152
|
+
|
153
|
+
pubnub = Pubnub.new(
|
154
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
155
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
156
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
157
|
+
uuid: 'test'
|
158
|
+
)
|
159
|
+
|
160
|
+
VCR.use_cassette('lib/signatures/here_now', record: :once) do
|
161
|
+
envelope = pubnub.here_now(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
162
|
+
expect(envelope.status[:code]).to eq 200
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'channel registration works' do
|
167
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
168
|
+
pubnub = Pubnub.new(
|
169
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
170
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
171
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
172
|
+
uuid: 'test'
|
173
|
+
)
|
174
|
+
|
175
|
+
VCR.use_cassette('lib/signatures/channel_registration', record: :once) do
|
176
|
+
Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
|
177
|
+
envelope0 = pubnub.channel_registration(
|
178
|
+
action: :add,
|
179
|
+
channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
180
|
+
channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
181
|
+
http_sync: true
|
182
|
+
)
|
183
|
+
|
184
|
+
Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
|
185
|
+
envelope1 = pubnub.channel_registration(
|
186
|
+
action: :get,
|
187
|
+
channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
188
|
+
http_sync: true
|
189
|
+
)
|
190
|
+
|
191
|
+
Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
|
192
|
+
envelope2 = pubnub.channel_registration(
|
193
|
+
action: :remove,
|
194
|
+
channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
195
|
+
channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
196
|
+
http_sync: true
|
197
|
+
)
|
198
|
+
|
199
|
+
Pubnub::ChannelRegistration.any_instance.stub(:current_time).and_return 1496400706
|
200
|
+
envelope3 = pubnub.channel_registration(
|
201
|
+
action: :remove,
|
202
|
+
channel_group: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
203
|
+
http_sync: true
|
204
|
+
)
|
205
|
+
|
206
|
+
expect(envelope0.status[:code]).to eq 200
|
207
|
+
expect(envelope1.status[:code]).to eq 200
|
208
|
+
expect(envelope2.status[:code]).to eq 200
|
209
|
+
expect(envelope3.status[:code]).to eq 200
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'heartbeat works' do
|
214
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
215
|
+
Pubnub::Heartbeat.any_instance.stub(:current_time).and_return 1496400995
|
216
|
+
|
217
|
+
pubnub = Pubnub.new(
|
218
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
219
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
220
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
221
|
+
uuid: 'test'
|
222
|
+
)
|
223
|
+
|
224
|
+
VCR.use_cassette('lib/signatures/heartbeat', record: :once) do
|
225
|
+
envelope = pubnub.heartbeat(channel: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z', heartbeat: 10, http_sync: true)
|
226
|
+
expect(envelope.status[:code]).to eq 200
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'state works' do
|
231
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
232
|
+
Pubnub::SetState.any_instance.stub(:current_time).and_return 1496402248
|
233
|
+
Pubnub::State.any_instance.stub(:current_time).and_return 1496402248
|
234
|
+
|
235
|
+
pubnub = Pubnub.new(
|
236
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
237
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
238
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
239
|
+
uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z'
|
240
|
+
)
|
241
|
+
|
242
|
+
VCR.use_cassette('lib/signatures/state', record: :once) do
|
243
|
+
envelope = pubnub.set_state(
|
244
|
+
channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z',
|
245
|
+
state: { something: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z' },
|
246
|
+
http_sync: true
|
247
|
+
)
|
248
|
+
|
249
|
+
expect(envelope.status[:code]).to eq 200
|
250
|
+
|
251
|
+
next_envelope = pubnub.get_state(channel: 'a!@#$%^&*()ŻÓŁ[]{}""<>??~`Z', uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z', http_sync: true)
|
252
|
+
expect(next_envelope.status[:code]).to eq 200
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'where now works' do
|
257
|
+
stub_const('Pubnub::VERSION', '4.0.21')
|
258
|
+
Pubnub::WhereNow.any_instance.stub(:current_time).and_return 1496402114
|
259
|
+
|
260
|
+
pubnub = Pubnub.new(
|
261
|
+
subscribe_key: 'sub-c-b6df3d38-45e3-11e7-86e2-02ee2ddab7fe',
|
262
|
+
publish_key: 'pub-c-cd48c41a-afce-4f37-8b3b-7fafccf52e2d',
|
263
|
+
secret_key: 'sec-c-OTMzNmViNGEtYjg0MS00ZTZkLWI5ZmMtNDYzMDA0NTBlMDdi',
|
264
|
+
uuid: 'test'
|
265
|
+
)
|
266
|
+
|
267
|
+
VCR.use_cassette('lib/signatures/where_now', record: :once) do
|
268
|
+
envelope = pubnub.where_now(
|
269
|
+
uuid: 'a!@#$%^&()ŻÓŁ[]{}""<>??~`Z',
|
270
|
+
http_sync: true
|
271
|
+
)
|
272
|
+
|
273
|
+
expect(envelope.status[:code]).to eq 200
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|