pubnub 4.5.0 → 4.6.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.

Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.pubnub.yml +53 -37
  3. data/CHANGELOG.md +10 -0
  4. data/Gemfile.lock +1 -1
  5. data/VERSION +1 -1
  6. data/fixtures/vcr_cassettes/examples/channel_members/001.yml +111 -0
  7. data/fixtures/vcr_cassettes/examples/channel_members/002.yml +111 -0
  8. data/fixtures/vcr_cassettes/examples/channel_members/003.yml +111 -0
  9. data/fixtures/vcr_cassettes/examples/channel_members/004.yml +147 -0
  10. data/fixtures/vcr_cassettes/examples/channel_members/005.yml +147 -0
  11. data/fixtures/vcr_cassettes/examples/channel_members/006.yml +147 -0
  12. data/fixtures/vcr_cassettes/examples/channel_metadata/001.yml +39 -0
  13. data/fixtures/vcr_cassettes/examples/channel_metadata/002.yml +39 -0
  14. data/fixtures/vcr_cassettes/examples/channel_metadata/003.yml +39 -0
  15. data/fixtures/vcr_cassettes/examples/channel_metadata/004.yml +73 -0
  16. data/fixtures/vcr_cassettes/examples/channel_metadata/005.yml +73 -0
  17. data/fixtures/vcr_cassettes/examples/channel_metadata/006.yml +73 -0
  18. data/fixtures/vcr_cassettes/examples/history/include_meta__encrypted.yml +7 -7
  19. data/fixtures/vcr_cassettes/examples/history/include_meta__encrypted_random_iv.yml +46 -0
  20. data/fixtures/vcr_cassettes/examples/history/include_token__encrypted.yml +6 -6
  21. data/fixtures/vcr_cassettes/examples/history/include_token__encrypted_random_iv.yml +46 -0
  22. data/fixtures/vcr_cassettes/examples/history/no_includes__encrypted.yml +6 -6
  23. data/fixtures/vcr_cassettes/examples/history/no_includes__encrypted_random_iv.yml +45 -0
  24. data/fixtures/vcr_cassettes/examples/memberships/001.yml +111 -0
  25. data/fixtures/vcr_cassettes/examples/memberships/002.yml +111 -0
  26. data/fixtures/vcr_cassettes/examples/memberships/003.yml +111 -0
  27. data/fixtures/vcr_cassettes/examples/memberships/004.yml +111 -0
  28. data/fixtures/vcr_cassettes/examples/memberships/005.yml +147 -0
  29. data/fixtures/vcr_cassettes/examples/memberships/006.yml +147 -0
  30. data/fixtures/vcr_cassettes/examples/memberships/007.yml +147 -0
  31. data/fixtures/vcr_cassettes/examples/memberships/008.yml +147 -0
  32. data/fixtures/vcr_cassettes/examples/uuid_metadata/001.yml +39 -0
  33. data/fixtures/vcr_cassettes/examples/uuid_metadata/002.yml +39 -0
  34. data/fixtures/vcr_cassettes/examples/uuid_metadata/003.yml +39 -0
  35. data/fixtures/vcr_cassettes/examples/uuid_metadata/004.yml +39 -0
  36. data/fixtures/vcr_cassettes/examples/uuid_metadata/005.yml +73 -0
  37. data/fixtures/vcr_cassettes/examples/uuid_metadata/006.yml +73 -0
  38. data/fixtures/vcr_cassettes/examples/uuid_metadata/007.yml +73 -0
  39. data/fixtures/vcr_cassettes/examples/uuid_metadata/008.yml +73 -0
  40. data/lib/pubnub/client.rb +4 -1
  41. data/lib/pubnub/client/helpers.rb +1 -1
  42. data/lib/pubnub/configuration.rb +1 -0
  43. data/lib/pubnub/constants.rb +1 -0
  44. data/lib/pubnub/crypto.rb +22 -8
  45. data/lib/pubnub/event.rb +7 -1
  46. data/lib/pubnub/events/history.rb +2 -1
  47. data/lib/pubnub/events/publish.rb +2 -2
  48. data/lib/pubnub/events/remove_channel_members.rb +1 -1
  49. data/lib/pubnub/events/remove_channel_metadata.rb +1 -1
  50. data/lib/pubnub/events/remove_memberships.rb +1 -1
  51. data/lib/pubnub/events/remove_uuid_metadata.rb +1 -1
  52. data/lib/pubnub/events/set_channel_members.rb +1 -1
  53. data/lib/pubnub/events/set_channel_metadata.rb +1 -1
  54. data/lib/pubnub/events/set_memberships.rb +1 -1
  55. data/lib/pubnub/events/set_uuid_metadata.rb +1 -1
  56. data/lib/pubnub/events/signal.rb +1 -1
  57. data/lib/pubnub/formatter.rb +3 -3
  58. data/lib/pubnub/subscribe_event/formatter.rb +4 -2
  59. data/lib/pubnub/version.rb +1 -1
  60. data/spec/examples/history_examples_spec.rb +87 -9
  61. data/spec/examples/publish_examples_spec.rb +864 -0
  62. data/spec/examples/remove_channel_members_examples_spec.rb +100 -0
  63. data/spec/examples/remove_channel_metadata_examples_spec.rb +89 -0
  64. data/spec/examples/remove_memberships_examples_spec.rb +121 -0
  65. data/spec/examples/remove_uuid_metadata_examples_spec.rb +107 -0
  66. data/spec/examples/set_channel_members_examples_spec.rb +99 -0
  67. data/spec/examples/set_channel_metadata_examples_spec.rb +93 -0
  68. data/spec/examples/set_memberships_examples_spec.rb +122 -0
  69. data/spec/examples/set_uuid_metadata_examples_spec.rb +114 -0
  70. data/spec/examples/subscribe_examples_1_spec.rb +2 -2
  71. data/spec/examples/subscribe_examples_2_spec.rb +4 -4
  72. data/spec/lib/events/subscribe_spec.rb +2 -0
  73. data/spec/lib/multiple_ciphers_spec.rb +16 -4
  74. data/spec/spec_helper.rb +1 -1
  75. metadata +50 -3
