slack_sign_in 0.1.0 → 0.1.3.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab3441efeb6969dabc184dd1410341c307a0160f22bab3b72162a59c80adfd83
4
- data.tar.gz: 07fe6499c9c387dacdba2723b3270a7f59ab37d078831a788b561701c0a49e8d
3
+ metadata.gz: d3eedae0b2cfe987cb083c1d056a144fc8ce9f408254bbfed065662c1ac7841e
4
+ data.tar.gz: f50afab462ee8c2d3c0990dad9809d6abd2ddf9503abb13db166588175eb8af0
5
5
  SHA512:
6
- metadata.gz: 66b5d9e3dc895c00ebe4da4e06b72edbd87fe12ca8232230bef3ebd9b6f0b710d2407c9b20aa2bb32e64dc6c6128389156f8ad2bde6fb38948ce22ed0f47b0c1
7
- data.tar.gz: 6edbf7498bda10084266dd77c456a35c8f3c52274976420181905f3cd6e25d5e61684c3857ee9335663a001b9f8b6dc78ec0539dfb300e71672c2047a9264662
6
+ metadata.gz: 53e178b38f88ec229c38ae8771aef4e414c9cffe0d69e26374686aa2b14d37f52a86a5355334b8fc1ee20232a5142fd2a4e40655984855047cab350272b245fd
7
+ data.tar.gz: 3b8e0e581c982d2609bc2e8f664f16ba2fcc44380961725cc59d079f59f0a4b24adc09fd0948f941345d87c61325021c77f03a48c542a0ac66fd4ad2660731b8
data/README.md CHANGED
@@ -16,6 +16,8 @@ This project adheres to the Contributor Covenant
16
16
  uphold this code. Please report unacceptable behavior to
17
17
  research@teecom.com.
18
18
 
19
+ In addition to the documentation here, we also have a **[Getting Started with `slack_sign_in`](https://vimeo.com/387819353)** video :movie_camera:.
20
+
19
21
  ## Installation
20
22
 
21
23
  Add `slack_sign_in` to your Rails app's Gemfile and run `bundle install`:
data/Rakefile CHANGED
@@ -15,4 +15,4 @@ Rake::TestTask.new(:test) do |t|
15
15
  t.warning = false
16
16
  end
17
17
 
18
- task default: :test
18
+ task default: [:test, :standard]
@@ -5,7 +5,7 @@ module SlackSignIn
5
5
  private
6
6
 
7
7
  def client
8
- @_client ||= OAuth2::Client.new(
8
+ @_client ||= SlackSignIn.client.new(
9
9
  SlackSignIn.client_id,
10
10
  SlackSignIn.client_secret,
11
11
  authorize_url: SlackSignIn::AUTHORIZE_URL,
@@ -18,6 +18,6 @@ class SlackSignIn::AuthorizationsController < SlackSignIn::ApplicationController
18
18
  end
19
19
 
20
20
  def state
21
- @_state ||= SecureRandom.base64(24)
21
+ @_state ||= SecureRandom.urlsafe_base64(24)
22
22
  end
23
23
  end
@@ -7,5 +7,5 @@ module SlackSignIn
7
7
  TOKEN_URL = "https://slack.com/api/oauth.access"
8
8
 
9
9
  mattr_accessor :client_id, :client_secret
10
- mattr_accessor :scopes
10
+ mattr_accessor :scopes, :client
11
11
  end
@@ -1,4 +1,5 @@
1
1
  require "oauth2"
2
+ require "slack_sign_in/test_client"
2
3
 
3
4
  module SlackSignIn
4
5
  class Engine < ::Rails::Engine
@@ -11,6 +12,7 @@ module SlackSignIn
11
12
  SlackSignIn.client_id = config.slack_sign_in.client_id || app.credentials.dig(:slack_sign_in, :client_id)
12
13
  SlackSignIn.client_secret = config.slack_sign_in.client_secret || app.credentials.dig(:slack_sign_in, :client_secret)
13
14
  SlackSignIn.scopes = config.slack_sign_in.scopes || SlackSignIn::DEFAULT_SCOPES
15
+ SlackSignIn.client = config.slack_sign_in.client || OAuth2::Client
14
16
  end
15
17
  end
16
18
 
@@ -0,0 +1,15 @@
1
+ require "minitest/mock"
2
+
3
+ module SlackSignIn::SystemTestHelpers
4
+ def mock_successful_authorization(identity_info, &block)
5
+ SlackSignIn::TestClient.stub(
6
+ :identity_info,
7
+ SlackSignIn::TestClient.identity_info.merge(identity_info),
8
+ &block
9
+ )
10
+ end
11
+
12
+ def mock_failed_authorization(error, &block)
13
+ SlackSignIn::TestClient.stub(:error_code, error, &block)
14
+ end
15
+ end
@@ -0,0 +1,45 @@
1
+ module SlackSignIn
2
+ class TestClient
3
+ def self.error_code
4
+ nil
5
+ end
6
+
7
+ def self.identity_info
8
+ {
9
+ team_id: "team_id_123",
10
+ user_id: "user_id_123",
11
+ user: {
12
+ name: "Example User",
13
+ email: "example@email.com",
14
+ image_48: "http://avatar.com",
15
+ },
16
+ }
17
+ end
18
+
19
+ def initialize(_, _, authorize_url:, token_url:, redirect_uri:)
20
+ @redirect_uri = redirect_uri
21
+ end
22
+
23
+ def auth_code
24
+ self
25
+ end
26
+
27
+ def authorize_url(scope:, state:)
28
+ base_url = @redirect_uri + "?state=#{state}&"
29
+
30
+ if (error = self.class.error_code)
31
+ base_url + "&error=#{error}"
32
+ else
33
+ base_url + "&code=123"
34
+ end
35
+ end
36
+
37
+ def get_token(_)
38
+ self
39
+ end
40
+
41
+ def params
42
+ self.class.identity_info
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module SlackSignIn
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.3.rc1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack_sign_in
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Schaefer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -113,6 +113,8 @@ files:
113
113
  - config/routes.rb
114
114
  - lib/slack_sign_in.rb
115
115
  - lib/slack_sign_in/engine.rb
116
+ - lib/slack_sign_in/minitest.rb
117
+ - lib/slack_sign_in/test_client.rb
116
118
  - lib/slack_sign_in/version.rb
117
119
  homepage: https://github.com/teecom/slack_sign_in
118
120
  licenses:
@@ -129,11 +131,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
131
  version: '0'
130
132
  required_rubygems_version: !ruby/object:Gem::Requirement
131
133
  requirements:
132
- - - ">="
134
+ - - ">"
133
135
  - !ruby/object:Gem::Version
134
- version: '0'
136
+ version: 1.3.1
135
137
  requirements: []
136
- rubygems_version: 3.0.3
138
+ rubygems_version: 3.1.2
137
139
  signing_key:
138
140
  specification_version: 4
139
141
  summary: Sign in (or up) with Slack for Rails applications