slack-ruby-client 0.17.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.rubocop_todo.yml +65 -31
  4. data/.travis.yml +1 -0
  5. data/CHANGELOG.md +10 -0
  6. data/CONTRIBUTING.md +3 -3
  7. data/README.md +5 -5
  8. data/RELEASING.md +1 -1
  9. data/UPGRADING.md +42 -0
  10. data/bin/commands/admin_apps.rb +11 -0
  11. data/bin/commands/admin_apps_requests.rb +1 -0
  12. data/bin/commands/admin_auth_policy.rb +39 -0
  13. data/bin/commands/admin_conversations.rb +10 -0
  14. data/bin/commands/admin_conversations_restrictAccess.rb +1 -1
  15. data/bin/commands/admin_users.rb +1 -0
  16. data/bin/commands/admin_users_session.rb +40 -0
  17. data/bin/commands/apps_manifest.rb +51 -0
  18. data/bin/commands/chat.rb +9 -6
  19. data/bin/commands/conversations.rb +59 -2
  20. data/bin/commands/dnd.rb +1 -1
  21. data/bin/commands/files.rb +2 -1
  22. data/bin/commands/oauth.rb +0 -13
  23. data/bin/commands/oauth_v2.rb +13 -1
  24. data/bin/commands/openid_connect.rb +27 -0
  25. data/bin/commands/pins.rb +2 -2
  26. data/bin/commands/reminders.rb +6 -0
  27. data/bin/commands/rtm.rb +2 -2
  28. data/bin/commands/search.rb +2 -1
  29. data/bin/commands/stars.rb +7 -6
  30. data/bin/commands/team_billing.rb +13 -0
  31. data/bin/commands/team_preferences.rb +13 -0
  32. data/bin/commands/tooling_tokens.rb +14 -0
  33. data/bin/commands/usergroups.rb +1 -1
  34. data/bin/commands/users.rb +1 -1
  35. data/bin/commands/views.rb +1 -1
  36. data/bin/commands.rb +6 -8
  37. data/lib/slack/config.rb +1 -2
  38. data/lib/slack/events/request.rb +3 -1
  39. data/lib/slack/real_time/client.rb +4 -5
  40. data/lib/slack/real_time/concurrency/async.rb +6 -8
  41. data/lib/slack/real_time/socket.rb +1 -2
  42. data/lib/slack/real_time/stores/base.rb +1 -6
  43. data/lib/slack/real_time/stores/starter.rb +6 -3
  44. data/lib/slack/real_time/stores/store.rb +5 -0
  45. data/lib/slack/version.rb +1 -1
  46. data/lib/slack/web/api/endpoints/admin_analytics.rb +3 -3
  47. data/lib/slack/web/api/endpoints/admin_apps.rb +21 -5
  48. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +2 -2
  49. data/lib/slack/web/api/endpoints/admin_apps_requests.rb +4 -2
  50. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +2 -2
  51. data/lib/slack/web/api/endpoints/admin_auth_policy.rb +72 -0
  52. data/lib/slack/web/api/endpoints/admin_barriers.rb +6 -6
  53. data/lib/slack/web/api/endpoints/admin_conversations.rb +38 -24
  54. data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +4 -4
  55. data/lib/slack/web/api/endpoints/admin_emoji.rb +9 -9
  56. data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +7 -7
  57. data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +3 -3
  58. data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +2 -2
  59. data/lib/slack/web/api/endpoints/admin_teams.rb +6 -6
  60. data/lib/slack/web/api/endpoints/admin_teams_admins.rb +2 -2
  61. data/lib/slack/web/api/endpoints/admin_teams_owners.rb +2 -2
  62. data/lib/slack/web/api/endpoints/admin_teams_settings.rb +5 -5
  63. data/lib/slack/web/api/endpoints/admin_usergroups.rb +10 -10
  64. data/lib/slack/web/api/endpoints/admin_users.rb +20 -18
  65. data/lib/slack/web/api/endpoints/admin_users_session.rb +65 -9
  66. data/lib/slack/web/api/endpoints/api.rb +1 -1
  67. data/lib/slack/web/api/endpoints/apps.rb +2 -2
  68. data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +3 -3
  69. data/lib/slack/web/api/endpoints/apps_manifest.rb +75 -0
  70. data/lib/slack/web/api/endpoints/auth.rb +1 -1
  71. data/lib/slack/web/api/endpoints/auth_teams.rb +3 -3
  72. data/lib/slack/web/api/endpoints/bots.rb +2 -2
  73. data/lib/slack/web/api/endpoints/calls.rb +15 -15
  74. data/lib/slack/web/api/endpoints/calls_participants.rb +4 -4
  75. data/lib/slack/web/api/endpoints/chat.rb +60 -54
  76. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +3 -3
  77. data/lib/slack/web/api/endpoints/conversations.rb +115 -25
  78. data/lib/slack/web/api/endpoints/dialog.rb +2 -2
  79. data/lib/slack/web/api/endpoints/dnd.rb +4 -5
  80. data/lib/slack/web/api/endpoints/files.rb +16 -14
  81. data/lib/slack/web/api/endpoints/files_comments.rb +1 -1
  82. data/lib/slack/web/api/endpoints/files_remote.rb +20 -20
  83. data/lib/slack/web/api/endpoints/migration.rb +3 -3
  84. data/lib/slack/web/api/endpoints/oauth.rb +5 -27
  85. data/lib/slack/web/api/endpoints/oauth_v2.rb +24 -6
  86. data/lib/slack/web/api/endpoints/openid_connect.rb +42 -0
  87. data/lib/slack/web/api/endpoints/pins.rb +4 -4
  88. data/lib/slack/web/api/endpoints/reactions.rb +12 -12
  89. data/lib/slack/web/api/endpoints/reminders.rb +17 -5
  90. data/lib/slack/web/api/endpoints/rtm.rb +10 -10
  91. data/lib/slack/web/api/endpoints/search.rb +24 -16
  92. data/lib/slack/web/api/endpoints/stars.rb +11 -9
  93. data/lib/slack/web/api/endpoints/team.rb +8 -8
  94. data/lib/slack/web/api/endpoints/team_billing.rb +21 -0
  95. data/lib/slack/web/api/endpoints/team_preferences.rb +21 -0
  96. data/lib/slack/web/api/endpoints/team_profile.rb +1 -1
  97. data/lib/slack/web/api/endpoints/tooling_tokens.rb +24 -0
  98. data/lib/slack/web/api/endpoints/usergroups.rb +19 -19
  99. data/lib/slack/web/api/endpoints/usergroups_users.rb +7 -7
  100. data/lib/slack/web/api/endpoints/users.rb +16 -16
  101. data/lib/slack/web/api/endpoints/users_profile.rb +4 -4
  102. data/lib/slack/web/api/endpoints/views.rb +12 -12
  103. data/lib/slack/web/api/endpoints/workflows.rb +9 -9
  104. data/lib/slack/web/api/endpoints.rb +12 -18
  105. data/lib/slack/web/api/errors/server_error.rb +37 -0
  106. data/lib/slack/web/api/errors/too_many_requests_error.rb +1 -4
  107. data/lib/slack/web/api/errors.rb +200 -8
  108. data/lib/slack/web/api/mixins.rb +0 -2
  109. data/lib/slack/web/api/patches/chat.1.patch +1 -2
  110. data/lib/slack/web/api/templates/endpoints.erb +0 -2
  111. data/lib/slack/web/faraday/request.rb +2 -1
  112. data/lib/slack/web/faraday/response/raise_error.rb +1 -1
  113. data/lib/slack/web/faraday/response/wrap_error.rb +2 -2
  114. data/lib/slack/web/pagination/cursor.rb +1 -5
  115. data/lib/slack-ruby-client.rb +1 -1
  116. data/slack-ruby-client.gemspec +2 -3
  117. data/spec/fixtures/slack/web/429_error.yml +50 -54
  118. data/spec/fixtures/slack/web/auth_test_error.yml +51 -18
  119. data/spec/fixtures/slack/web/auth_test_success.yml +50 -26
  120. data/spec/fixtures/slack/web/conversations_info.yml +133 -9
  121. data/spec/fixtures/slack/web/conversations_setTopic.yml +42 -27
  122. data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +89 -59
  123. data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +131 -86
  124. data/spec/fixtures/slack/web/paginated_users_list.yml +501 -69
  125. data/spec/fixtures/slack/web/rtm_connect.yml +267 -30
  126. data/spec/fixtures/slack/web/rtm_start.yml +771 -60
  127. data/spec/fixtures/slack/web/users_info.yml +153 -69
  128. data/spec/fixtures/slack/web/users_list.yml +102 -41
  129. data/spec/fixtures/slack/web/views_open_error.yml +49 -42
  130. data/spec/slack/real_time/client_spec.rb +17 -21
  131. data/spec/slack/real_time/event_handlers/bot_spec.rb +1 -1
  132. data/spec/slack/real_time/event_handlers/channel_spec.rb +1 -1
  133. data/spec/slack/real_time/event_handlers/im_spec.rb +5 -5
  134. data/spec/slack/real_time/event_handlers/user_spec.rb +2 -2
  135. data/spec/slack/slack_spec.rb +3 -1
  136. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +5 -0
  137. data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +35 -0
  138. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +14 -9
  139. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +1 -1
  140. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +6 -6
  141. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +22 -2
  142. data/spec/slack/web/api/endpoints/admin_users_spec.rb +8 -8
  143. data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +36 -0
  144. data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
  145. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +4 -4
  146. data/spec/slack/web/api/endpoints/calls_spec.rb +2 -2
  147. data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +4 -6
  148. data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +1 -1
  149. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +2 -2
  150. data/spec/slack/web/api/endpoints/dnd_spec.rb +0 -5
  151. data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
  152. data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
  153. data/spec/slack/web/api/endpoints/oauth_spec.rb +0 -11
  154. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +6 -3
  155. data/spec/slack/web/api/endpoints/{im_spec.rb → openid_connect_spec.rb} +1 -1
  156. data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
  157. data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
  158. data/spec/slack/web/api/endpoints/{mpim_spec.rb → team_billing_spec.rb} +1 -1
  159. data/spec/slack/web/api/endpoints/{apps_permissions_scopes_spec.rb → team_preferences_spec.rb} +1 -1
  160. data/spec/slack/web/api/endpoints/tooling_tokens_spec.rb +13 -0
  161. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
  162. data/spec/slack/web/api/error_spec.rb +5 -7
  163. data/spec/slack/web/api/errors/slack_error_spec.rb +21 -26
  164. data/spec/slack/web/api/mixins/conversations_list_spec.rb +1 -1
  165. data/spec/slack/web/api/pagination/cursor_spec.rb +1 -3
  166. data/spec/slack/web/client_spec.rb +7 -6
  167. data/spec/slack/web/faraday/request_spec.rb +80 -0
  168. data/spec/slack/web/faraday/response/raise_error_spec.rb +1 -0
  169. data/spec/spec_helper.rb +1 -1
  170. data/spec/support/real_time/connected_client.rb +1 -7
  171. data/spec/support/vcr.rb +33 -2
  172. metadata +28 -144
  173. data/lib/slack/web/api/errors/internal_error.rb +0 -14
  174. data/lib/slack/web/api/mixins/channels.id.json +0 -20
  175. data/lib/slack/web/api/mixins/channels.id.rb +0 -25
  176. data/lib/slack/web/api/mixins/groups.id.json +0 -20
  177. data/lib/slack/web/api/mixins/groups.id.rb +0 -25
  178. data/spec/fixtures/slack/web/503_error.yml +0 -14
  179. data/spec/fixtures/slack/web/channels_info.yml +0 -139
  180. data/spec/slack/web/api/endpoints/apps_permissions_resources_spec.rb +0 -8
  181. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +0 -16
  182. data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +0 -19
  183. data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -109
  184. data/spec/slack/web/api/mixins/channels_spec.rb +0 -43
  185. data/spec/slack/web/api/mixins/groups_spec.rb +0 -43
