pubnub 4.2.6 → 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 (226) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.pubnub.yml +113 -56
  4. data/.travis.yml +4 -2
  5. data/CHANGELOG.md +39 -11
  6. data/Gemfile.lock +10 -1
  7. data/README.md +56 -17
  8. data/VERSION +1 -1
  9. data/fixtures/vcr_cassettes/examples/add_channels_to_push/001.yml +45 -0
  10. data/fixtures/vcr_cassettes/examples/add_channels_to_push/002.yml +45 -0
  11. data/fixtures/vcr_cassettes/examples/add_channels_to_push/003.yml +45 -0
  12. data/fixtures/vcr_cassettes/examples/add_channels_to_push/004.yml +45 -0
  13. data/fixtures/vcr_cassettes/examples/channel_members/001.yml +111 -0
  14. data/fixtures/vcr_cassettes/examples/channel_members/002.yml +111 -0
  15. data/fixtures/vcr_cassettes/examples/channel_members/003.yml +111 -0
  16. data/fixtures/vcr_cassettes/examples/channel_members/004.yml +147 -0
  17. data/fixtures/vcr_cassettes/examples/channel_members/005.yml +147 -0
  18. data/fixtures/vcr_cassettes/examples/channel_members/006.yml +147 -0
  19. data/fixtures/vcr_cassettes/examples/channel_metadata/001.yml +39 -0
  20. data/fixtures/vcr_cassettes/examples/channel_metadata/002.yml +39 -0
  21. data/fixtures/vcr_cassettes/examples/channel_metadata/003.yml +39 -0
  22. data/fixtures/vcr_cassettes/examples/channel_metadata/004.yml +73 -0
  23. data/fixtures/vcr_cassettes/examples/channel_metadata/005.yml +73 -0
  24. data/fixtures/vcr_cassettes/examples/channel_metadata/006.yml +73 -0
  25. data/fixtures/vcr_cassettes/examples/grant/1913.yml +1 -1
  26. data/fixtures/vcr_cassettes/examples/grant/1944.yml +8 -9
  27. data/fixtures/vcr_cassettes/examples/grant/1945.yml +359 -9
  28. data/fixtures/vcr_cassettes/examples/grant/1946.yml +8 -9
  29. data/fixtures/vcr_cassettes/examples/grant/1947.yml +8 -9
  30. data/fixtures/vcr_cassettes/examples/grant/1948.yml +8 -9
  31. data/fixtures/vcr_cassettes/examples/history/include_meta__encrypted.yml +7 -7
  32. data/fixtures/vcr_cassettes/examples/history/include_meta__encrypted_random_iv.yml +46 -0
  33. data/fixtures/vcr_cassettes/examples/history/include_token__encrypted.yml +6 -6
  34. data/fixtures/vcr_cassettes/examples/history/include_token__encrypted_random_iv.yml +46 -0
  35. data/fixtures/vcr_cassettes/examples/history/no_includes__encrypted.yml +6 -6
  36. data/fixtures/vcr_cassettes/examples/history/no_includes__encrypted_random_iv.yml +45 -0
  37. data/fixtures/vcr_cassettes/examples/list_push_provisions/001.yml +46 -0
  38. data/fixtures/vcr_cassettes/examples/list_push_provisions/002.yml +45 -0
  39. data/fixtures/vcr_cassettes/examples/list_push_provisions/003.yml +45 -0
  40. data/fixtures/vcr_cassettes/examples/memberships/001.yml +111 -0
  41. data/fixtures/vcr_cassettes/examples/memberships/002.yml +111 -0
  42. data/fixtures/vcr_cassettes/examples/memberships/003.yml +111 -0
  43. data/fixtures/vcr_cassettes/examples/memberships/004.yml +111 -0
  44. data/fixtures/vcr_cassettes/examples/memberships/005.yml +147 -0
  45. data/fixtures/vcr_cassettes/examples/memberships/006.yml +147 -0
  46. data/fixtures/vcr_cassettes/examples/memberships/007.yml +147 -0
  47. data/fixtures/vcr_cassettes/examples/memberships/008.yml +147 -0
  48. data/fixtures/vcr_cassettes/examples/remove_channels_from_push/001.yml +45 -0
  49. data/fixtures/vcr_cassettes/examples/remove_channels_from_push/002.yml +45 -0
  50. data/fixtures/vcr_cassettes/examples/remove_channels_from_push/003.yml +45 -0
  51. data/fixtures/vcr_cassettes/examples/remove_device_from_push/001.yml +45 -0
  52. data/fixtures/vcr_cassettes/examples/remove_device_from_push/002.yml +45 -0
  53. data/fixtures/vcr_cassettes/examples/remove_device_from_push/003.yml +45 -0
  54. data/fixtures/vcr_cassettes/examples/uuid_metadata/001.yml +39 -0
  55. data/fixtures/vcr_cassettes/examples/uuid_metadata/002.yml +39 -0
  56. data/fixtures/vcr_cassettes/examples/uuid_metadata/003.yml +39 -0
  57. data/fixtures/vcr_cassettes/examples/uuid_metadata/004.yml +39 -0
  58. data/fixtures/vcr_cassettes/examples/uuid_metadata/005.yml +73 -0
  59. data/fixtures/vcr_cassettes/examples/uuid_metadata/006.yml +73 -0
  60. data/fixtures/vcr_cassettes/examples/uuid_metadata/007.yml +73 -0
  61. data/fixtures/vcr_cassettes/examples/uuid_metadata/008.yml +73 -0
  62. data/fixtures/vcr_cassettes/lib/events/get_all_channels_metadata.yml +39 -0
  63. data/fixtures/vcr_cassettes/lib/events/get_all_uuid_metadata.yml +76 -0
  64. data/fixtures/vcr_cassettes/lib/events/get_channel_members.yml +37 -0
  65. data/fixtures/vcr_cassettes/lib/events/get_channel_metadata.yml +37 -0
  66. data/fixtures/vcr_cassettes/lib/events/get_memberships1.yml +37 -0
  67. data/fixtures/vcr_cassettes/lib/events/get_memberships2.yml +37 -0
  68. data/fixtures/vcr_cassettes/lib/events/get_uuid_metadata1.yml +76 -0
  69. data/fixtures/vcr_cassettes/lib/events/get_uuid_metadata2.yml +76 -0
  70. data/fixtures/vcr_cassettes/lib/events/grant-error.yml +2 -2
  71. data/fixtures/vcr_cassettes/lib/events/grant.yml +10 -11
  72. data/fixtures/vcr_cassettes/lib/events/remove_channel_members.yml +78 -0
  73. data/fixtures/vcr_cassettes/lib/events/{delete_space.yml → remove_channel_metadata.yml} +5 -6
  74. data/fixtures/vcr_cassettes/lib/events/{manage_memberships_remove.yml → remove_memberships1.yml} +8 -9
  75. data/fixtures/vcr_cassettes/lib/events/{manage_members_add.yml → remove_memberships2.yml} +8 -9
  76. data/fixtures/vcr_cassettes/lib/events/remove_uuid_metadata1.yml +76 -0
  77. data/fixtures/vcr_cassettes/lib/events/remove_uuid_metadata2.yml +76 -0
  78. data/fixtures/vcr_cassettes/lib/events/set_channel_members.yml +39 -0
  79. data/fixtures/vcr_cassettes/lib/events/set_channel_metadata.yml +39 -0
  80. data/fixtures/vcr_cassettes/lib/events/{manage_memberships_add.yml → set_memberships1.yml} +8 -9
  81. data/fixtures/vcr_cassettes/lib/events/set_memberships2.yml +39 -0
  82. data/fixtures/vcr_cassettes/lib/events/set_uuid_metadata1.yml +78 -0
  83. data/fixtures/vcr_cassettes/lib/events/set_uuid_metadata2.yml +78 -0
  84. data/fixtures/vcr_cassettes/lib/events/{subscribe-space-delete-async.yml → subscribe-channel-metadata-remove-sync.yml} +12 -14
  85. data/fixtures/vcr_cassettes/lib/events/subscribe-channel-metadata-set-async.yml +75 -0
  86. data/fixtures/vcr_cassettes/lib/events/{subscribe-member-remove-async.yml → subscribe-member-remove-sync.yml} +12 -14
  87. data/fixtures/vcr_cassettes/lib/events/subscribe-member-set-async.yml +75 -0
  88. data/fixtures/vcr_cassettes/lib/events/subscribe-membership-remove-async.yml +12 -14
  89. data/fixtures/vcr_cassettes/lib/events/{subscribe-user-update-async.yml → subscribe-membership-set-async.yml} +12 -14
  90. data/fixtures/vcr_cassettes/lib/events/{subscribe-user-delete-async.yml → subscribe-uuid-metadata-remove-sync.yml} +12 -14
  91. data/fixtures/vcr_cassettes/lib/events/subscribe-uuid-metadata-set-async.yml +75 -0
  92. data/lib/pubnub/client.rb +22 -16
  93. data/lib/pubnub/client/events.rb +4 -2
  94. data/lib/pubnub/client/helpers.rb +1 -1
  95. data/lib/pubnub/configuration.rb +1 -0
  96. data/lib/pubnub/constants.rb +20 -18
  97. data/lib/pubnub/crypto.rb +22 -8
  98. data/lib/pubnub/event.rb +39 -17
  99. data/lib/pubnub/event/formatter.rb +4 -0
  100. data/lib/pubnub/event/signature.rb +22 -7
  101. data/lib/pubnub/events/add_channels_to_push.rb +29 -13
  102. data/lib/pubnub/events/get_all_channels_metadata.rb +104 -0
  103. data/lib/pubnub/events/get_all_uuid_metadata.rb +104 -0
  104. data/lib/pubnub/events/get_channel_members.rb +120 -0
  105. data/lib/pubnub/events/{update_space.rb → get_channel_metadata.rb} +27 -27
  106. data/lib/pubnub/events/get_memberships.rb +120 -0
  107. data/lib/pubnub/events/{create_space.rb → get_uuid_metadata.rb} +27 -25
  108. data/lib/pubnub/events/grant.rb +10 -1
  109. data/lib/pubnub/events/history.rb +2 -1
  110. data/lib/pubnub/events/list_push_provisions.rb +29 -12
  111. data/lib/pubnub/events/publish.rb +2 -2
  112. data/lib/pubnub/events/remove_channel_members.rb +137 -0
  113. data/lib/pubnub/events/{delete_space.rb → remove_channel_metadata.rb} +13 -13
  114. data/lib/pubnub/events/remove_channels_from_push.rb +29 -13
  115. data/lib/pubnub/events/remove_device_from_push.rb +30 -14
  116. data/lib/pubnub/events/remove_memberships.rb +137 -0
  117. data/lib/pubnub/events/{delete_user.rb → remove_uuid_metadata.rb} +13 -13
  118. data/lib/pubnub/events/set_channel_members.rb +140 -0
  119. data/lib/pubnub/events/{manage_members.rb → set_channel_metadata.rb} +32 -38
  120. data/lib/pubnub/events/set_memberships.rb +140 -0
  121. data/lib/pubnub/events/{create_user.rb → set_uuid_metadata.rb} +33 -17
  122. data/lib/pubnub/events/signal.rb +1 -1
  123. data/lib/pubnub/formatter.rb +31 -4
  124. data/lib/pubnub/pam.rb +2 -11
  125. data/lib/pubnub/subscribe_callback.rb +1 -3
  126. data/lib/pubnub/subscribe_event/formatter.rb +30 -19
  127. data/lib/pubnub/subscriber.rb +5 -6
  128. data/lib/pubnub/validators/add_channels_to_push.rb +52 -0
  129. data/lib/pubnub/validators/get_all_channels_metadata.rb +29 -0
  130. data/lib/pubnub/validators/get_all_uuid_metadata.rb +29 -0
  131. data/lib/pubnub/validators/get_channel_members.rb +39 -0
  132. data/lib/pubnub/validators/get_channel_metadata.rb +39 -0
  133. data/lib/pubnub/validators/get_memberships.rb +39 -0
  134. data/lib/pubnub/validators/get_uuid_metadata.rb +39 -0
  135. data/lib/pubnub/validators/grant.rb +37 -2
  136. data/lib/pubnub/validators/list_push_provisions.rb +43 -0
  137. data/lib/pubnub/validators/remove_channel_members.rb +52 -0
  138. data/lib/pubnub/validators/remove_channel_metadata.rb +39 -0
  139. data/lib/pubnub/validators/remove_channels_from_push.rb +52 -0
  140. data/lib/pubnub/validators/remove_device_from_push.rb +43 -0
  141. data/lib/pubnub/validators/remove_memberships.rb +52 -0
  142. data/lib/pubnub/validators/remove_uuid_metadata.rb +39 -0
  143. data/lib/pubnub/validators/set_channel_members.rb +78 -0
  144. data/lib/pubnub/validators/set_channel_metadata.rb +62 -0
  145. data/lib/pubnub/validators/set_memberships.rb +78 -0
  146. data/lib/pubnub/validators/set_uuid_metadata.rb +62 -0
  147. data/lib/pubnub/version.rb +1 -1
  148. data/spec/examples/add_channels_to_push_spec.rb +178 -0
  149. data/spec/examples/{grant_examples_spec.rb → grant_examples_1_spec.rb} +0 -8973
  150. data/spec/examples/grant_examples_2_spec.rb +9107 -0
  151. data/spec/examples/history_examples_spec.rb +87 -9
  152. data/spec/examples/list_push_provisions_spec.rb +164 -0
  153. data/spec/examples/presence_examples_spec.rb +222 -186
  154. data/spec/examples/publish_examples_spec.rb +864 -0
  155. data/spec/examples/remove_channel_members_examples_spec.rb +100 -0
  156. data/spec/examples/remove_channel_metadata_examples_spec.rb +89 -0
  157. data/spec/examples/remove_channels_from_push_spec.rb +164 -0
  158. data/spec/examples/remove_device_from_push_spec.rb +164 -0
  159. data/spec/examples/remove_memberships_examples_spec.rb +121 -0
  160. data/spec/examples/remove_uuid_metadata_examples_spec.rb +107 -0
  161. data/spec/examples/revoke_examples_1_spec.rb +27013 -0
  162. data/spec/examples/revoke_examples_2_spec.rb +27012 -0
  163. data/spec/examples/revoke_examples_3_spec.rb +17967 -0
  164. data/spec/examples/set_channel_members_examples_spec.rb +99 -0
  165. data/spec/examples/set_channel_metadata_examples_spec.rb +93 -0
  166. data/spec/examples/set_memberships_examples_spec.rb +122 -0
  167. data/spec/examples/set_uuid_metadata_examples_spec.rb +114 -0
  168. data/spec/examples/status_request_message_count_exceeded_spec.rb +4 -1
  169. data/spec/examples/subscribe_examples_1_spec.rb +26972 -0
  170. data/spec/examples/subscribe_examples_2_spec.rb +19575 -0
  171. data/spec/lib/connection_callback_spec.rb +4 -3
  172. data/spec/lib/event/formatter_spec.rb +22 -0
  173. data/spec/lib/events/channel_metadata_spec.rb +58 -0
  174. data/spec/lib/events/grant_spec.rb +3 -2
  175. data/spec/lib/events/membership_spec.rb +51 -21
  176. data/spec/lib/events/presence_delta_spec.rb +9 -6
  177. data/spec/lib/events/presence_spec.rb +13 -7
  178. data/spec/lib/events/subscribe_spec.rb +104 -65
  179. data/spec/lib/events/uuid_metadata_spec.rb +86 -0
  180. data/spec/lib/multiple_ciphers_spec.rb +16 -4
  181. data/spec/lib/subscribe_event/formatter_spec.rb +22 -0
  182. data/spec/lib/super_admin_spec.rb +8 -4
  183. data/spec/spec_helper.rb +24 -8
  184. metadata +153 -65
  185. data/fixtures/vcr_cassettes/lib/events/create_space.yml +0 -40
  186. data/fixtures/vcr_cassettes/lib/events/create_user.yml +0 -40
  187. data/fixtures/vcr_cassettes/lib/events/delete_user.yml +0 -38
  188. data/fixtures/vcr_cassettes/lib/events/get_members.yml +0 -38
  189. data/fixtures/vcr_cassettes/lib/events/get_space.yml +0 -38
  190. data/fixtures/vcr_cassettes/lib/events/get_space_memberships.yml +0 -38
  191. data/fixtures/vcr_cassettes/lib/events/get_spaces.yml +0 -40
  192. data/fixtures/vcr_cassettes/lib/events/get_user.yml +0 -38
  193. data/fixtures/vcr_cassettes/lib/events/get_users.yml +0 -40
  194. data/fixtures/vcr_cassettes/lib/events/manage_members_remove.yml +0 -83
  195. data/fixtures/vcr_cassettes/lib/events/subscribe-member-add-async.yml +0 -77
  196. data/fixtures/vcr_cassettes/lib/events/subscribe-membership-add-async.yml +0 -77
  197. data/fixtures/vcr_cassettes/lib/events/subscribe-space-update-async.yml +0 -77
  198. data/fixtures/vcr_cassettes/lib/events/update_space.yml +0 -40
  199. data/fixtures/vcr_cassettes/lib/events/update_user.yml +0 -40
  200. data/lib/pubnub/events/get_members.rb +0 -93
  201. data/lib/pubnub/events/get_space.rb +0 -74
  202. data/lib/pubnub/events/get_space_memberships.rb +0 -93
  203. data/lib/pubnub/events/get_spaces.rb +0 -90
  204. data/lib/pubnub/events/get_user.rb +0 -74
  205. data/lib/pubnub/events/get_users.rb +0 -90
  206. data/lib/pubnub/events/manage_memberships.rb +0 -105
  207. data/lib/pubnub/events/update_user.rb +0 -86
  208. data/lib/pubnub/validators/create_space.rb +0 -44
  209. data/lib/pubnub/validators/create_user.rb +0 -44
  210. data/lib/pubnub/validators/delete_space.rb +0 -32
  211. data/lib/pubnub/validators/delete_user.rb +0 -32
  212. data/lib/pubnub/validators/get_members.rb +0 -32
  213. data/lib/pubnub/validators/get_space.rb +0 -32
  214. data/lib/pubnub/validators/get_space_memberships.rb +0 -32
  215. data/lib/pubnub/validators/get_spaces.rb +0 -16
  216. data/lib/pubnub/validators/get_user.rb +0 -32
  217. data/lib/pubnub/validators/get_users.rb +0 -16
  218. data/lib/pubnub/validators/manage_members.rb +0 -45
  219. data/lib/pubnub/validators/manage_memberships.rb +0 -45
  220. data/lib/pubnub/validators/push.rb +0 -43
  221. data/lib/pubnub/validators/update_space.rb +0 -45
  222. data/lib/pubnub/validators/update_user.rb +0 -45
  223. data/spec/examples/revoke_examples_spec.rb +0 -71950
  224. data/spec/examples/subscribe_examples_spec.rb +0 -45184
  225. data/spec/lib/events/space_spec.rb +0 -75
  226. data/spec/lib/events/user_spec.rb +0 -75