@@ -0,0 +1,100 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::HereNow do
4
+ around :each do |example|
5
+ @fired = false
6
+
7
+ @callback = -> (_envelope) do
8
+ @fired = true
9
+ end
10
+
11
+ @pubnub = Pubnub.new(
12
+ publish_key: "pub-a-mock-key",
13
+ subscribe_key: 'sub-a-mock-key',
14
+ uuid: "ruby-test-uuid-client-one",
15
+ auth_key: "ruby-test-auth-client-one",
16
+ random_iv: false
17
+ )
18
+
19
+ example.run_with_retry retry: 10
20
+ end
21
+
22
+ it "__channel__channel___uuids__ruby-test-uuid-client-one___include__count___http_sync__true___cipher_key__nil___random_iv__false___callback__nil_" do
23
+ VCR.use_cassette("examples/channel_members/004", record: :once) do
24
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
25
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
26
+ @pubnub.set_channel_members(channel: 'channel', uuids: [{ uuid: 'ruby-test-uuid-client-one' }], http_sync: true)
27
+ envelope = @pubnub.remove_channel_members(
28
+ channel: 'channel',
29
+ uuids: ['ruby-test-uuid-client-one'],
30
+ include: { count: true },
31
+ http_sync: true
32
+ )
33
+
34
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
35
+ expect(envelope.error?).to eq false
36
+ expect(@pubnub.env[:random_iv]).to eq false
37
+
38
+ expect(envelope.status[:code]).to eq(200)
39
+ expect(envelope.status[:operation]).to eq(:remove_channel_members)
40
+ expect(envelope.status[:category]).to eq(:ack)
41
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel")
42
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
43
+ end
44
+ end
45
+
46
+ it "__channel__channel___uuids__bob___include__nil___http_sync__true___cipher_key__enigma___random_iv__false___callback__nil_" do
47
+ VCR.use_cassette("examples/channel_members/005", record: :once) do
48
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
49
+ @pubnub.set_uuid_metadata(uuid: 'bob', metadata: { name: 'magnum' }, http_sync: true)
50
+ @pubnub.set_channel_members(channel: 'channel', uuids: [{ uuid: 'bob' }], http_sync: true)
51
+ pubnub = Pubnub.new(
52
+ publish_key: "pub-a-mock-key",
53
+ subscribe_key: 'sub-a-mock-key',
54
+ uuid: "ruby-test-uuid-client-one",
55
+ auth_key: "ruby-test-auth-client-one",
56
+ random_iv: false,
57
+ cipher_key: "enigma"
58
+ )
59
+
60
+ envelope = pubnub.remove_channel_members(channel: 'channel', uuids: ['bob'], http_sync: true)
61
+
62
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
63
+ expect(envelope.error?).to eq false
64
+ expect(pubnub.env[:random_iv]).to eq false
65
+
66
+ expect(envelope.status[:code]).to eq(200)
67
+ expect(envelope.status[:operation]).to eq(:remove_channel_members)
68
+ expect(envelope.status[:category]).to eq(:ack)
69
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel")
70
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
71
+ end
72
+ end
73
+
74
+ it "__channel__channel___uuids__bob___http_sync__true___cipher_key__enigma___random_iv__true___callback__nil_" do
75
+ VCR.use_cassette("examples/channel_members/006", record: :once) do
76
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
77
+ @pubnub.set_uuid_metadata(uuid: 'bob', metadata: { name: 'magnum' }, http_sync: true)
78
+ @pubnub.set_channel_members(channel: 'channel', uuids: [{ uuid: 'bob' }], http_sync: true)
79
+ pubnub = Pubnub.new(
80
+ publish_key: "pub-a-mock-key",
81
+ subscribe_key: 'sub-a-mock-key',
82
+ uuid: "ruby-test-uuid-client-one",
83
+ auth_key: "ruby-test-auth-client-one",
84
+ cipher_key: "enigma"
85
+ )
86
+
87
+ envelope = pubnub.remove_channel_members(channel: 'channel', uuids: ['bob'], http_sync: true)
88
+
89
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
90
+ expect(envelope.error?).to eq false
91
+ expect(pubnub.env[:random_iv]).to eq true
92
+
93
+ expect(envelope.status[:code]).to eq(200)
94
+ expect(envelope.status[:operation]).to eq(:remove_channel_members)
95
+ expect(envelope.status[:category]).to eq(:ack)
96
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel")
97
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,89 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::HereNow do
4
+ around :each do |example|
5
+ @fired = false
6
+
7
+ @callback = -> (_envelope) do
8
+ @fired = true
9
+ end
10
+
11
+ @pubnub = Pubnub.new(
12
+ publish_key: "pub-a-mock-key",
13
+ subscribe_key: 'sub-a-mock-key',
14
+ uuid: "ruby-test-uuid-client-one",
15
+ auth_key: "ruby-test-auth-client-one",
16
+ random_iv: false
17
+ )
18
+
19
+ example.run_with_retry retry: 10
20
+ end
21
+
22
+ it "__channel__channel___http_sync__true___cipher_key__nil___random_iv__false___callback__nil_" do
23
+ VCR.use_cassette("examples/channel_metadata/004", record: :once) do
24
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
25
+ envelope = @pubnub.remove_channel_metadata(channel: 'channel', http_sync: true)
26
+
27
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
28
+ expect(envelope.error?).to eq false
29
+ expect(@pubnub.env[:random_iv]).to eq false
30
+
31
+ expect(envelope.status[:code]).to eq(200)
32
+ expect(envelope.status[:operation]).to eq(:remove_channel_metadata)
33
+ expect(envelope.status[:category]).to eq(:ack)
34
+ expect(envelope.status[:client_request].path.split('/').last).to eq("channel")
35
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
36
+ end
37
+ end
38
+
39
+ it "__channel__channel___http_sync__true___cipher_key__enigma___random_iv__false___callback__nil_" do
40
+ VCR.use_cassette("examples/channel_metadata/005", record: :once) do
41
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
42
+ pubnub = Pubnub.new(
43
+ publish_key: "pub-a-mock-key",
44
+ subscribe_key: 'sub-a-mock-key',
45
+ uuid: "ruby-test-uuid-client-one",
46
+ auth_key: "ruby-test-auth-client-one",
47
+ random_iv: false,
48
+ cipher_key: "enigma"
49
+ )
50
+
51
+ envelope = pubnub.remove_channel_metadata(channel: 'channel', http_sync: true)
52
+
53
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
54
+ expect(envelope.error?).to eq false
55
+ expect(pubnub.env[:random_iv]).to eq false
56
+
57
+ expect(envelope.status[:code]).to eq(200)
58
+ expect(envelope.status[:operation]).to eq(:remove_channel_metadata)
59
+ expect(envelope.status[:category]).to eq(:ack)
60
+ expect(envelope.status[:client_request].path.split('/').last).to eq("channel")
61
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
62
+ end
63
+ end
64
+
65
+ it "__channel__channel___http_sync__true___cipher_key__enigma___random_iv__true___callback__nil_" do
66
+ VCR.use_cassette("examples/channel_metadata/006", record: :once) do
67
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
68
+ pubnub = Pubnub.new(
69
+ publish_key: "pub-a-mock-key",
70
+ subscribe_key: 'sub-a-mock-key',
71
+ uuid: "ruby-test-uuid-client-one",
72
+ auth_key: "ruby-test-auth-client-one",
73
+ cipher_key: "enigma"
74
+ )
75
+
76
+ envelope = pubnub.remove_channel_metadata(channel: 'channel', http_sync: true)
77
+
78
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
79
+ expect(envelope.error?).to eq false
80
+ expect(pubnub.env[:random_iv]).to eq true
81
+
82
+ expect(envelope.status[:code]).to eq(200)
83
+ expect(envelope.status[:operation]).to eq(:remove_channel_metadata)
84
+ expect(envelope.status[:category]).to eq(:ack)
85
+ expect(envelope.status[:client_request].path.split('/').last).to eq("channel")
86
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,121 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::HereNow do
4
+ around :each do |example|
5
+ @fired = false
6
+
7
+ @callback = -> (_envelope) do
8
+ @fired = true
9
+ end
10
+
11
+ @pubnub = Pubnub.new(
12
+ publish_key: "pub-a-mock-key",
13
+ subscribe_key: 'sub-a-mock-key',
14
+ uuid: "ruby-test-uuid-client-one",
15
+ auth_key: "ruby-test-auth-client-one",
16
+ random_iv: false
17
+ )
18
+
19
+ example.run_with_retry retry: 10
20
+ end
21
+
22
+ it "__uuid__nil___channels__channel___include__count___http_sync__true___cipher_key__nil___random_iv__false___callback__lambda_" do
23
+ VCR.use_cassette("examples/memberships/005", record: :once) do
24
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
25
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
26
+ @pubnub.set_memberships(uuid: nil, channels: [{ channel: 'channel' }], http_sync: true)
27
+ envelope = @pubnub.remove_memberships(
28
+ uuid: nil,
29
+ channels: ['channel'],
30
+ include: { count: true },
31
+ http_sync: true,
32
+ callback: @callback
33
+ )
34
+
35
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
36
+ expect(envelope.error?).to eq false
37
+ expect(@fired).to eq true
38
+ expect(@pubnub.env[:random_iv]).to eq false
39
+
40
+ expect(envelope.status[:code]).to eq(200)
41
+ expect(envelope.status[:operation]).to eq(:remove_memberships)
42
+ expect(envelope.status[:category]).to eq(:ack)
43
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("ruby-test-uuid-client-one")
44
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
45
+ end
46
+ end
47
+
48
+ it "__uuid__bob___channels__channel___include__count___http_sync__true___cipher_key__nil___random_iv__false___callback__nil_" do
49
+ VCR.use_cassette("examples/memberships/006", record: :once) do
50
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
51
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
52
+ @pubnub.set_memberships(uuid: nil, channels: [{ channel: 'channel' }], http_sync: true)
53
+ envelope = @pubnub.remove_memberships(uuid: 'bob', channels: ['channel'], include: { count: true }, http_sync: true)
54
+
55
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
56
+ expect(envelope.error?).to eq false
57
+ expect(@pubnub.env[:random_iv]).to eq false
58
+
59
+ expect(envelope.status[:code]).to eq(200)
60
+ expect(envelope.status[:operation]).to eq(:remove_memberships)
61
+ expect(envelope.status[:category]).to eq(:ack)
62
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob")
63
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
64
+ end
65
+ end
66
+
67
+ it "__uuid__bob___channels__channel___http_sync__true___cipher_key__enigma___random_iv__false___callback__nil_" do
68
+ VCR.use_cassette("examples/memberships/007", record: :once) do
69
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
70
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
71
+ @pubnub.set_memberships(uuid: nil, channels: [{ channel: 'channel' }], http_sync: true)
72
+ pubnub = Pubnub.new(
73
+ publish_key: "pub-a-mock-key",
74
+ subscribe_key: 'sub-a-mock-key',
75
+ uuid: "ruby-test-uuid-client-one",
76
+ auth_key: "ruby-test-auth-client-one",
77
+ random_iv: false,
78
+ cipher_key: "enigma"
79
+ )
80
+
81
+ envelope = pubnub.remove_memberships(uuid: 'bob', channels: ['channel'], http_sync: true)
82
+
83
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
84
+ expect(envelope.error?).to eq false
85
+ expect(pubnub.env[:random_iv]).to eq false
86
+
87
+ expect(envelope.status[:code]).to eq(200)
88
+ expect(envelope.status[:operation]).to eq(:remove_memberships)
89
+ expect(envelope.status[:category]).to eq(:ack)
90
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob")
91
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
92
+ end
93
+ end
94
+
95
+ it "__uuid__bob___channels__channel___http_sync__true___cipher_key__enigma___random_iv__true___callback__nil_" do
96
+ VCR.use_cassette("examples/memberships/008", record: :once) do
97
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
98
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
99
+ @pubnub.set_memberships(uuid: nil, channels: [{ channel: 'channel' }], http_sync: true)
100
+ pubnub = Pubnub.new(
101
+ publish_key: "pub-a-mock-key",
102
+ subscribe_key: 'sub-a-mock-key',
103
+ uuid: "ruby-test-uuid-client-one",
104
+ auth_key: "ruby-test-auth-client-one",
105
+ cipher_key: "enigma"
106
+ )
107
+
108
+ envelope = pubnub.remove_memberships(uuid: 'bob', channels: ['channel'], http_sync: true)
109
+
110
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
111
+ expect(envelope.error?).to eq false
112
+ expect(pubnub.env[:random_iv]).to eq true
113
+
114
+ expect(envelope.status[:code]).to eq(200)
115
+ expect(envelope.status[:operation]).to eq(:remove_memberships)
116
+ expect(envelope.status[:category]).to eq(:ack)
117
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("bob")
118
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,107 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::HereNow do
4
+ around :each do |example|
5
+ @fired = false
6
+
7
+ @callback = -> (_envelope) do
8
+ @fired = true
9
+ end
10
+
11
+ @pubnub = Pubnub.new(
12
+ publish_key: "pub-a-mock-key",
13
+ subscribe_key: 'sub-a-mock-key',
14
+ uuid: "ruby-test-uuid-client-one",
15
+ auth_key: "ruby-test-auth-client-one",
16
+ random_iv: false
17
+ )
18
+
19
+ example.run_with_retry retry: 10
20
+ end
21
+
22
+ it "__uuid__nil___http_sync__true___cipher_key__nil___random_iv__false___callback__lambda_" do
23
+ VCR.use_cassette("examples/uuid_metadata/005", record: :once) do
24
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
25
+ envelope = @pubnub.remove_uuid_metadata(uuid: nil, http_sync: true, callback: @callback)
26
+
27
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
28
+ expect(envelope.error?).to eq false
29
+ expect(@fired).to eq true
30
+ expect(@pubnub.env[:random_iv]).to eq false
31
+
32
+ expect(envelope.status[:code]).to eq(200)
33
+ expect(envelope.status[:operation]).to eq(:remove_uuid_metadata)
34
+ expect(envelope.status[:category]).to eq(:ack)
35
+ expect(envelope.status[:client_request].path.split('/').last).to eq("ruby-test-uuid-client-one")
36
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
37
+ end
38
+ end
39
+
40
+ it "__uuid__bob___http_sync__true___cipher_key__nil___random_iv__false___callback__nil_" do
41
+ VCR.use_cassette("examples/uuid_metadata/006", record: :once) do
42
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
43
+ envelope = @pubnub.remove_uuid_metadata(uuid: 'bob', http_sync: true)
44
+
45
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
46
+ expect(envelope.error?).to eq false
47
+ expect(@pubnub.env[:random_iv]).to eq false
48
+
49
+ expect(envelope.status[:code]).to eq(200)
50
+ expect(envelope.status[:operation]).to eq(:remove_uuid_metadata)
51
+ expect(envelope.status[:category]).to eq(:ack)
52
+ expect(envelope.status[:client_request].path.split('/').last).to eq("bob")
53
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
54
+ end
55
+ end
56
+
57
+ it "__uuid__bob___http_sync__true___cipher_key__enigma___random_iv__false___callback__nil_" do
58
+ VCR.use_cassette("examples/uuid_metadata/007", record: :once) do
59
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
60
+ pubnub = Pubnub.new(
61
+ publish_key: "pub-a-mock-key",
62
+ subscribe_key: 'sub-a-mock-key',
63
+ uuid: "ruby-test-uuid-client-one",
64
+ auth_key: "ruby-test-auth-client-one",
65
+ random_iv: false,
66
+ cipher_key: "enigma"
67
+ )
68
+
69
+ envelope = pubnub.remove_uuid_metadata(uuid: 'bob', http_sync: true)
70
+
71
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
72
+ expect(envelope.error?).to eq false
73
+ expect(pubnub.env[:random_iv]).to eq false
74
+
75
+ expect(envelope.status[:code]).to eq(200)
76
+ expect(envelope.status[:operation]).to eq(:remove_uuid_metadata)
77
+ expect(envelope.status[:category]).to eq(:ack)
78
+ expect(envelope.status[:client_request].path.split('/').last).to eq("bob")
79
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
80
+ end
81
+ end
82
+
83
+ it "__uuid__bob___http_sync__true___cipher_key__enigma___random_iv__true___callback__nil_" do
84
+ VCR.use_cassette("examples/uuid_metadata/008", record: :once) do
85
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, include: { custom: true }, http_sync: true)
86
+ pubnub = Pubnub.new(
87
+ publish_key: "pub-a-mock-key",
88
+ subscribe_key: 'sub-a-mock-key',
89
+ uuid: "ruby-test-uuid-client-one",
90
+ auth_key: "ruby-test-auth-client-one",
91
+ cipher_key: "enigma"
92
+ )
93
+
94
+ envelope = pubnub.remove_uuid_metadata(uuid: 'bob', http_sync: true)
95
+
96
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
97
+ expect(envelope.error?).to eq false
98
+ expect(pubnub.env[:random_iv]).to eq true
99
+
100
+ expect(envelope.status[:code]).to eq(200)
101
+ expect(envelope.status[:operation]).to eq(:remove_uuid_metadata)
102
+ expect(envelope.status[:category]).to eq(:ack)
103
+ expect(envelope.status[:client_request].path.split('/').last).to eq("bob")
104
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,99 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::HereNow do
4
+ around :each do |example|
5
+ @fired = false
6
+
7
+ @callback = -> (_envelope) do
8
+ @fired = true
9
+ end
10
+
11
+ @pubnub = Pubnub.new(
12
+ publish_key: "pub-a-mock-key",
13
+ subscribe_key: 'sub-a-mock-key',
14
+ uuid: "ruby-test-uuid-client-one",
15
+ auth_key: "ruby-test-auth-client-one",
16
+ random_iv: false
17
+ )
18
+
19
+ example.run_with_retry retry: 10
20
+ end
21
+
22
+ it "__channel__channel___uuids__uuid_ruby-test-uuid-client-one___include__count___http_sync__true___cipher_key__nil___random_iv__false___callback__lambda_" do
23
+ VCR.use_cassette("examples/channel_members/001", record: :once) do
24
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
25
+ @pubnub.set_uuid_metadata(uuid: nil, metadata: { name: 'magnum' }, http_sync: true)
26
+ envelope = @pubnub.set_channel_members(
27
+ channel: 'channel',
28
+ uuids: [{ uuid: 'ruby-test-uuid-client-one' }],
29
+ include: { count: true },
30
+ http_sync: true,
31
+ callback: @callback
32
+ )
33
+
34
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
35
+ expect(envelope.error?).to eq false
36
+ expect(@fired).to eq true
37
+ expect(@pubnub.env[:random_iv]).to eq false
38
+
39
+ expect(envelope.status[:code]).to eq(200)
40
+ expect(envelope.status[:operation]).to eq(:set_channel_members)
41
+ expect(envelope.status[:category]).to eq(:ack)
42
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel")
43
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
44
+ end
45
+ end
46
+
47
+ it "__channel__channel___uuids__bob___include__nil___http_sync__true___cipher_key__enigma___random_iv__false___callback__nil_" do
48
+ VCR.use_cassette("examples/channel_members/002", record: :once) do
49
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
50
+ @pubnub.set_uuid_metadata(uuid: 'bob', metadata: { name: 'magnum' }, http_sync: true)
51
+ pubnub = Pubnub.new(
52
+ publish_key: "pub-a-mock-key",
53
+ subscribe_key: 'sub-a-mock-key',
54
+ uuid: "ruby-test-uuid-client-one",
55
+ auth_key: "ruby-test-auth-client-one",
56
+ random_iv: false,
57
+ cipher_key: "enigma"
58
+ )
59
+
60
+ envelope = pubnub.set_channel_members(channel: 'channel', uuids: [{ uuid: 'bob' }], http_sync: true)
61
+
62
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
63
+ expect(envelope.error?).to eq false
64
+ expect(pubnub.env[:random_iv]).to eq false
65
+
66
+ expect(envelope.status[:code]).to eq(200)
67
+ expect(envelope.status[:operation]).to eq(:set_channel_members)
68
+ expect(envelope.status[:category]).to eq(:ack)
69
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel")
70
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
71
+ end
72
+ end
73
+
74
+ it "__channel__channel___uuids__uuid___include__nil___http_sync__true___cipher_key__enigma___random_iv__true___callback__nil_" do
75
+ VCR.use_cassette("examples/channel_members/003", record: :once) do
76
+ @pubnub.set_channel_metadata(channel: 'channel', metadata: { name: 'some_name' }, http_sync: true)
77
+ @pubnub.set_uuid_metadata(uuid: 'bob', metadata: { name: 'magnum' }, http_sync: true)
78
+ pubnub = Pubnub.new(
79
+ publish_key: "pub-a-mock-key",
80
+ subscribe_key: 'sub-a-mock-key',
81
+ uuid: "ruby-test-uuid-client-one",
82
+ auth_key: "ruby-test-auth-client-one",
83
+ cipher_key: "enigma"
84
+ )
85
+
86
+ envelope = pubnub.set_channel_members(channel: 'channel', uuids: [{ uuid: 'bob' }], http_sync: true)
87
+
88
+ expect(envelope.is_a?(Pubnub::Envelope)).to eq true
89
+ expect(envelope.error?).to eq false
90
+ expect(pubnub.env[:random_iv]).to eq true
91
+
92
+ expect(envelope.status[:code]).to eq(200)
93
+ expect(envelope.status[:operation]).to eq(:set_channel_members)
94
+ expect(envelope.status[:category]).to eq(:ack)
95
+ expect(envelope.status[:client_request].path.split('/')[-2]).to eq("channel")
96
+ expect(envelope.status[:config]).to eq({:tls => false, :uuid => "ruby-test-uuid-client-one", auth_key: "ruby-test-auth-client-one", :origin => "ps.pndsn.com"})
97
+ end
98
+ end
99
+ end