@@ -12,10 +12,10 @@ RSpec.describe Slack::Web::Api::Endpoints::UsergroupsUsers do
12
12
  end
13
13
  context 'usergroups.users_update' do
14
14
  it 'requires usergroup' do
15
- expect { client.usergroups_users_update(users: %q[U060R4BJ4,U060RNRCZ]) }.to raise_error ArgumentError, /Required arguments :usergroup missing/
15
+ expect { client.usergroups_users_update(users: %q[]) }.to raise_error ArgumentError, /Required arguments :usergroup missing/
16
16
  end
17
17
  it 'requires users' do
18
- expect { client.usergroups_users_update(usergroup: %q[S0604QSJC]) }.to raise_error ArgumentError, /Required arguments :users missing/
18
+ expect { client.usergroups_users_update(usergroup: %q[]) }.to raise_error ArgumentError, /Required arguments :users missing/
19
19
  end
20
20
  end
21
21
  end
@@ -5,12 +5,10 @@ RSpec.describe Slack::Web::Api::Error do
5
5
  let(:client) { Slack::Web::Client.new }
6
6
 
7
7
  it 'provides access to the response object', vcr: { cassette_name: 'web/auth_test_error' } do
8
- begin
9
- client.auth_test
10
- raise 'Expected to receive Slack::Web::Api::Error.'
11
- rescue described_class => e
12
- expect(e.response).not_to be_nil
13
- expect(e.response.status).to eq 200
14
- end
8
+ client.auth_test
9
+ raise 'Expected to receive Slack::Web::Api::Error.'
10
+ rescue described_class => e
11
+ expect(e.response).not_to be_nil
12
+ expect(e.response.status).to eq 200
15
13
  end
