lita-activedirectory 0.2.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/lita/handlers/activedirectory.rb +1 -0
- data/lita-activedirectory.gemspec +1 -1
- data/spec/lita/handlers/activedirectory_spec.rb +28 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bcc4c302e0bb34938f608adecfc61e59af84944
|
4
|
+
data.tar.gz: a51c8b92f84a66cb2b9a81ebf83b96a81e4a33f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e687c2bb220786475a9c1b8bc441cece10c41f33df9a5ec180ccc6322513cb545ead93b7ade21246d9cdcef9faa28377b2c33d4ae693c0cd78b1ff873774cbb5
|
7
|
+
data.tar.gz: 21b58e4727eac412db4a6b73f622c342fe89c1dcb18f692ea962ce827a7c3b25d3051e8068b8fa8d5d24696bb33a2c4bd0a940b6acc3f7b36a7bb9c6543483f8
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# lita-activedirectory
|
2
|
-
[![Build Status](https://travis-ci.org/knuedge/lita-activedirectory.svg?branch=master)](https://travis-ci.org/knuedge/lita-activedirectory) [![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://tldrlegal.com/license/mit-license) [![Gem](https://
|
2
|
+
[![Build Status](https://travis-ci.org/knuedge/lita-activedirectory.svg?branch=master)](https://travis-ci.org/knuedge/lita-activedirectory) [![MIT License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://tldrlegal.com/license/mit-license) [![Gem Version](https://badge.fury.io/rb/lita-activedirectory.svg)](https://badge.fury.io/rb/lita-activedirectory) [![Code Climate](https://codeclimate.com/github/knuedge/lita-activedirectory/badges/gpa.svg)](https://codeclimate.com/github/knuedge/lita-activedirectory)
|
3
3
|
|
4
4
|
A [Lita](https://www.lita.io/) handler plugin for basic interactions with Active Directory.
|
5
5
|
|
@@ -28,6 +28,8 @@ gem "lita-activedirectory"
|
|
28
28
|
### Unlock a user account
|
29
29
|
`unlock <username>`
|
30
30
|
|
31
|
+
Requires membership in `ad_admins` authorization group.
|
32
|
+
|
31
33
|
The user account specified in `config.handlers.activedirectory.username` must have permission to write the lockouttime attribute for unlocking to succeed. We leave it up to you to secure this account accordingly.
|
32
34
|
|
33
35
|
### List a User's Group Memberships
|
@@ -10,14 +10,15 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
10
10
|
registry.config.handlers.activedirectory.password = 'pass'
|
11
11
|
end
|
12
12
|
|
13
|
+
let(:lita_user) { Lita::User.create('User', name: 'A User', mention_name: 'user') }
|
14
|
+
|
13
15
|
it 'should have the necessary routes' do
|
14
16
|
is_expected.to route_command('is jdoe locked').to(:user_locked?)
|
15
17
|
is_expected.to route_command('is jdoe locked?').to(:user_locked?)
|
16
|
-
is_expected.to route_command('unlock jdoe').to(:unlock)
|
18
|
+
is_expected.to route_command('unlock jdoe').with_authorization_for(:ad_admins).to(:unlock)
|
17
19
|
is_expected.to route_command('jdoe groups').to(:user_groups)
|
18
20
|
is_expected.to route_command('group foo members').to(:group_members)
|
19
21
|
end
|
20
|
-
|
21
22
|
let(:locked_user) do
|
22
23
|
testuser = instance_double(
|
23
24
|
'Cratus::User',
|
@@ -25,6 +26,8 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
25
26
|
lockouttime: '124',
|
26
27
|
locked?: true
|
27
28
|
)
|
29
|
+
allow(Cratus::LDAP).to receive(:connect).and_return(true)
|
30
|
+
allow(Cratus::LDAP).to receive(:connection).and_return(true)
|
28
31
|
testuser
|
29
32
|
end
|
30
33
|
|
@@ -32,9 +35,12 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
32
35
|
testuser = instance_double(
|
33
36
|
'Cratus::User',
|
34
37
|
dn: 'cn=jdoe,dc=example,dc=com',
|
38
|
+
member_of: "['cn=foo,dc=example,dc=com','cn=bar,dc=example,dc=com']",
|
35
39
|
lockouttime: '0',
|
36
40
|
locked?: false
|
37
41
|
)
|
42
|
+
allow(Cratus::LDAP).to receive(:connect).and_return(true)
|
43
|
+
allow(Cratus::LDAP).to receive(:connection).and_return(true)
|
38
44
|
testuser
|
39
45
|
end
|
40
46
|
|
@@ -56,23 +62,37 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
56
62
|
end
|
57
63
|
|
58
64
|
describe '#unlock' do
|
65
|
+
before do
|
66
|
+
robot.auth.add_user_to_group!(lita_user, :ad_admins)
|
67
|
+
end
|
59
68
|
it 'unlocks the user when locked' do
|
60
|
-
allow(Cratus::LDAP).to receive(:connect).and_return(true)
|
61
|
-
allow(Cratus::LDAP).to receive(:connection).and_return(true)
|
62
69
|
allow(Cratus::User).to receive(:new).and_return(locked_user)
|
63
70
|
allow(Cratus::LDAP.connection).to receive(:replace_attribute).and_return(true)
|
64
|
-
send_command('unlock jdoe')
|
71
|
+
send_command('unlock jdoe', as: lita_user)
|
65
72
|
expect(replies.first).to eq('lets see what we can do')
|
66
73
|
expect(replies.last).to eq("'jdoe' has been unlocked")
|
67
74
|
end
|
68
75
|
it 'lets you know if the user is not locked' do
|
69
|
-
allow(Cratus::LDAP).to receive(:connect).and_return(true)
|
70
|
-
allow(Cratus::LDAP).to receive(:connection).and_return(true)
|
71
76
|
allow(Cratus::User).to receive(:new).and_return(unlocked_user)
|
72
77
|
allow(Cratus::LDAP.connection).to receive(:replace_attribute).and_return(true)
|
73
|
-
send_command('unlock jdoe')
|
78
|
+
send_command('unlock jdoe', as: lita_user)
|
74
79
|
expect(replies.first).to eq('lets see what we can do')
|
75
80
|
expect(replies.last).to eq("'jdoe' is not locked")
|
76
81
|
end
|
77
82
|
end
|
83
|
+
|
84
|
+
describe '#user_groups' do
|
85
|
+
it 'should return proper error mesage' do
|
86
|
+
allow(Cratus::User).to receive(:new).and_return(unlocked_user)
|
87
|
+
send_command('fbar groups')
|
88
|
+
expect(replies.first).to eq('Give me a second to search')
|
89
|
+
expect(replies.last)
|
90
|
+
.to eq("That did not work, double check that 'fbar' is a valid samAccountName")
|
91
|
+
end
|
92
|
+
it 'should return group membership' do
|
93
|
+
allow(Cratus::User).to receive(:new).and_return(unlocked_user)
|
94
|
+
send_command('fjdoe groups')
|
95
|
+
expect(replies.first).to eq('Give me a second to search')
|
96
|
+
end
|
97
|
+
end
|
78
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-activedirectory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schaaff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|