@@ -7,6 +7,7 @@ describe "Connect, disconnect and reconnect callbacks" do
7
7
 
8
8
  before(:each) do
9
9
  @connect_messages, @reconnect_messages, @disconnect_messages = [], [], []
10
+ @sleep_duration = ENV['JRUBY_TEST'] == 'true' ? 1.5 : 0.5
10
11
 
11
12
  callback = Pubnub::SubscribeCallback.new(
12
13
  message: -> (_envelope) { },
@@ -37,7 +38,7 @@ describe "Connect, disconnect and reconnect callbacks" do
37
38
  it "fire connect callback when connection is made" do
38
39
  VCR.use_cassette("client/connection_callbacks_0", :record => :once) do
39
40
  @pubnub.subscribe(channel: :demo)
40
- sleep 0.5
41
+ sleep @sleep_duration
41
42
  expect(@connect_messages.size).to be > 0
42
43
  end
43
44
  end
@@ -47,7 +48,7 @@ describe "Connect, disconnect and reconnect callbacks" do
47
48
 
48
49
  VCR.use_cassette("client/connection_callbacks_1", :record => :once) do
49
50
  @pubnub.subscribe(channel: :demo)
50
- sleep 0.5
51
+ sleep @sleep_duration
51
52
  expect(@disconnect_messages.size).to be > 0
52
53
  end
53
54
  end
@@ -57,7 +58,7 @@ describe "Connect, disconnect and reconnect callbacks" do
57
58
 
58
59
  VCR.use_cassette("client/connection_callbacks_2", :record => :once) do
59
60
  @pubnub.subscribe(channel: :demo)
60
- sleep 0.5
61
+ sleep @sleep_duration
61
62
  expect(@reconnect_messages.size).to be > 0
62
63
  end
63
64
  end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe "formatter" do
4
+ around :each do |example|
5
+ example.run_with_retry retry: 10
6
+ end
7
+
8
+ it "does not hide errors when formatting" do
9
+ class MockFormatter
10
+ include Pubnub::Event::EFormatter
11
+ end
12
+
13
+ class TestError < StandardError
14
+ def message
15
+ "This is a test"
16
+ end
17
+ end
18
+
19
+ # ensure the correct error is raised instead of -> NoMethodError: undefined method `body'
20
+ expect { MockFormatter.new.format_envelopes(TestError.new('error'), nil) }.to raise_error(TestError)
21
+ end
22
+ end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ describe Pubnub::SetChannelMetadata do
4
+ it_behaves_like "an event"
5
+
6
+ context "given basic parameters" do
7
+ before :each do
8
+ @pubnub = Pubnub::Client.new(
9
+ subscribe_key: "sub-a-mock-key",
10
+ publish_key: "pub-a-mock-key",
11
+ auth_key: "ruby-test-auth",
12
+ uuid: "ruby-test-uuid"
13
+ )
14
+ end
15
+
16
+ it "set_channel_metadata_works" do
17
+ VCR.use_cassette("lib/events/set_channel_metadata", record: :once) do
18
+ envelope = @pubnub.set_channel_metadata(
19
+ channel: "rb_channel",
20
+ metadata: { name: "some_name", custom: { XXX: "YYYY" } },
21
+ include: { custom: true }
22
+ ).value
23
+
24
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
25
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
26
+ end
27
+ end
28
+
29
+ it "get_channel_metadata_works" do
30
+ VCR.use_cassette("lib/events/get_channel_metadata", record: :once) do
31
+ envelope = @pubnub.get_channel_metadata(channel: "rb_channel", include: { custom: true }).value
32
+
33
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
34
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
35
+ end
36
+ end
37
+
38
+ it "get_all_channels_metadata_works" do
39
+ VCR.use_cassette("lib/events/get_all_channels_metadata", record: :once) do
40
+ envelope = @pubnub.get_all_channels_metadata(limit: 5, include: { custom: true }).value
41
+
42
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
43
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
44
+ end
45
+ end
46
+
47
+ it "remove_channel_metadata_works" do
48
+ VCR.use_cassette("lib/events/remove_channel_metadata", record: :once) do
49
+ envelope = @pubnub.remove_channel_metadata(channel: "rb_channel").value
50
+
51
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
52
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -5,9 +5,10 @@ describe Pubnub::Grant do
5
5
 
6
6
  context "given basic parameters" do
7
7
  before :each do
8
- allow_any_instance_of(Pubnub::Grant).to receive(:current_time).and_return 1463146850
9
- allow_any_instance_of(Pubnub::Grant).to receive(:signature).and_return "udCXAk-z4VaU2JA2LgjVzED2LBZAKsjj86twYJoGPnY="
8
+ allow_any_instance_of(Pubnub::Grant).to receive(:current_time).and_return 1602537897
9
+ allow_any_instance_of(Pubnub::Grant).to receive(:signature).and_return "v2.OdCTZXne_jEBewh3yY8iNDWcMCHC6BXNrg1Er9JoSTQ"
10
10
  end
11
+
11
12
  let(:pubnub) do
12
13
  Pubnub::Client.new(
13
14
  subscribe_key: "sub-a-mock-key",
@@ -1,63 +1,93 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Pubnub::ManageMemberships do
3
+ describe Pubnub::SetMemberships do
4
4
  it_behaves_like "an event"
5
5
 
6
6
  context "given basic parameters" do
7
7
  before :each do
8
8
  @pubnub = Pubnub::Client.new(
9
- subscribe_key: "demo",
10
- publish_key: "demo",
9
+ subscribe_key: "sub-a-mock-key",
10
+ publish_key: "pub-a-mock-key",
11
11
  auth_key: "ruby-test-auth",
12
12
  uuid: "ruby-test-uuid",
13
13
  )
14
14
  end
15
- it "get_members_works" do
16
- VCR.use_cassette("lib/events/get_members", record: :once) do
17
- envelope = @pubnub.get_members(space_id: "space-1", include: "custom", count: true).value
15
+
16
+ it "get_channel_members_works" do
17
+ VCR.use_cassette("lib/events/get_channel_members", record: :once) do
18
+ envelope = @pubnub.get_channel_members(channel: "channel-1", include: { count: true, custom: true }).value
18
19
 
19
20
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
20
21
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
21
22
  end
22
23
  end
23
24
 
24
- it "get_space_memberships_works" do
25
- VCR.use_cassette("lib/events/get_space_memberships", record: :once) do
26
- envelope = @pubnub.get_space_memberships(user_id: "mg3", include: "custom", count: true).value
25
+ it "get_memberships_works_1" do
26
+ VCR.use_cassette("lib/events/get_memberships1", record: :once) do
27
+ envelope = @pubnub.get_memberships(uuid: "mg3", include: { count: true, custom: true }).value
27
28
 
28
29
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
29
30
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
30
31
  end
31
32
  end
32
33
 
33
- it "manage_memberships_add_works" do
34
- VCR.use_cassette("lib/events/manage_memberships_add", record: :once) do
35
- envelope = @pubnub.manage_memberships(user_id: "mg3", data: {'add': [{'id': 'space-1'}]}, include: "custom").value
34
+ it "get_memberships_works_2" do
35
+ VCR.use_cassette("lib/events/get_memberships2", record: :once) do
36
+ envelope = @pubnub.get_memberships(include: { count: true, custom: true }).value
36
37
 
37
38
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
38
39
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
39
40
  end
40
41
  end
41
- it "manage_memberships_remove_works" do
42
- VCR.use_cassette("lib/events/manage_memberships_remove", record: :once) do
43
- envelope = @pubnub.manage_memberships(user_id: "mg3", data: {'remove': [{'id': 'space-1'}]}, include: "custom").value
42
+
43
+ it "set_memberships_works_1" do
44
+ VCR.use_cassette("lib/events/set_memberships1", record: :once) do
45
+ envelope = @pubnub.set_memberships(uuid: "mg3", channels: [{ channel: 'channel-1'}], include: { custom: true }).value
44
46
 
45
47
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
46
48
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
47
49
  end
48
50
  end
49
51
 
50
- it "manage_members_add_works" do
51
- VCR.use_cassette("lib/events/manage_members_add", record: :once) do
52
- envelope = @pubnub.manage_members(space_id: "space-1", data: {'add': [{'id': 'mg2'}]}, include: "custom").value
52
+ it "set_memberships_works_2" do
53
+ VCR.use_cassette("lib/events/set_memberships2", record: :once) do
54
+ envelope = @pubnub.set_memberships(channels: [{ channel: 'channel-1'}], include: { custom: true }).value
53
55
 
54
56
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
55
57
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
56
58
  end
57
59
  end
58
- it "manage_members_remove_works" do
59
- VCR.use_cassette("lib/events/manage_members_remove", record: :once) do
60
- envelope = @pubnub.manage_members(space_id: "space-1", data: {'remove': [{'id': 'mg2'}]}, include: "custom").value
60
+
61
+ it "remove_memberships_works_1" do
62
+ VCR.use_cassette("lib/events/remove_memberships1", record: :once) do
63
+ envelope = @pubnub.remove_memberships(uuid: "mg3", channels: ['channel-1'], include: { custom: true }).value
64
+
65
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
66
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
67
+ end
68
+ end
69
+
70
+ it "remove_memberships_works_2" do
71
+ VCR.use_cassette("lib/events/remove_memberships2", record: :once) do
72
+ envelope = @pubnub.remove_memberships(channels: ['channel-1'], include: { custom: true }).value
73
+
74
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
75
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
76
+ end
77
+ end
78
+
79
+ it "set_channel_members_works" do
80
+ VCR.use_cassette("lib/events/set_channel_members", record: :once) do
81
+ envelope = @pubnub.set_channel_members(channel: "channel-1", uuids: [{uuid: 'mg2'}], include: { custom: true }).value
82
+
83
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
84
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
85
+ end
86
+ end
87
+
88
+ it "remove_channel_members_works" do
89
+ VCR.use_cassette("lib/events/remove_channel_members", record: :once) do
90
+ envelope = @pubnub.remove_channel_members(channel: "channel-1", uuids: ['mg2'], include: { custom: true }).value
61
91
 
62
92
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
63
93
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
@@ -8,12 +8,12 @@ describe Pubnub::Presence do
8
8
 
9
9
  context "with interval events and delta" do
10
10
  before :each do
11
- @messages = []
11
+ @presences = []
12
12
  @statuses = []
13
13
 
14
14
  @callbacks = Pubnub::SubscribeCallback.new(
15
15
  message: -> (_envelope) { },
16
- presence: -> (envelope) { @messages << envelope },
16
+ presence: -> (envelope) { @presences << envelope },
17
17
  status: -> (envelope) { @statuses << envelope },
18
18
  )
19
19
  end
@@ -26,10 +26,13 @@ describe Pubnub::Presence do
26
26
  pubnub.presence(channel: :demo)
27
27
 
28
28
  eventually do
29
- 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}})
30
- 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}})
31
- 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}})
32
- 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}})
29
+ if @presences.length >= 4
30
+ expect(@presences[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(@presences[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(@presences[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(@presences[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
+ true
35
+ end
33
36
  end
34
37
  end
35
38
  end
@@ -4,7 +4,7 @@ describe Pubnub::Presence do
4
4
  around :each do |example|
5
5
  example.run_with_retry retry: 10
6
6
  end
7
-
7
+
8
8
  it_behaves_like "an event"
9
9
 
10
10
  context "given basic parameters" do
@@ -34,9 +34,12 @@ describe Pubnub::Presence do
34
34
  @pubnub.presence(channel: :demo)
35
35
 
36
36
  eventually do
37
- envelope = @messages.first
38
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
39
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
37
+ if @messages.length > 0
38
+ envelope = @messages.first
39
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
40
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
41
+ true
42
+ end
40
43
  end
41
44
  end
42
45
  end
@@ -56,9 +59,12 @@ describe Pubnub::Presence do
56
59
  sleep 0.1
57
60
 
58
61
  eventually do
59
- envelope = @statuses.first
60
- expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
61
- # expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
62
+ if @statuses.length > 0
63
+ envelope = @statuses.first
64
+ expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
65
+ # expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema
66
+ true
67
+ end
62
68
  end
63
69
  end
64
70
  end
@@ -13,8 +13,8 @@ describe Pubnub::Subscribe do
13
13
  @messages = []
14
14
  @statuses = []
15
15
  @signals = []
16
- @user_events = []
17
- @space_events = []
16
+ @uuid_metadata_events = []
17
+ @channel_metadata_events = []
18
18
  @membership_events = []
19
19
 
20
20
  @callbacks = Pubnub::SubscribeCallback.new(
@@ -22,9 +22,19 @@ describe Pubnub::Subscribe do
22
22
  presence: -> (_envelope) { },
23
23
  status: -> (envelope) { @statuses << envelope },
24
24
  signal: -> (envelope) { @signals << envelope },
25
- user: -> (envelope) { @user_events << envelope },
26
- space: -> (envelope) { @space_events << envelope },
27
- membership: -> (envelope) { @membership_events << envelope }
25
+ object: -> (envelope) {
26
+ case envelope.result[:operation]
27
+ when Pubnub::Constants::OPERATION_SET_UUID_METADATA, Pubnub::Constants::OPERATION_REMOVE_UUID_METADATA
28
+ @uuid_metadata_events << envelope
29
+ when Pubnub::Constants::OPERATION_SET_CHANNEL_METADATA, Pubnub::Constants::OPERATION_REMOVE_CHANNEL_METADATA
30
+ @channel_metadata_events << envelope
31
+ when Pubnub::Constants::OPERATION_SET_CHANNEL_MEMBERS, Pubnub::Constants::OPERATION_REMOVE_CHANNEL_MEMBERS,
32
+ Pubnub::Constants::OPERATION_SET_MEMBERSHIPS, Pubnub::Constants::OPERATION_REMOVE_MEMBERSHIPS
33
+ @membership_events << envelope
34
+ else
35
+ puts "Unexpected operation"
36
+ end
37
+ }
28
38
  )
29
39
  end
30
40
 
@@ -43,9 +53,12 @@ describe Pubnub::Subscribe do
43
53
  @pubnub.subscribe(channel: :demo)
44
54
 
45
55
  eventually do
46
- envelope = @messages.first
47
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
48
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
56
+ if @messages.length > 0
57
+ envelope = @messages.first
58
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
59
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
60
+ true
61
+ end
49
62
  end
50
63
  end
51
64
  end
@@ -56,6 +69,7 @@ describe Pubnub::Subscribe do
56
69
  publish_key: "demo",
57
70
  uuid: "ruby-test-uuid",
58
71
  cipher_key: "demo",
72
+ random_iv: false
59
73
  )
60
74
 
61
75
  @pubnub.add_listener(callback: @callbacks)
@@ -64,7 +78,10 @@ describe Pubnub::Subscribe do
64
78
  @pubnub.subscribe(channel: :whatever)
65
79
 
66
80
  eventually do
67
- expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
81
+ if @messages.length > 0
82
+ expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
83
+ true
84
+ end
68
85
  end
69
86
  end
70
87
  end
@@ -100,15 +117,18 @@ describe Pubnub::Subscribe do
100
117
  sleep 0.1
101
118
 
102
119
  eventually do
103
- envelope = @statuses.first
104
- expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
105
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
120
+ if @statuses.length > 0
121
+ envelope = @statuses.first
122
+ expect(envelope).to be_a_kind_of Pubnub::ErrorEnvelope
123
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
124
+ true
125
+ end
106
126
  end
107
127
  end
108
128
  end
109
129
 
110
- it "user update works" do
111
- VCR.use_cassette("lib/events/subscribe-user-update-async", record: :once) do
130
+ it "uuid metadata update works" do
131
+ VCR.use_cassette("lib/events/subscribe-uuid-metadata-set-async", record: :once) do
112
132
  @pubnub = Pubnub::Client.new(
113
133
  subscribe_key: "sub-a-mock-key",
114
134
  publish_key: "pub-a-mock-key",
@@ -118,20 +138,24 @@ describe Pubnub::Subscribe do
118
138
 
119
139
  @pubnub.add_listener(callback: @callbacks)
120
140
 
121
- @pubnub.subscribe(channel: :user_mg3)
141
+ @pubnub.subscribe(channel: :uuid_mg3)
122
142
 
123
143
  eventually do
124
- envelope = @user_events.first
125
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
126
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
127
- expect(envelope.result[:data][:message]['event']).to eq 'update'
128
- expect(envelope.result[:data][:message]['type']).to eq 'user'
144
+ if @uuid_metadata_events.length > 0
145
+ envelope = @uuid_metadata_events.first
146
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
147
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
148
+ expect(envelope.result[:data][:message]['event']).to eq 'set'
149
+ expect(envelope.result[:data][:message]['type']).to eq 'uuid'
150
+ expect(envelope.result[:data][:message]['data']['id']).to eq 'uuid_mg3'
151
+ true
152
+ end
129
153
  end
130
154
  end
131
155
  end
132
156
 
133
- it "space update works" do
134
- VCR.use_cassette("lib/events/subscribe-space-update-async", record: :once) do
157
+ it "channel metadata update works" do
158
+ VCR.use_cassette("lib/events/subscribe-channel-metadata-set-async", record: :once) do
135
159
  @pubnub = Pubnub::Client.new(
136
160
  subscribe_key: "sub-a-mock-key",
137
161
  publish_key: "pub-a-mock-key",
@@ -141,20 +165,24 @@ describe Pubnub::Subscribe do
141
165
 
142
166
  @pubnub.add_listener(callback: @callbacks)
143
167
 
144
- @pubnub.subscribe(channel: :rb_space_3)
168
+ @pubnub.subscribe(channel: :rb_channel_3)
145
169
 
146
170
  eventually do
147
- envelope = @space_events.first
148
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
149
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
150
- expect(envelope.result[:data][:message]['event']).to eq 'update'
151
- expect(envelope.result[:data][:message]['type']).to eq 'space'
171
+ if @channel_metadata_events.length > 0
172
+ envelope = @channel_metadata_events.first
173
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
174
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
175
+ expect(envelope.result[:data][:message]['event']).to eq 'set'
176
+ expect(envelope.result[:data][:message]['type']).to eq 'channel'
177
+ # expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_channel_3'
178
+ true
179
+ end
152
180
  end
153
181
  end
154
182
  end
155
183
 
156
- it "member add works" do
157
- VCR.use_cassette("lib/events/subscribe-member-add-async", record: :once) do
184
+ it "member set works" do
185
+ VCR.use_cassette("lib/events/subscribe-member-set-async", record: :once) do
158
186
  @pubnub = Pubnub::Client.new(
159
187
  subscribe_key: "sub-a-mock-key",
160
188
  publish_key: "pub-a-mock-key",
@@ -164,21 +192,24 @@ describe Pubnub::Subscribe do
164
192
 
165
193
  @pubnub.add_listener(callback: @callbacks)
166
194
 
167
- @pubnub.subscribe(channel: :rb_space_4)
195
+ @pubnub.subscribe(channel: :rb_channel_3)
168
196
 
169
197
  eventually do
170
- envelope = @membership_events.first
171
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
172
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
173
- expect(envelope.result[:data][:message]['event']).to eq 'create'
174
- expect(envelope.result[:data][:message]['type']).to eq 'membership'
175
- expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4'
198
+ if @membership_events.length > 0
199
+ envelope = @membership_events.first
200
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
201
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
202
+ expect(envelope.result[:data][:message]['event']).to eq 'set'
203
+ expect(envelope.result[:data][:message]['type']).to eq 'membership'
204
+ expect(envelope.result[:data][:message]['data']['uuid']['id']).to eq 'uuid_mg3'
205
+ true
206
+ end
176
207
  end
177
208
  end
178
209
  end
179
210
 
180
- it "membership add works" do
181
- VCR.use_cassette("lib/events/subscribe-membership-add-async", record: :once) do
211
+ it "membership set works" do
212
+ VCR.use_cassette("lib/events/subscribe-membership-set-async", record: :once) do
182
213
  @pubnub = Pubnub::Client.new(
183
214
  subscribe_key: "sub-a-mock-key",
184
215
  publish_key: "pub-a-mock-key",
@@ -188,15 +219,18 @@ describe Pubnub::Subscribe do
188
219
 
189
220
  @pubnub.add_listener(callback: @callbacks)
190
221
 
191
- @pubnub.subscribe(channel: :user_mg4)
222
+ @pubnub.subscribe(channel: :uuid_mg5)
192
223
 
193
224
  eventually do
194
- envelope = @membership_events.first
195
- expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
196
- expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
197
- expect(envelope.result[:data][:message]['event']).to eq 'create'
198
- expect(envelope.result[:data][:message]['type']).to eq 'membership'
199
- expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4'
225
+ if @membership_events.length > 0
226
+ envelope = @membership_events.first
227
+ expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
228
+ expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
229
+ expect(envelope.result[:data][:message]['event']).to eq 'set'
230
+ expect(envelope.result[:data][:message]['type']).to eq 'membership'
231
+ expect(envelope.result[:data][:message]['data']['channel']['id']).to eq 'rb_channel_5'
232
+ true
233
+ end
200
234
  end
201
235
  end
202
236
  end
@@ -211,13 +245,17 @@ describe Pubnub::Subscribe do
211
245
  publish_key: "demo",
212
246
  uuid: "ruby-test-uuid",
213
247
  cipher_key: "demo",
248
+ random_iv: false
214
249
  )
215
250
 
216
251
  VCR.use_cassette("lib/events/subscribe-cipher-async", record: :once) do
217
252
  @pubnub.subscribe(channel: :whatever, http_sync: true)
218
253
  @messages = @pubnub.subscribe(channel: :whatever, http_sync: true)
219
254
  eventually do
220
- expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
255
+ if @messages.length > 0
256
+ expect(@messages.first.result[:data][:message]).to eq("text" => "hey")
257
+ true
258
+ end
221
259
  end
222
260
  end
223
261
  end
@@ -258,8 +296,8 @@ describe Pubnub::Subscribe do
258
296
  end
259
297
  end
260
298
 
261
- it "user delete works" do
262
- VCR.use_cassette("lib/events/subscribe-user-delete-async", record: :once) do
299
+ it "uuid metadata remove works" do
300
+ VCR.use_cassette("lib/events/subscribe-uuid-metadata-remove-sync", record: :once) do
263
301
  @pubnub = Pubnub::Client.new(
264
302
  subscribe_key: "sub-a-mock-key",
265
303
  publish_key: "pub-a-mock-key",
@@ -267,19 +305,20 @@ describe Pubnub::Subscribe do
267
305
  uuid: "ruby-test-uuid"
268
306
  )
269
307
 
270
- @pubnub.subscribe(channel: :user_mg3, http_sync: true)
271
- envelopes = @pubnub.subscribe(channel: :user_mg3, http_sync: true)
308
+ @pubnub.subscribe(channel: :uuid_mg3, http_sync: true)
309
+ envelopes = @pubnub.subscribe(channel: :uuid_mg3, http_sync: true)
272
310
 
273
311
  envelope = envelopes.first
274
312
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
275
313
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
276
314
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
277
- expect(envelope.result[:data][:message]['type']).to eq 'user'
315
+ expect(envelope.result[:data][:message]['type']).to eq 'uuid'
316
+ expect(envelope.result[:data][:message]['data']['id']).to eq 'uuid_mg3'
278
317
  end
279
318
  end
280
319
 
281
- it "space delete works" do
282
- VCR.use_cassette("lib/events/subscribe-space-delete-async", record: :once) do
320
+ it "channel metadata remove works" do
321
+ VCR.use_cassette("lib/events/subscribe-channel-metadata-remove-sync", record: :once) do
283
322
  @pubnub = Pubnub::Client.new(
284
323
  subscribe_key: "sub-a-mock-key",
285
324
  publish_key: "pub-a-mock-key",
@@ -287,20 +326,20 @@ describe Pubnub::Subscribe do
287
326
  uuid: "ruby-test-uuid"
288
327
  )
289
328
 
290
- @pubnub.subscribe(channel: :rb_space_3, http_sync: true)
291
- envelopes = @pubnub.subscribe(channel: :rb_space_3, http_sync: true)
329
+ @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
330
+ envelopes = @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
292
331
 
293
332
  envelope = envelopes.first
294
333
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
295
334
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
296
335
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
297
- expect(envelope.result[:data][:message]['type']).to eq 'space'
298
- expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_space_3'
336
+ expect(envelope.result[:data][:message]['type']).to eq 'channel'
337
+ expect(envelope.result[:data][:message]['data']['id']).to eq 'rb_channel_1'
299
338
  end
300
339
  end
301
340
 
302
341
  it "member remove works" do
303
- VCR.use_cassette("lib/events/subscribe-member-remove-async", record: :once) do
342
+ VCR.use_cassette("lib/events/subscribe-member-remove-sync", record: :once) do
304
343
  @pubnub = Pubnub::Client.new(
305
344
  subscribe_key: "sub-a-mock-key",
306
345
  publish_key: "pub-a-mock-key",
@@ -308,15 +347,15 @@ describe Pubnub::Subscribe do
308
347
  uuid: "ruby-test-uuid"
309
348
  )
310
349
 
311
- @pubnub.subscribe(channel: :rb_space_4, http_sync: true)
312
- envelopes = @pubnub.subscribe(channel: :rb_space_4, http_sync: true)
350
+ @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
351
+ envelopes = @pubnub.subscribe(channel: :rb_channel_1, http_sync: true)
313
352
 
314
353
  envelope = envelopes.first
315
354
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
316
355
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
317
356
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
318
357
  expect(envelope.result[:data][:message]['type']).to eq 'membership'
319
- expect(envelope.result[:data][:message]['data']['userId']).to eq 'user_mg4'
358
+ expect(envelope.result[:data][:message]['data']['uuid']['id']).to eq 'uuid_mg1'
320
359
  end
321
360
  end
322
361
 
@@ -329,15 +368,15 @@ describe Pubnub::Subscribe do
329
368
  uuid: "ruby-test-uuid"
330
369
  )
331
370
 
332
- @pubnub.subscribe(channel: :user_mg4, http_sync: true)
333
- envelopes = @pubnub.subscribe(channel: :user_mg4, http_sync: true)
371
+ @pubnub.subscribe(channel: :uuid_mg1, http_sync: true)
372
+ envelopes = @pubnub.subscribe(channel: :uuid_mg1, http_sync: true)
334
373
 
335
374
  envelope = envelopes.first
336
375
  expect(envelope.status).to satisfies_schema Pubnub::Schemas::Envelope::StatusSchema.new
337
376
  expect(envelope.result).to satisfies_schema Pubnub::Schemas::Envelope::ResultSchema.new
338
377
  expect(envelope.result[:data][:message]['event']).to eq 'delete'
339
378
  expect(envelope.result[:data][:message]['type']).to eq 'membership'
340
- expect(envelope.result[:data][:message]['data']['spaceId']).to eq 'rb_space_4'
379
+ expect(envelope.result[:data][:message]['data']['channel']['id']).to eq 'rb_channel_1'
341
380
  end
342
381
 
343
382
  end