16
14
  end
@@ -5,34 +5,29 @@ RSpec.describe Slack::Web::Api::Errors::SlackError do
5
5
  let(:client) { Slack::Web::Client.new }
6
6
 
7
7
  it 'provides access to the response object', vcr: { cassette_name: 'web/auth_test_error' } do
8
- begin
9
- client.auth_test
10
- raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
11
- rescue described_class => e
12
- expect(e.response).not_to be_nil
13
- expect(e.response.status).to eq 200
14
- expect(e.message).to eql 'not_authed'
15
- expect(e.error).to eql 'not_authed'
16
- expect(e.response_metadata).to be_nil
17
- end
8
+ client.auth_test
9
+ raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
10
+ rescue described_class => e
11
+ expect(e.response).not_to be_nil
12
+ expect(e.response.status).to eq 200
13
+ expect(e.message).to eql 'not_authed'
14
+ expect(e.error).to eql 'not_authed'
15
+ expect(e.response_metadata).to be_nil
18
16
  end
19
17
 
20
18
  it 'provides access to any response_metadata', vcr: { cassette_name: 'web/views_open_error' } do
21
- begin
22
- client.views_open(trigger_id: 'trigger_id', view: {})
23
- raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
24
- rescue described_class => e
25
- expect(e.response).not_to be_nil
26
- expect(e.response.status).to eq 200
27
- expect(e.message).to eql 'invalid_arguments'
28
- expect(e.error).to eql 'invalid_arguments'
29
- expect(e.response_metadata).to eq(
30
- 'messages' => [
31
- "[ERROR] missing required field: title [json-pointer:\/view]",
32
- "[ERROR] missing required field: blocks [json-pointer:\/view]",
33
- "[ERROR] missing required field: type [json-pointer:\/view]"
34
- ]
35
- )
36
- end
19
+ client.views_open(trigger_id: 'trigger_id', view: {})
20
+ raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
21
+ rescue described_class => e
22
+ expect(e.response).not_to be_nil
23
+ expect(e.response.status).to eq 200
24
+ expect(e.message).to eql 'invalid_arguments'
25
+ expect(e.error).to eql 'invalid_arguments'
26
+ expect(e.response_metadata).to eq(
27
+ 'messages' => [
28
+ '[ERROR] failed to match all allowed schemas [json-pointer:/view]',
29
+ '[ERROR] missing required field: type [json-pointer:/view]'
30
+ ]
31
+ )
37
32
  end
38
33
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  RSpec.describe Slack::Web::Client do
5
5
  context 'conversations_setTopic' do
6
6
  it 'does not invoke conversations_list', vcr: { cassette_name: 'web/conversations_setTopic' } do
7
- rc = subject.conversations_setTopic({ channel: 'C018Y6VH39D', topic: 'new topic' })
7
+ rc = subject.conversations_setTopic({ channel: 'C019CV63UTC', topic: 'new topic' })
8
8
  expect(rc.channel.topic.value).to eq 'new topic'
