lita-gauth 0.1.0.3 → 0.1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/lita/handlers/gauth.rb +9 -12
- data/lita-gauth.gemspec +1 -1
- data/spec/lita/handlers/gauth_spec.rb +20 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d158c285f8d693c0e0e5f32c5fdfd845380b5b669d869db9208b7c71ccf150
|
4
|
+
data.tar.gz: 601e25c6651dfe49377d26e21bd8bd8a311403eb326343e1e3be89ac640f4c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f86816edbaf22303c231eb806f837f0b37002051e1a6ac7956252d43e106780c6372ad777c8bd1ce260760b91cd87bf40eb20a5a063889756dcf30d5c1cf39b
|
7
|
+
data.tar.gz: 569c3e5861cab69b98bb81a2ac4bf85410bb1261a6a19818159e2ba5157597e4414f3992ac2bcc3f19d1bc323752b8a182ca0de3b061e7cbf8f8f9443bb35de8
|
data/.gitignore
CHANGED
data/lib/lita/handlers/gauth.rb
CHANGED
@@ -2,15 +2,14 @@ require 'google_auth_box'
|
|
2
2
|
module Lita
|
3
3
|
module Handlers
|
4
4
|
class Gauth < Handler
|
5
|
-
config :secret_key, required: true
|
6
|
-
|
7
5
|
config :client_id_hash, required: true
|
8
6
|
|
9
7
|
config :scopes, required: true
|
10
8
|
|
11
9
|
config :data_file_path, required: true
|
12
10
|
|
13
|
-
config :
|
11
|
+
config :base_domain, required: true
|
12
|
+
config :oauth_redir_path, required: true
|
14
13
|
|
15
14
|
route(/^authed\?$/, :check_auth, command: true)
|
16
15
|
route(/^auth me$/, :request_auth, command: true)
|
@@ -20,12 +19,6 @@ module Lita
|
|
20
19
|
http.get 'auth-root/:id', :auth_root
|
21
20
|
http.get 'auth-save/:user_id/', :auth_save
|
22
21
|
|
23
|
-
def bar(msg)
|
24
|
-
p 'called'
|
25
|
-
p config.secret_key
|
26
|
-
msg.reply "hey there"
|
27
|
-
end
|
28
|
-
|
29
22
|
def get_user_creds(user_id)
|
30
23
|
auth_client.get_creds user_id
|
31
24
|
end
|
@@ -48,7 +41,7 @@ module Lita
|
|
48
41
|
attrs = {
|
49
42
|
storage_key: 'lita_gauth_user_id',
|
50
43
|
code: req.params["code"],
|
51
|
-
base_url:
|
44
|
+
base_url: build_redir_url
|
52
45
|
}
|
53
46
|
resp.body << render_template("auth_redir.html", attrs)
|
54
47
|
end
|
@@ -70,16 +63,20 @@ module Lita
|
|
70
63
|
end
|
71
64
|
|
72
65
|
def request_auth(msg)
|
73
|
-
url = "#{config.
|
66
|
+
url = "#{config.base_domain}/auth-root"
|
74
67
|
msg.reply "Click the followin link to do the thing! #{url}"
|
75
68
|
end
|
76
69
|
|
70
|
+
def build_redir_url
|
71
|
+
"#{config.base_domain}#{config.oauth_redir_path}"
|
72
|
+
end
|
73
|
+
|
77
74
|
def auth_client
|
78
75
|
@_auth_client ||=GoogleAuthBox::Client.new(
|
79
76
|
client_id_hash: config.client_id_hash,
|
80
77
|
scopes: config.scopes,
|
81
78
|
data_file_path: config.data_file_path,
|
82
|
-
base_uri:
|
79
|
+
base_uri: build_redir_url
|
83
80
|
)
|
84
81
|
end
|
85
82
|
|
data/lita-gauth.gemspec
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require 'byebug'
|
2
3
|
|
3
4
|
describe Lita::Handlers::Gauth, lita_handler: true do
|
4
5
|
let(:robot) { Lita::Robot.new(registry) }
|
5
6
|
let(:file_path) { './test_file_path' }
|
6
|
-
let(:
|
7
|
-
|
8
|
-
let(:handler) {
|
7
|
+
let(:base_domain) { "http://uri.com/virgil" }
|
8
|
+
let(:oauth_redir_path) { "/auth-redir" }
|
9
|
+
let(:handler) { Lita::Handlers::Gauth.new robot }
|
10
|
+
# subject { Lita::Handlers::Gauth.new(robot) }
|
11
|
+
subject { handler }
|
9
12
|
|
10
13
|
before do
|
11
14
|
robot.config.handlers.gauth.client_id_hash = {
|
@@ -16,7 +19,8 @@ describe Lita::Handlers::Gauth, lita_handler: true do
|
|
16
19
|
}
|
17
20
|
|
18
21
|
robot.config.handlers.gauth.scopes = ["sheets"]
|
19
|
-
robot.config.handlers.gauth.
|
22
|
+
robot.config.handlers.gauth.base_domain = base_domain
|
23
|
+
robot.config.handlers.gauth.oauth_redir_path = oauth_redir_path
|
20
24
|
File.delete file_path if File.exist? file_path
|
21
25
|
f = File.new file_path, 'w'
|
22
26
|
f.close
|
@@ -40,9 +44,14 @@ describe Lita::Handlers::Gauth, lita_handler: true do
|
|
40
44
|
subject.check_auth auth_spy
|
41
45
|
end
|
42
46
|
|
47
|
+
it 'can get the right auth url' do
|
48
|
+
send_message "Lita authed?"
|
49
|
+
expect(replies.last).to match handler.build_redir_url
|
50
|
+
end
|
51
|
+
|
43
52
|
it 'listens for authorization requests' do
|
44
53
|
send_message "Lita auth me"
|
45
|
-
expect(replies.last).to match(
|
54
|
+
expect(replies.last).to match(base_domain)
|
46
55
|
expect(replies.last).to match("auth-root")
|
47
56
|
end
|
48
57
|
end
|
@@ -51,10 +60,10 @@ describe Lita::Handlers::Gauth, lita_handler: true do
|
|
51
60
|
let(:user_id) { 5 }
|
52
61
|
let(:auth_url) { "/auth-root/#{user_id}" }
|
53
62
|
let(:storage_key) { "lita_gauth_user_id" }
|
63
|
+
let(:redir_url) { build_redir_url }
|
54
64
|
it { is_expected.to route_http(:get, "/auth-root/#{user_id}").to :auth_root }
|
55
|
-
let(:resp) { resp = http.get auth_url }
|
56
65
|
|
57
|
-
subject {
|
66
|
+
subject { http.get(auth_url).body }
|
58
67
|
|
59
68
|
it { is_expected.not_to be_empty }
|
60
69
|
|
@@ -62,7 +71,9 @@ describe Lita::Handlers::Gauth, lita_handler: true do
|
|
62
71
|
|
63
72
|
it { is_expected.to match storage_key }
|
64
73
|
|
65
|
-
it { is_expected.to match
|
74
|
+
it { is_expected.to match base_domain }
|
75
|
+
|
76
|
+
it { is_expected.to match handler.build_redir_url }
|
66
77
|
end
|
67
78
|
|
68
79
|
describe "#oauth_callback" do
|
@@ -81,7 +92,7 @@ describe Lita::Handlers::Gauth, lita_handler: true do
|
|
81
92
|
|
82
93
|
it { is_expected.to match code }
|
83
94
|
|
84
|
-
it { is_expected.to match
|
95
|
+
it { is_expected.to match base_domain }
|
85
96
|
|
86
97
|
xit 'saves the api code' do
|
87
98
|
code = '4/er7394sadfasdf'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-gauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Axylos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|