pubnub 4.0.19 → 4.0.20
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 +30 -1
- data/.rubocop.yml +4 -1
- data/.travis.yml +7 -8
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/VERSION +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/1.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/101.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/103.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/105.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/107.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/109.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/11.yml +4 -4
- data/fixtures/vcr_cassettes/examples/subscribe/111.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/113.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/115.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/117.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/119.yml +2 -2
- data/fixtures/vcr_cassettes/examples/subscribe/121.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/123.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/125.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/127.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/129.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/13.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/131.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/133.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/135.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/137.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/139.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/141.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/143.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/145.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/147.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/149.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/15.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/151.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/153.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/155.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/157.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/159.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/161.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/163.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/165.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/167.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/169.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/17.yml +3 -3
- data/fixtures/vcr_cassettes/examples/subscribe/171.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/173.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/175.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/177.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/179.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/181.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/183.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/185.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/187.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/189.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/19.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/191.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/193.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/195.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/197.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/199.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/201.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/203.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/205.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/207.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/209.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/21.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/211.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/213.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/215.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/217.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/219.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/221.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/223.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/225.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/227.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/229.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/23.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/231.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/233.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/235.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/237.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/239.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/241.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/243.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/245.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/247.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/249.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/25.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/251.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/253.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/255.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/257.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/259.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/261.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/263.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/265.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/267.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/269.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/27.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/271.yml +2 -2
- data/fixtures/vcr_cassettes/examples/subscribe/273.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/275.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/277.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/279.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/281.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/283.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/285.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/287.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/289.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/29.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/291.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/293.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/295.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/297.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/299.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/3.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/301.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/303.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/305.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/307.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/309.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/31.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/311.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/313.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/315.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/317.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/319.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/321.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/323.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/325.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/327.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/329.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/33.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/331.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/333.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/335.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/337.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/339.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/341.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/343.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/345.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/347.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/349.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/35.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/351.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/353.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/355.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/357.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/359.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/361.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/363.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/365.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/367.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/369.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/37.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/371.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/379.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/381.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/383.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/385.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/387.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/389.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/39.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/397.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/399.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/401.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/403.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/405.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/407.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/41.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/415.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/417.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/419.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/421.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/423.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/425.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/43.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/433.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/435.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/437.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/439.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/441.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/443.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/45.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/47.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/49.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/5.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/51.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/53.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/55.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/57.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/59.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/61.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/63.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/65.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/67.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/69.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/7.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/71.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/73.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/75.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/77.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/79.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/81.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/83.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/85.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/87.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/89.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/9.yml +2 -2
- data/fixtures/vcr_cassettes/examples/subscribe/91.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/93.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/95.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/97.yml +1 -1
- data/fixtures/vcr_cassettes/examples/subscribe/99.yml +1 -1
- data/fixtures/vcr_cassettes/lib/callable_cipher_key.yml +78 -0
- data/fixtures/vcr_cassettes/lib/events/heartbeat-sub.yml +46 -3
- data/fixtures/vcr_cassettes/lib/events/presence_delta.yml +193 -0
- data/fixtures/vcr_cassettes/lib/multiple_ciphers.yml +188 -0
- data/fixtures/vcr_cassettes/lib/multiple_ciphers_history.yml +163 -0
- data/lib/pubnub/client/getters_setters.rb +127 -0
- data/lib/pubnub/client.rb +3 -112
- data/lib/pubnub/configuration.rb +1 -1
- data/lib/pubnub/constants.rb +5 -2
- data/lib/pubnub/crypto.rb +5 -5
- data/lib/pubnub/event/formatter.rb +45 -0
- data/lib/pubnub/event/signature.rb +41 -0
- data/lib/pubnub/event.rb +41 -97
- data/lib/pubnub/events/history.rb +4 -3
- data/lib/pubnub/events/publish.rb +37 -37
- data/lib/pubnub/formatter.rb +1 -1
- data/lib/pubnub/pam.rb +9 -9
- data/lib/pubnub/single_event.rb +1 -1
- data/lib/pubnub/subscribe_event/formatter.rb +4 -4
- data/lib/pubnub/subscriber.rb +28 -28
- data/lib/pubnub/validators/client.rb +1 -1
- data/lib/pubnub/validators/common_validator.rb +2 -2
- data/lib/pubnub/version.rb +1 -1
- data/pubnub.gemspec +0 -2
- data/spec/examples/presence_examples_spec.rb +2 -1
- data/spec/examples/subscribe_examples_spec.rb +1080 -1080
- data/spec/lib/client_spec.rb +5 -5
- data/spec/lib/events/presence_delta_spec.rb +38 -0
- data/spec/lib/multiple_ciphers_spec.rb +145 -0
- data/spec/spec_helper.rb +2 -2
- metadata +15 -7
data/spec/lib/client_spec.rb
CHANGED
@@ -72,19 +72,19 @@ describe Pubnub::Client do
|
|
72
72
|
context 'validates' do
|
73
73
|
context 'parameter :origin' do
|
74
74
|
it 'must be valid' do
|
75
|
-
expect { Pubnub.new(
|
75
|
+
expect { Pubnub.new(origin: 123, subscribe_key: 'key') }
|
76
76
|
.to raise_error(Pubnub::InitializationError)
|
77
77
|
|
78
|
-
expect { Pubnub.new(
|
78
|
+
expect { Pubnub.new(origin: { a: :b }, subscribe_key: 'key') }
|
79
79
|
.to raise_error(Pubnub::InitializationError)
|
80
80
|
|
81
|
-
expect { Pubnub.new(
|
81
|
+
expect { Pubnub.new(origin: nil, subscribe_key: 'key') }
|
82
82
|
.not_to raise_error
|
83
83
|
|
84
|
-
expect { Pubnub.new(
|
84
|
+
expect { Pubnub.new(origin: '', subscribe_key: 'key') }
|
85
85
|
.not_to raise_error
|
86
86
|
|
87
|
-
expect { Pubnub.new(
|
87
|
+
expect { Pubnub.new(origin: 'http://a.com', subscribe_key: 'key') }
|
88
88
|
.not_to raise_error
|
89
89
|
end
|
90
90
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pubnub::Presence do
|
4
|
+
around :each do |example|
|
5
|
+
Celluloid.boot
|
6
|
+
example.run
|
7
|
+
Celluloid.shutdown
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'with interval events and delta' do
|
11
|
+
before :each do
|
12
|
+
@messages = []
|
13
|
+
@statuses = []
|
14
|
+
|
15
|
+
@callbacks = Pubnub::SubscribeCallback.new(
|
16
|
+
message: ->(_envelope) { },
|
17
|
+
presence: ->(envelope) { @messages << envelope },
|
18
|
+
status: ->(envelope) { @statuses << envelope }
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'works' do
|
23
|
+
pubnub = Pubnub.new(subscribe_key: 'sub-c-9fb06248-0a21-11e7-91d0-02ee2ddab7fe', publish_key: 'pub-c-7a6fa2a4-a4c4-4eb4-9a21-a3334d38209d', uuid: '')
|
24
|
+
pubnub.add_listener(callback: @callbacks)
|
25
|
+
|
26
|
+
VCR.use_cassette('lib/events/presence_delta', record: :once) do
|
27
|
+
pubnub.presence(channel: :demo)
|
28
|
+
|
29
|
+
eventually do
|
30
|
+
expect(@messages[0].result[:data]).to eq({:message=>{"action"=>"interval", "timestamp"=>1490958575, "occupancy"=>3}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14909585750910131", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"interval", :presence=>{:uuid=>nil, :timestamp=>1490958575, :state=>nil, :occupancy=>3}})
|
31
|
+
expect(@messages[1].result[:data]).to eq({:message=>{"action"=>"interval", "timestamp"=>1490958585, "occupancy"=>4, "join"=>["Client-d39lr"]}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14909585850925693", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"interval", :presence=>{:uuid=>nil, :timestamp=>1490958585, :state=>nil, :occupancy=>4}})
|
32
|
+
expect(@messages[2].result[:data]).to eq({:message=>{"action"=>"interval", "timestamp"=>1490958595, "occupancy"=>3, "leave"=>["another-client"]}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14909585950916556", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"interval", :presence=>{:uuid=>nil, :timestamp=>1490958595, :state=>nil, :occupancy=>3}})
|
33
|
+
expect(@messages[3].result[:data]).to eq({:message=>{"action"=>"interval", "timestamp"=>1490958605, "occupancy"=>2, "join"=>["another-client"], "leave"=>["Client-d39lr", "client0"]}, :subscribed_channel=>"demo-pnpres", :actual_channel=>"demo-pnpres", :publish_time_object=>{:timetoken=>"14909586050915528", :region_code=>1}, :message_meta_data=>nil, :presence_event=>"interval", :presence=>{:uuid=>nil, :timestamp=>1490958605, :state=>nil, :occupancy=>2}})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Using multiple cipher keys' do
|
4
|
+
|
5
|
+
around :each do |example|
|
6
|
+
Celluloid.boot
|
7
|
+
example.run
|
8
|
+
Celluloid.shutdown
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'works with publish' do
|
12
|
+
@pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: 'this_doesnt_fit_anywhere')
|
13
|
+
|
14
|
+
VCR.use_cassette('lib/multiple_ciphers', record: :once) do
|
15
|
+
# Fetch current timestamp
|
16
|
+
@pubnub.subscribe(channel: :multiple_cipher_test, http_sync: true)
|
17
|
+
|
18
|
+
@pubnub.publish(
|
19
|
+
channel: :multiple_cipher_test,
|
20
|
+
message: 'Some test message',
|
21
|
+
cipher_key: 'super_secret',
|
22
|
+
http_sync: true
|
23
|
+
)
|
24
|
+
|
25
|
+
e0 = @pubnub.subscribe(
|
26
|
+
channel: :multiple_cipher_test,
|
27
|
+
cipher_key: 'super_secret',
|
28
|
+
http_sync: true
|
29
|
+
).first
|
30
|
+
|
31
|
+
@pubnub.publish(
|
32
|
+
channel: :multiple_cipher_test,
|
33
|
+
message: 'Another test message',
|
34
|
+
cipher_key: 'another_secret',
|
35
|
+
http_sync: true
|
36
|
+
)
|
37
|
+
|
38
|
+
e1 = @pubnub.subscribe(
|
39
|
+
channel: :multiple_cipher_test,
|
40
|
+
cipher_key: 'another_secret',
|
41
|
+
http_sync: true
|
42
|
+
).first
|
43
|
+
|
44
|
+
expect(e0.result[:data][:message]).to eq 'Some test message'
|
45
|
+
expect(e1.result[:data][:message]).to eq 'Another test message'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'works with history' do
|
50
|
+
@pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: 'this_doesnt_fit_anywhere')
|
51
|
+
|
52
|
+
VCR.use_cassette('lib/multiple_ciphers_history', record: :once) do
|
53
|
+
@pubnub.publish(
|
54
|
+
channel: :multiple_cipher_test,
|
55
|
+
message: 'Some test message',
|
56
|
+
cipher_key: 'super_secret',
|
57
|
+
http_sync: true
|
58
|
+
)
|
59
|
+
|
60
|
+
e0 = @pubnub.history(
|
61
|
+
channel: :multiple_cipher_test,
|
62
|
+
cipher_key: 'super_secret',
|
63
|
+
count: 1,
|
64
|
+
http_sync: true
|
65
|
+
)
|
66
|
+
|
67
|
+
@pubnub.publish(
|
68
|
+
channel: :multiple_cipher_test,
|
69
|
+
message: 'Another test message',
|
70
|
+
cipher_key: 'another_secret',
|
71
|
+
http_sync: true
|
72
|
+
)
|
73
|
+
|
74
|
+
e1 = @pubnub.history(
|
75
|
+
channel: :multiple_cipher_test,
|
76
|
+
cipher_key: 'another_secret',
|
77
|
+
count: 1,
|
78
|
+
http_sync: true
|
79
|
+
)
|
80
|
+
|
81
|
+
expect(e0.result[:data][:messages].first).to eq 'Some test message'
|
82
|
+
expect(e1.result[:data][:messages].first).to eq 'Another test message'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'works with async history' do
|
87
|
+
@pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key: 'this_doesnt_fit_anywhere')
|
88
|
+
|
89
|
+
VCR.use_cassette('lib/multiple_ciphers_history', record: :once) do
|
90
|
+
@pubnub.publish(
|
91
|
+
channel: :multiple_cipher_test,
|
92
|
+
message: 'Some test message',
|
93
|
+
cipher_key: 'super_secret',
|
94
|
+
http_sync: true
|
95
|
+
)
|
96
|
+
|
97
|
+
e0 = @pubnub.history(
|
98
|
+
channel: :multiple_cipher_test,
|
99
|
+
cipher_key: 'super_secret',
|
100
|
+
count: 1
|
101
|
+
).value
|
102
|
+
|
103
|
+
@pubnub.publish(
|
104
|
+
channel: :multiple_cipher_test,
|
105
|
+
message: 'Another test message',
|
106
|
+
cipher_key: 'another_secret',
|
107
|
+
http_sync: true
|
108
|
+
)
|
109
|
+
|
110
|
+
e1 = @pubnub.history(
|
111
|
+
channel: :multiple_cipher_test,
|
112
|
+
cipher_key: 'another_secret',
|
113
|
+
count: 1
|
114
|
+
).value
|
115
|
+
|
116
|
+
expect(e0.result[:data][:messages].first).to eq 'Some test message'
|
117
|
+
expect(e1.result[:data][:messages].first).to eq 'Another test message'
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'works with asynchronous subscribe and callable cipher key argument' do
|
122
|
+
@message = nil
|
123
|
+
cb = Pubnub::SubscribeCallback.new(
|
124
|
+
message: ->(envelope){ @message = envelope.result[:data][:message] }
|
125
|
+
)
|
126
|
+
|
127
|
+
ciphers = {
|
128
|
+
'some-uuid' => 'secret'
|
129
|
+
}
|
130
|
+
|
131
|
+
lambda_cipher_key = ->(data) do
|
132
|
+
ciphers[data[:issuing_client_id]]
|
133
|
+
end
|
134
|
+
|
135
|
+
@pubnub = Pubnub.new(subscribe_key: :demo, publish_key: :demo, cipher_key_selector: lambda_cipher_key)
|
136
|
+
@pubnub.add_listener(callback: cb)
|
137
|
+
|
138
|
+
VCR.use_cassette('lib/callable_cipher_key', record: :once) do
|
139
|
+
@pubnub.subscribe(channel: :multiple_cipher_test)
|
140
|
+
sleep(1)
|
141
|
+
expect(@message).to eq('hello ruby!')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -26,7 +26,7 @@ Celluloid.task_class = Celluloid::Task::Threaded
|
|
26
26
|
# AsyncHelper allows us to wait for async operations
|
27
27
|
module AsyncHelper
|
28
28
|
def eventually(options = {})
|
29
|
-
timeout = options[:timeout] ||
|
29
|
+
timeout = options[:timeout] || 30
|
30
30
|
interval = options[:interval] || 0.1
|
31
31
|
time_limit = Time.now + timeout
|
32
32
|
loop_it(interval, time_limit) do yield end
|
@@ -73,6 +73,6 @@ VCR.configure do |c|
|
|
73
73
|
c.ignore_hosts 'api.codacy.com'
|
74
74
|
c.default_cassette_options = {
|
75
75
|
match_requests_on: [:method,
|
76
|
-
VCR.request_matchers.uri_without_param(:pnsdk, :uuid, :ortt, :seqn)]
|
76
|
+
VCR.request_matchers.uri_without_param(:pnsdk, :uuid, :ortt, :seqn, :t)]
|
77
77
|
}
|
78
78
|
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.0.
|
4
|
+
version: 4.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|
@@ -10435,6 +10435,7 @@ files:
|
|
10435
10435
|
- fixtures/vcr_cassettes/examples/where_now/4.yml
|
10436
10436
|
- fixtures/vcr_cassettes/examples/where_now/5.yml
|
10437
10437
|
- fixtures/vcr_cassettes/integration/publish/publish-store-replicate.yml
|
10438
|
+
- fixtures/vcr_cassettes/lib/callable_cipher_key.yml
|
10438
10439
|
- fixtures/vcr_cassettes/lib/events/audit-error.yml
|
10439
10440
|
- fixtures/vcr_cassettes/lib/events/audit-json-error.yml
|
10440
10441
|
- fixtures/vcr_cassettes/lib/events/audit-works.yml
|
@@ -10455,6 +10456,7 @@ files:
|
|
10455
10456
|
- fixtures/vcr_cassettes/lib/events/presence-async.yml
|
10456
10457
|
- fixtures/vcr_cassettes/lib/events/presence-sync-error.yml
|
10457
10458
|
- fixtures/vcr_cassettes/lib/events/presence-sync.yml
|
10459
|
+
- fixtures/vcr_cassettes/lib/events/presence_delta.yml
|
10458
10460
|
- fixtures/vcr_cassettes/lib/events/publish-error.yml
|
10459
10461
|
- fixtures/vcr_cassettes/lib/events/publish.yml
|
10460
10462
|
- fixtures/vcr_cassettes/lib/events/revoke-error.yml
|
@@ -10473,6 +10475,8 @@ files:
|
|
10473
10475
|
- fixtures/vcr_cassettes/lib/events/time.yml
|
10474
10476
|
- fixtures/vcr_cassettes/lib/events/where-now-error.yml
|
10475
10477
|
- fixtures/vcr_cassettes/lib/events/where-now.yml
|
10478
|
+
- fixtures/vcr_cassettes/lib/multiple_ciphers.yml
|
10479
|
+
- fixtures/vcr_cassettes/lib/multiple_ciphers_history.yml
|
10476
10480
|
- fixtures/vcr_cassettes/lib/ssl-error.yml
|
10477
10481
|
- fixtures/vcr_cassettes/lib/super_admin/cg.yml
|
10478
10482
|
- fixtures/vcr_cassettes/lib/super_admin/here_now.yml
|
@@ -10488,6 +10492,7 @@ files:
|
|
10488
10492
|
- lib/pubnub.rb
|
10489
10493
|
- lib/pubnub/client.rb
|
10490
10494
|
- lib/pubnub/client/events.rb
|
10495
|
+
- lib/pubnub/client/getters_setters.rb
|
10491
10496
|
- lib/pubnub/client/helpers.rb
|
10492
10497
|
- lib/pubnub/client/paged_history.rb
|
10493
10498
|
- lib/pubnub/configuration.rb
|
@@ -10497,6 +10502,8 @@ files:
|
|
10497
10502
|
- lib/pubnub/error.rb
|
10498
10503
|
- lib/pubnub/error_envelope.rb
|
10499
10504
|
- lib/pubnub/event.rb
|
10505
|
+
- lib/pubnub/event/formatter.rb
|
10506
|
+
- lib/pubnub/event/signature.rb
|
10500
10507
|
- lib/pubnub/events/audit.rb
|
10501
10508
|
- lib/pubnub/events/channel_registration.rb
|
10502
10509
|
- lib/pubnub/events/grant.rb
|
@@ -10575,6 +10582,7 @@ files:
|
|
10575
10582
|
- spec/lib/events/here_now_spec.rb
|
10576
10583
|
- spec/lib/events/history_spec.rb
|
10577
10584
|
- spec/lib/events/leave_spec.rb
|
10585
|
+
- spec/lib/events/presence_delta_spec.rb
|
10578
10586
|
- spec/lib/events/presence_spec.rb
|
10579
10587
|
- spec/lib/events/publish_spec.rb
|
10580
10588
|
- spec/lib/events/revoke_spec.rb
|
@@ -10583,6 +10591,7 @@ files:
|
|
10583
10591
|
- spec/lib/events/time_spec.rb
|
10584
10592
|
- spec/lib/events/timeout_handling_spec.rb
|
10585
10593
|
- spec/lib/events/where_now_spec.rb
|
10594
|
+
- spec/lib/multiple_ciphers_spec.rb
|
10586
10595
|
- spec/lib/pubnub_spec.rb
|
10587
10596
|
- spec/lib/ssl_error_spec.rb
|
10588
10597
|
- spec/lib/super_admin_spec.rb
|
@@ -10593,10 +10602,7 @@ homepage: http://github.com/pubnub/ruby
|
|
10593
10602
|
licenses:
|
10594
10603
|
- MIT
|
10595
10604
|
metadata: {}
|
10596
|
-
post_install_message:
|
10597
|
-
-----
|
10598
|
-
UPGRADE NOTICE: Pubnub 3.8.0 and higher versions are using Celluloid instead of EventMachine for asynchronous processing.
|
10599
|
-
-----
|
10605
|
+
post_install_message:
|
10600
10606
|
rdoc_options: []
|
10601
10607
|
require_paths:
|
10602
10608
|
- lib
|
@@ -10612,7 +10618,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
10612
10618
|
version: '0'
|
10613
10619
|
requirements: []
|
10614
10620
|
rubyforge_project:
|
10615
|
-
rubygems_version: 2.
|
10621
|
+
rubygems_version: 2.6.11
|
10616
10622
|
signing_key:
|
10617
10623
|
specification_version: 4
|
10618
10624
|
summary: PubNub Official Ruby gem.
|
@@ -10645,6 +10651,7 @@ test_files:
|
|
10645
10651
|
- spec/lib/events/here_now_spec.rb
|
10646
10652
|
- spec/lib/events/history_spec.rb
|
10647
10653
|
- spec/lib/events/leave_spec.rb
|
10654
|
+
- spec/lib/events/presence_delta_spec.rb
|
10648
10655
|
- spec/lib/events/presence_spec.rb
|
10649
10656
|
- spec/lib/events/publish_spec.rb
|
10650
10657
|
- spec/lib/events/revoke_spec.rb
|
@@ -10653,6 +10660,7 @@ test_files:
|
|
10653
10660
|
- spec/lib/events/time_spec.rb
|
10654
10661
|
- spec/lib/events/timeout_handling_spec.rb
|
10655
10662
|
- spec/lib/events/where_now_spec.rb
|
10663
|
+
- spec/lib/multiple_ciphers_spec.rb
|
10656
10664
|
- spec/lib/pubnub_spec.rb
|
10657
10665
|
- spec/lib/ssl_error_spec.rb
|
10658
10666
|
- spec/lib/super_admin_spec.rb
|