9
9
  end
10
10
 
@@ -30,7 +30,7 @@ RSpec.describe Slack::Web::Api::Pagination::Cursor do
30
30
  cursor.to_a
31
31
  end
32
32
  context 'with rate limiting' do
33
- let(:error) { Slack::Web::Api::Errors::TooManyRequestsError.new(nil) }
33
+ let(:error) { Slack::Web::Api::Errors::TooManyRequestsError.new(OpenStruct.new(headers: { 'retry-after' => 9 })) }
34
34
 
35
35
  context 'with default max retries' do
36
36
  it 'sleeps after a TooManyRequestsError' do
@@ -43,7 +43,6 @@ RSpec.describe Slack::Web::Api::Pagination::Cursor do
43
43
  expect(client).to(
44
44
  receive(:users_list).with(limit: 100, cursor: 'next').ordered.and_raise(error)
45
45
  )
46
- expect(error).to receive(:retry_after).once.ordered.and_return(9)
47
46
  expect(cursor).to receive(:sleep).once.ordered.with(9)
48
47
  expect(client).to(
49
48
  receive(:users_list)
@@ -67,7 +66,6 @@ RSpec.describe Slack::Web::Api::Pagination::Cursor do
67
66
  expect(client).to(
68
67
  receive(:users_list).with(limit: 100, cursor: 'next').exactly(5).times.and_raise(error)
69
68
  )
70
- expect(error).to receive(:retry_after).exactly(4).times.and_return(9)
71
69
  expect(cursor).to receive(:sleep).exactly(4).times.with(9)
72
70
  expect { cursor.to_a }.to raise_error(error)
73
71
  end
@@ -226,7 +226,10 @@ RSpec.describe Slack::Web::Client do
226
226
  request = nil
227
227
  response = conn.post do |r|
228
228
  r.path = 'rtm.start'
229
- r.body = { token: 'token' }
229
+ r.headers = {
230
+ 'Accept' => ['application/json; charset=utf-8'],
231
+ 'Authorization' => ['Bearer <SLACK_API_TOKEN>']
232
+ }
230
233
  request = r
231
234
  end
232
235
 
@@ -266,11 +269,9 @@ RSpec.describe Slack::Web::Client do
266
269
 
267
270
  let(:stub_slack_request) { stub_request(:post, 'https://slack.com/api/api.test') }
268
271
  let(:exception) do
269
- begin
270
- request
271
- rescue Slack::Web::Api::Errors::ServerError => e
272
- return e
273
- end
272
+ request
273
+ rescue Slack::Web::Api::Errors::ServerError => e
274
+ return e
274
275
  end
275
276
 
276
277
  context 'parsing error' do
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ class DummyClient
5
+ include Slack::Web::Faraday::Connection
6
+ include Slack::Web::Faraday::Request
7
+
8
+ attr_reader :token
9
+
10
+ def initialize(token)
11
+ @token = token
12
+ end
13
+ end
14
+
15
+ RSpec.describe Slack::Web::Faraday::Request do
16
+ let(:token) { 'by-the-power-of-grayskull' }
17
+ let(:client) { DummyClient.new(token) }
18
+
19
+ before do
20
+ Slack::Config.reset
21
+ end
22
+
23
+ context 'authorization' do
24
+ let(:path) { '/any-path' }
25
+ let(:options) { {} }
26
+ let(:connection) { instance_double('Faraday::Connection') }
27
+ let(:request) { instance_double('Faraday::Request') }
28
+ let(:headers) { instance_double('Faraday::Utils::Headers') }
29
+ let(:response) { instance_double('Faraday::Response', body: '') }
30
+
31
+ before do
32
+ allow(client).to receive(:connection).and_return(connection)
33
+ allow(request).to receive(:url).with(path, options)
34
+ allow(request).to receive(:path=).with(path)
35
+ allow(request).to receive(:headers).and_return(headers)
36
+ allow(connection).to receive(:send)
37
+ .with(method).and_yield(request).and_return(response)
38
+ end
39
+
40
+ describe '#get' do
41
+ let(:method) { :get }
42
+
43
+ it 'sets authorization header' do
44
+ expect(headers).to receive(:[]=)
45
+ .with('Authorization', "Bearer #{token}")
46
+ client.send(method, path, options)
47
+ end
48
+ end
49
+
50
+ describe '#post' do
51
+ let(:method) { :post }
52
+
53
+ it 'sets authorization header' do
54
+ expect(headers).to receive(:[]=)
55
+ .with('Authorization', "Bearer #{token}")
56
+ client.send(method, path, options)
57
+ end
58
+ end
59
+
60
+ describe '#put' do
61
+ let(:method) { :put }
62
+
63
+ it 'sets authorization header' do
64
+ expect(headers).to receive(:[]=)
65
+ .with('Authorization', "Bearer #{token}")
66
+ client.send(method, path, options)
67
+ end
68
+ end
69
+
70
+ describe '#delete' do
71
+ let(:method) { :delete }
72
+
73
+ it 'sets authorization header' do
74
+ expect(headers).to receive(:[]=)
75
+ .with('Authorization', "Bearer #{token}")
76
+ client.send(method, path, options)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -13,6 +13,7 @@ RSpec.describe Slack::Web::Faraday::Response::RaiseError do
13
13
  describe '#on_complete' do
14
14
  context 'with status of 429' do
15
15
  let(:status) { 429 }
16
+ let(:response) { OpenStruct.new(headers: { 'retry-after' => 10 }) }
16
17
 
17
18
  it 'raises a TooManyRequestsError' do
18
19
  expect { raise_error_obj.on_complete(env) }.to(
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,7 @@ Dir[File.join(File.dirname(__FILE__), 'support', '**/*.rb')].each do |file|
12
12
  end
13
13
 
14
14
  Slack.configure do |config|
15
- config.token = ENV['SLACK_API_TOKEN']
15
+ config.token = '<SLACK_API_TOKEN>' # ENV['SLACK_API_TOKEN']
16
16
  end
17
17
 
18
18
  RSpec.configure do |config|
@@ -2,13 +2,7 @@
2
2
  RSpec.shared_context 'connected client' do |opts|
3
3
  let(:client) { Slack::RealTime::Client.new(opts || {}) }
4
4
  let(:ws) { double(Slack::RealTime::Concurrency::Mock::WebSocket) }
5
- let(:url) do
6
- if Slack::RealTime.config.store_class == Slack::RealTime::Stores::Store
7
- 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid='
8
- else
9
- 'wss://mpmulti-w5tz.slack-msgs.com/websocket/uid'
10
- end
11
- end
5
+ let(:url) { 'wss://cerberus-xxxx.lb.slack-msgs.com/websocket/uid' }
12
6
  let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
13
7
 
14
8
  before do
data/spec/support/vcr.rb CHANGED
@@ -5,10 +5,41 @@ require 'webmock/rspec'
5
5
  VCR.configure do |config|
6
6
  config.cassette_library_dir = 'spec/fixtures/slack'
7
7
  config.hook_into :webmock
8
- # config.default_cassette_options = { record: :new_episodes }
9
8
  config.configure_rspec_metadata!
9
+ if ENV.key?('SLACK_API_TOKEN')
10
+ config.filter_sensitive_data('<SLACK_API_TOKEN>') do
11
+ ENV['SLACK_API_TOKEN']
12
+ end
13
+ end
10
14
  config.before_record do |i|
11
- i.request.body.gsub!(ENV['SLACK_API_TOKEN'], 'token') if ENV.key?('SLACK_API_TOKEN')
12
15
  i.response.body.force_encoding('UTF-8')
13
16
  end
17
+ config.register_request_matcher :client_headers do |recorded, actual|
18
+ authorizations = ENV.key?('SLACK_API_TOKEN') ? actual.headers['Authorization'].map do |auth|
19
+ auth.gsub(ENV['SLACK_API_TOKEN'], '<SLACK_API_TOKEN>')
20
+ end : actual.headers['Authorization']
21
+ actual.headers['Accept'] == recorded.headers['Accept'] &&
22
+ authorizations == recorded.headers['Authorization']
23
+ end
24
+ config.default_cassette_options = {
25
+ match_requests_on: %i[method uri body client_headers]
26
+ # record: :new_episodes
27
+ }
28
+ end
29
+
30
+ module VCR
31
+ module Errors
32
+ class UnhandledHTTPRequestError
33
+ private
34
+
35
+ # Force unhandled HTTP error reports to include the headers
36
+ # for our custom matcher `client_headers`.
37
+ #
38
+ # This patch can be removed if https://github.com/vcr/vcr/issues/912
39
+ # is ever resolved.
40
+ def match_request_on_headers?
41
+ true
42
+ end
43
+ end
44
+ end
14
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-07 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '10'
131
+ version: '13'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '10'
138
+ version: '13'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.82.0
159
+ version: 0.93.1
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.82.0
166
+ version: 0.93.1
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rubocop-performance
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -263,6 +263,7 @@ files:
263
263
  - bin/commands/admin_apps_approved.rb
264
264
  - bin/commands/admin_apps_requests.rb
265
265
  - bin/commands/admin_apps_restricted.rb
266
+ - bin/commands/admin_auth_policy.rb
266
267
  - bin/commands/admin_barriers.rb
267
268
  - bin/commands/admin_conversations.rb
268
269
  - bin/commands/admin_conversations_ekm.rb
@@ -283,6 +284,7 @@ files:
283
284
  - bin/commands/apps.rb
284
285
  - bin/commands/apps_connections.rb
285
286
  - bin/commands/apps_event_authorizations.rb
287
+ - bin/commands/apps_manifest.rb
286
288
  - bin/commands/apps_permissions.rb
287
289
  - bin/commands/apps_permissions_resources.rb
288
290
  - bin/commands/apps_permissions_scopes.rb
@@ -308,6 +310,7 @@ files:
308
310
  - bin/commands/mpim.rb
309
311
  - bin/commands/oauth.rb
310
312
  - bin/commands/oauth_v2.rb
313
+ - bin/commands/openid_connect.rb
311
314
  - bin/commands/pins.rb
312
315
  - bin/commands/reactions.rb
313
316
  - bin/commands/reminders.rb
@@ -315,7 +318,10 @@ files:
315
318
  - bin/commands/search.rb
316
319
  - bin/commands/stars.rb
317
320
  - bin/commands/team.rb
321
+ - bin/commands/team_billing.rb
322
+ - bin/commands/team_preferences.rb
318
323
  - bin/commands/team_profile.rb
324
+ - bin/commands/tooling_tokens.rb
319
325
  - bin/commands/usergroups.rb
320
326
  - bin/commands/usergroups_users.rb
321
327
  - bin/commands/users.rb
@@ -374,6 +380,7 @@ files:
374
380
  - lib/slack/web/api/endpoints/admin_apps_approved.rb
375
381
  - lib/slack/web/api/endpoints/admin_apps_requests.rb
376
382
  - lib/slack/web/api/endpoints/admin_apps_restricted.rb
383
+ - lib/slack/web/api/endpoints/admin_auth_policy.rb
377
384
  - lib/slack/web/api/endpoints/admin_barriers.rb
378
385
  - lib/slack/web/api/endpoints/admin_conversations.rb
379
386
  - lib/slack/web/api/endpoints/admin_conversations_ekm.rb
@@ -394,6 +401,7 @@ files:
394
401
  - lib/slack/web/api/endpoints/apps.rb
395
402
  - lib/slack/web/api/endpoints/apps_connections.rb
396
403
  - lib/slack/web/api/endpoints/apps_event_authorizations.rb
404
+ - lib/slack/web/api/endpoints/apps_manifest.rb
397
405
  - lib/slack/web/api/endpoints/apps_permissions.rb
398
406
  - lib/slack/web/api/endpoints/apps_permissions_resources.rb
399
407
  - lib/slack/web/api/endpoints/apps_permissions_scopes.rb
@@ -419,6 +427,7 @@ files:
419
427
  - lib/slack/web/api/endpoints/mpim.rb
420
428
  - lib/slack/web/api/endpoints/oauth.rb
421
429
  - lib/slack/web/api/endpoints/oauth_v2.rb
430
+ - lib/slack/web/api/endpoints/openid_connect.rb
422
431
  - lib/slack/web/api/endpoints/pins.rb
423
432
  - lib/slack/web/api/endpoints/presence.rb
424
433
  - lib/slack/web/api/endpoints/reactions.rb
@@ -427,7 +436,10 @@ files:
427
436
  - lib/slack/web/api/endpoints/search.rb
428
437
  - lib/slack/web/api/endpoints/stars.rb
429
438
  - lib/slack/web/api/endpoints/team.rb
439
+ - lib/slack/web/api/endpoints/team_billing.rb
440
+ - lib/slack/web/api/endpoints/team_preferences.rb
430
441
  - lib/slack/web/api/endpoints/team_profile.rb
442
+ - lib/slack/web/api/endpoints/tooling_tokens.rb
431
443
  - lib/slack/web/api/endpoints/usergroups.rb
432
444
  - lib/slack/web/api/endpoints/usergroups_users.rb
433
445
  - lib/slack/web/api/endpoints/users.rb
@@ -438,15 +450,11 @@ files:
438
450
  - lib/slack/web/api/endpoints/workflows.rb
439
451
  - lib/slack/web/api/error.rb
440
452
  - lib/slack/web/api/errors.rb
441
- - lib/slack/web/api/errors/internal_error.rb
453
+ - lib/slack/web/api/errors/server_error.rb
442
454
  - lib/slack/web/api/errors/slack_error.rb
443
455
  - lib/slack/web/api/errors/too_many_requests_error.rb
444
456
  - lib/slack/web/api/mixins.rb
445
- - lib/slack/web/api/mixins/channels.id.json
446
- - lib/slack/web/api/mixins/channels.id.rb
447
457
  - lib/slack/web/api/mixins/conversations.id.rb
448
- - lib/slack/web/api/mixins/groups.id.json
449
- - lib/slack/web/api/mixins/groups.id.rb
450
458
  - lib/slack/web/api/mixins/ids.id.rb
451
459
  - lib/slack/web/api/mixins/users.id.json
452
460
  - lib/slack/web/api/mixins/users.id.rb
@@ -480,10 +488,8 @@ files:
480
488
  - slack-ruby-client.gemspec
481
489
  - slack.png
482
490
  - spec/fixtures/slack/web/429_error.yml
483
- - spec/fixtures/slack/web/503_error.yml
484
491
  - spec/fixtures/slack/web/auth_test_error.yml
485
492
  - spec/fixtures/slack/web/auth_test_success.yml
486
- - spec/fixtures/slack/web/channels_info.yml
487
493
  - spec/fixtures/slack/web/conversations_info.yml
488
494
  - spec/fixtures/slack/web/conversations_setTopic.yml
489
495
  - spec/fixtures/slack/web/conversations_setTopic_one_page.yml
@@ -523,6 +529,7 @@ files:
523
529
  - spec/slack/web/api/endpoints/admin_apps_requests_spec.rb
524
530
  - spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb
525
531
  - spec/slack/web/api/endpoints/admin_apps_spec.rb
532
+ - spec/slack/web/api/endpoints/admin_auth_policy_spec.rb
526
533
  - spec/slack/web/api/endpoints/admin_barriers_spec.rb
527
534
  - spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb
528
535
  - spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb
@@ -541,17 +548,13 @@ files:
541
548
  - spec/slack/web/api/endpoints/api_spec.rb
542
549
  - spec/slack/web/api/endpoints/apps_connections_spec.rb
543
550
  - spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb
544
- - spec/slack/web/api/endpoints/apps_permissions_resources_spec.rb
545
- - spec/slack/web/api/endpoints/apps_permissions_scopes_spec.rb
546
- - spec/slack/web/api/endpoints/apps_permissions_spec.rb
547
- - spec/slack/web/api/endpoints/apps_permissions_users_spec.rb
551
+ - spec/slack/web/api/endpoints/apps_manifest_spec.rb
548
552
  - spec/slack/web/api/endpoints/apps_spec.rb
549
553
  - spec/slack/web/api/endpoints/auth_teams_spec.rb
550
554
  - spec/slack/web/api/endpoints/bots_spec.rb
551
555
  - spec/slack/web/api/endpoints/calls_participants_spec.rb
552
556
  - spec/slack/web/api/endpoints/calls_spec.rb
553
557
  - spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb
554
- - spec/slack/web/api/endpoints/conversations_spec.rb
555
558
  - spec/slack/web/api/endpoints/custom_specs/auth_spec.rb
556
559
  - spec/slack/web/api/endpoints/custom_specs/chat_spec.rb
557
560
  - spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb
@@ -563,19 +566,21 @@ files:
563
566
  - spec/slack/web/api/endpoints/files_comments_spec.rb
564
567
  - spec/slack/web/api/endpoints/files_remote_spec.rb
565
568
  - spec/slack/web/api/endpoints/files_spec.rb
566
- - spec/slack/web/api/endpoints/im_spec.rb
567
569
  - spec/slack/web/api/endpoints/migration_spec.rb
568
- - spec/slack/web/api/endpoints/mpim_spec.rb
569
570
  - spec/slack/web/api/endpoints/oauth_spec.rb
570
571
  - spec/slack/web/api/endpoints/oauth_v2_spec.rb
572
+ - spec/slack/web/api/endpoints/openid_connect_spec.rb
571
573
  - spec/slack/web/api/endpoints/pins_spec.rb
572
574
  - spec/slack/web/api/endpoints/reactions_spec.rb
573
575
  - spec/slack/web/api/endpoints/reminders_spec.rb
574
576
  - spec/slack/web/api/endpoints/rtm_spec.rb
575
577
  - spec/slack/web/api/endpoints/search_spec.rb
576
578
  - spec/slack/web/api/endpoints/stars_spec.rb
579
+ - spec/slack/web/api/endpoints/team_billing_spec.rb
580
+ - spec/slack/web/api/endpoints/team_preferences_spec.rb
577
581
  - spec/slack/web/api/endpoints/team_profile_spec.rb
578
582
  - spec/slack/web/api/endpoints/team_spec.rb
583
+ - spec/slack/web/api/endpoints/tooling_tokens_spec.rb
579
584
  - spec/slack/web/api/endpoints/usergroups_spec.rb
580
585
  - spec/slack/web/api/endpoints/usergroups_users_spec.rb
581
586
  - spec/slack/web/api/endpoints/users_admin_spec.rb
@@ -584,13 +589,12 @@ files:
584
589
  - spec/slack/web/api/endpoints/workflows_spec.rb
585
590
  - spec/slack/web/api/error_spec.rb
586
591
  - spec/slack/web/api/errors/slack_error_spec.rb
587
- - spec/slack/web/api/mixins/channels_spec.rb
588
592
  - spec/slack/web/api/mixins/conversations_list_spec.rb
589
593
  - spec/slack/web/api/mixins/conversations_spec.rb
590
- - spec/slack/web/api/mixins/groups_spec.rb
591
594
  - spec/slack/web/api/mixins/users_spec.rb
592
595
  - spec/slack/web/api/pagination/cursor_spec.rb
593
596
  - spec/slack/web/client_spec.rb
597
+ - spec/slack/web/faraday/request_spec.rb
594
598
  - spec/slack/web/faraday/response/raise_error_spec.rb
595
599
  - spec/spec_helper.rb
596
600
  - spec/support/queue_with_timeout.rb
@@ -618,128 +622,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
618
622
  - !ruby/object:Gem::Version
619
623
  version: 1.3.6
620
624
  requirements: []
621
- rubygems_version: 3.1.3
625
+ rubygems_version: 3.0.6
622
626
  signing_key:
623
627
  specification_version: 4
624
628
  summary: Slack Web and RealTime API client.
625
- test_files:
626
- - spec/fixtures/slack/web/429_error.yml
627
- - spec/fixtures/slack/web/503_error.yml
628
- - spec/fixtures/slack/web/auth_test_error.yml
629
- - spec/fixtures/slack/web/auth_test_success.yml
630
- - spec/fixtures/slack/web/channels_info.yml
631
- - spec/fixtures/slack/web/conversations_info.yml
632
- - spec/fixtures/slack/web/conversations_setTopic.yml
633
- - spec/fixtures/slack/web/conversations_setTopic_one_page.yml
634
- - spec/fixtures/slack/web/conversations_setTopic_paginated.yml
635
- - spec/fixtures/slack/web/paginated_users_list.yml
636
- - spec/fixtures/slack/web/rtm_connect.yml
637
- - spec/fixtures/slack/web/rtm_start.yml
638
- - spec/fixtures/slack/web/users_info.yml
639
- - spec/fixtures/slack/web/users_list.yml
640
- - spec/fixtures/slack/web/views_open_error.yml
641
- - spec/integration/integration_spec.rb
642
- - spec/slack/config_spec.rb
643
- - spec/slack/events/config_spec.rb
644
- - spec/slack/events/request_spec.rb
645
- - spec/slack/messages/formatting_spec.rb
646
- - spec/slack/real_time/api/message_spec.rb
647
- - spec/slack/real_time/api/ping_spec.rb
648
- - spec/slack/real_time/api/typing_spec.rb
649
- - spec/slack/real_time/client_spec.rb
650
- - spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb
651
- - spec/slack/real_time/concurrency/with_concurrency_spec.rb
652
- - spec/slack/real_time/concurrency/without_concurrency_spec.rb
653
- - spec/slack/real_time/event_handlers/bot_spec.rb
654
- - spec/slack/real_time/event_handlers/channel_spec.rb
655
- - spec/slack/real_time/event_handlers/event_handlers_spec.rb
656
- - spec/slack/real_time/event_handlers/group_spec.rb
657
- - spec/slack/real_time/event_handlers/im_spec.rb
658
- - spec/slack/real_time/event_handlers/team_spec.rb
659
- - spec/slack/real_time/event_handlers/user_spec.rb
660
- - spec/slack/real_time/rtm_connect_spec.rb
661
- - spec/slack/real_time/rtm_start_spec.rb
662
- - spec/slack/real_time/store_spec.rb
663
- - spec/slack/slack_spec.rb
664
- - spec/slack/version_spec.rb
665
- - spec/slack/web/api/endpoints/admin_analytics_spec.rb
666
- - spec/slack/web/api/endpoints/admin_apps_approved_spec.rb
667
- - spec/slack/web/api/endpoints/admin_apps_requests_spec.rb
668
- - spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb
669
- - spec/slack/web/api/endpoints/admin_apps_spec.rb
670
- - spec/slack/web/api/endpoints/admin_barriers_spec.rb
671
- - spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb
672
- - spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb
673
- - spec/slack/web/api/endpoints/admin_conversations_spec.rb
674
- - spec/slack/web/api/endpoints/admin_emoji_spec.rb
675
- - spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb
676
- - spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb
677
- - spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb
678
- - spec/slack/web/api/endpoints/admin_teams_admins_spec.rb
679
- - spec/slack/web/api/endpoints/admin_teams_owners_spec.rb
680
- - spec/slack/web/api/endpoints/admin_teams_settings_spec.rb
681
- - spec/slack/web/api/endpoints/admin_teams_spec.rb
682
- - spec/slack/web/api/endpoints/admin_usergroups_spec.rb
683
- - spec/slack/web/api/endpoints/admin_users_session_spec.rb
684
- - spec/slack/web/api/endpoints/admin_users_spec.rb
685
- - spec/slack/web/api/endpoints/api_spec.rb
686
- - spec/slack/web/api/endpoints/apps_connections_spec.rb
687
- - spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb
688
- - spec/slack/web/api/endpoints/apps_permissions_resources_spec.rb
689
- - spec/slack/web/api/endpoints/apps_permissions_scopes_spec.rb
690
- - spec/slack/web/api/endpoints/apps_permissions_spec.rb
691
- - spec/slack/web/api/endpoints/apps_permissions_users_spec.rb
692
- - spec/slack/web/api/endpoints/apps_spec.rb
693
- - spec/slack/web/api/endpoints/auth_teams_spec.rb
694
- - spec/slack/web/api/endpoints/bots_spec.rb
695
- - spec/slack/web/api/endpoints/calls_participants_spec.rb
696
- - spec/slack/web/api/endpoints/calls_spec.rb
697
- - spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb
698
- - spec/slack/web/api/endpoints/conversations_spec.rb
699
- - spec/slack/web/api/endpoints/custom_specs/auth_spec.rb
700
- - spec/slack/web/api/endpoints/custom_specs/chat_spec.rb
701
- - spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb
702
- - spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
703
- - spec/slack/web/api/endpoints/custom_specs/users_spec.rb
704
- - spec/slack/web/api/endpoints/custom_specs/views_spec.rb
705
- - spec/slack/web/api/endpoints/dnd_spec.rb
706
- - spec/slack/web/api/endpoints/emoji_spec.rb
707
- - spec/slack/web/api/endpoints/files_comments_spec.rb
708
- - spec/slack/web/api/endpoints/files_remote_spec.rb
709
- - spec/slack/web/api/endpoints/files_spec.rb
710
- - spec/slack/web/api/endpoints/im_spec.rb
711
- - spec/slack/web/api/endpoints/migration_spec.rb
712
- - spec/slack/web/api/endpoints/mpim_spec.rb
713
- - spec/slack/web/api/endpoints/oauth_spec.rb
714
- - spec/slack/web/api/endpoints/oauth_v2_spec.rb
715
- - spec/slack/web/api/endpoints/pins_spec.rb
716
- - spec/slack/web/api/endpoints/reactions_spec.rb
717
- - spec/slack/web/api/endpoints/reminders_spec.rb
718
- - spec/slack/web/api/endpoints/rtm_spec.rb
719
- - spec/slack/web/api/endpoints/search_spec.rb
720
- - spec/slack/web/api/endpoints/stars_spec.rb
721
- - spec/slack/web/api/endpoints/team_profile_spec.rb
722
- - spec/slack/web/api/endpoints/team_spec.rb
723
- - spec/slack/web/api/endpoints/usergroups_spec.rb
724
- - spec/slack/web/api/endpoints/usergroups_users_spec.rb
725
- - spec/slack/web/api/endpoints/users_admin_spec.rb
726
- - spec/slack/web/api/endpoints/users_prefs_spec.rb
727
- - spec/slack/web/api/endpoints/users_profile_spec.rb
728
- - spec/slack/web/api/endpoints/workflows_spec.rb
729
- - spec/slack/web/api/error_spec.rb
730
- - spec/slack/web/api/errors/slack_error_spec.rb
731
- - spec/slack/web/api/mixins/channels_spec.rb
732
- - spec/slack/web/api/mixins/conversations_list_spec.rb
733
- - spec/slack/web/api/mixins/conversations_spec.rb
734
- - spec/slack/web/api/mixins/groups_spec.rb
735
- - spec/slack/web/api/mixins/users_spec.rb
736
- - spec/slack/web/api/pagination/cursor_spec.rb
737
- - spec/slack/web/client_spec.rb
738
- - spec/slack/web/faraday/response/raise_error_spec.rb
739
- - spec/spec_helper.rb
740
- - spec/support/queue_with_timeout.rb
741
- - spec/support/real_time/concurrency/mock.rb
742
- - spec/support/real_time/connected_client.rb
743
- - spec/support/real_time/event.rb
744
- - spec/support/token.rb
745
- - spec/support/vcr.rb
629
+ test_files: []