lita-ldap 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3167e6fec632522988a1c129cc05aa2939e47ee3
4
+ data.tar.gz: 3fbf2d94042554e7eaa663c3513fc8ef8f01fb0a
5
+ SHA512:
6
+ metadata.gz: f08e28135ac41a108d49a642b33b9626c4a9719f7348c2d71e483f046262c317265735e0d04f01f9d10b79f9376b5268366f0397d2c20d307fd4021ea47b422b
7
+ data.tar.gz: d3a45ddb8ff0d6a46ffa6b8c55224d4c5b0e1d34b4e62de2b89efad9762f452b34d41bb4e9a7460df60c4f5ecdd3559fb9911b843bd0b7a4b51787d3437d863c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # lita-ldap
2
+
3
+ Lita handler for ldap operations.
4
+ ## Installation
5
+
6
+ Add lita-ldap to your Lita instance's Gemfile:
7
+
8
+ ``` ruby
9
+ gem "lita-ldap"
10
+ ```
11
+
12
+ ## Configuration
13
+
14
+ ```ruby
15
+ Lita.configure do |config|
16
+ #required
17
+ config.handlers.ldap.host = 'localhost'
18
+ config.handlers.ldap.port = 1389
19
+ config.handlers.ldap.bind_dn = 'cn=admin,dc=ldap,dc=example,dc=com'
20
+ config.handlers.ldap.bind_password = 'admin'
21
+ config.handlers.ldap.base_dn = 'dc=ldap,dc=example,dc=com'
22
+
23
+ config.handlers.ldap.user_base_dn = 'ou=people' # append before base_dn
24
+ config.handlers.ldap.group_base_dn = 'ou=groups' # append before base_dn
25
+ end
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ * lita search user nexus
31
+ * lita search group nx-admin
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,26 @@
1
+ require 'net/ldap'
2
+ module LitaLDAPHelper
3
+ module Group
4
+ def search_group(str)
5
+ filter_str_templ = "(&#{config.group_search_filter}#{config.group_object_filter})"
6
+ #filter_str_templ = "#{config.user_search_filter}"
7
+ filter_str = filter_str_templ % { s:str}
8
+ tree_base = "#{config.group_base_dn},#{config.base_dn}"
9
+ puts "search base_dn : #{tree_base} with filter_str #{filter_str}"
10
+ filter=Net::LDAP::Filter.construct(filter_str)
11
+ return_attributes = config.user_attributes || config.default_attributes
12
+ return_attributes = return_attributes.split(',')
13
+ entries = client.search(:base => tree_base, :filter => filter, :attributes =>return_attributes , :return_result => true)
14
+ results = []
15
+ unless entries.nil?
16
+ entries.each do |entry|
17
+ results << entry.to_ldif
18
+ results << '*********'
19
+ end
20
+ end
21
+ #puts results
22
+ results
23
+ end # end function search_usr
24
+
25
+ end#Misc
26
+ end#LitaLDAPHelper
@@ -0,0 +1,21 @@
1
+ require 'net/ldap'
2
+ module LitaLDAPHelper
3
+ module Misc
4
+ def client
5
+ puts "config: #{config.bind_dn} with #{config.bind_password}"
6
+ ldap = Net::LDAP.new :host => config.host,
7
+ :port => config.port,
8
+ :auth =>{
9
+ :method => config.auth_method.to_sym,
10
+ :username => config.bind_dn,
11
+ :password => config.bind_password
12
+ }
13
+
14
+ if ldap.bind
15
+ ldap
16
+ else
17
+ raise "Cannot connect to ldap server"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ require 'net/ldap'
2
+ module LitaLDAPHelper
3
+ module User
4
+ def search_user(str)
5
+ filter_str_templ = "(&#{config.user_search_filter}#{config.user_object_filter})"
6
+ #filter_str_templ = "#{config.user_search_filter}"
7
+ filter_str = filter_str_templ % { s:str}
8
+ puts filter_str
9
+
10
+ tree_base = "#{config.user_base_dn},#{config.base_dn}"
11
+ puts "search base_dn : #{tree_base}"
12
+ filter=Net::LDAP::Filter.construct(filter_str)
13
+ return_attributes = config.user_attributes || config.default_attributes
14
+ return_attributes = return_attributes.split(',')
15
+ entries = client.search(:base => tree_base, :filter => filter, :attributes =>return_attributes , :return_result => true)
16
+ results = []
17
+ unless entries.nil?
18
+ entries.each do |entry|
19
+ results << entry.to_ldif
20
+ results << '*********'
21
+ end
22
+ end
23
+ #puts results
24
+ results
25
+ end # end function search_usr
26
+
27
+ end#Misc
28
+ end#LitaLDAPHelper
@@ -0,0 +1,75 @@
1
+ # require 'rubygems'
2
+ # require 'net/ldap'
3
+
4
+ module Lita
5
+ module Handlers
6
+ class Ldap < Handler
7
+ # insert handler code here
8
+ namespace 'Ldap'
9
+
10
+ config :host, required: true, type: String
11
+ config :port, required: false, type: Integer, default: 389
12
+ config :bind_dn, required: true, type: String
13
+ config :bind_password, required: true, type: String
14
+ config :auth_method, required: false, type: String, default: 'simple'
15
+ # encryption = {
16
+ # :method => :start_tls,
17
+ # :tls_options => { :ca_file => "/etc/cafile.pem", :ssl_version => "TLSv1_1" }
18
+ # }
19
+ config :encryption, required: false, type: Hash, default: {}
20
+
21
+ config :base_dn, required: true, type: String
22
+ config :user_base_dn, required: true, type: String #ou=people, dc=example,dc=net
23
+ config :username_attribute, required: false, type: String, default: 'uid'
24
+ config :default_attributes, required: false, type: String, default: 'dc,o,ou,cn,uid,mail,member,uniquemember,memberof,sAMAccountName, primaryGroupToken,primaryGroupID'
25
+ config :user_object_filter, required: false, type: String, default: '(|(objectclass=user)(objectclass=person)(objectclass=inetOrgPerson)(objectclass=organizationalPerson))'
26
+ config :user_search_filter, required: true, type: String, default: '(|(cn=%{s})(uid=%{s})(userPrincipalName=%{s})(mail=%{s}))'
27
+ config :user_member_attributes, required: false, type: String, default: 'memberof,primaryGroupID'
28
+ config :user_attributes, required: false, type: String, default: 'dn,cn,uid,mail, member, memberof,sn,givenName,loginshell,homedirectory, gidNumber,title,uidNumber,gecos,objectclass'
29
+
30
+ config :group_base_dn, required: true, type: String #ou=group, dc=example,dc=net
31
+ config :group_object_filter, required: false, type: String, default: '(|(objectclass=group)(objectclass=groupofnames) (objectclass=groupofuniquenames))'
32
+ config :group_search_filter, required: false, type: String, default: '(|(o=%{s})(ou=%{s})(cn=%{s}))'
33
+ config :group_member_attributes, required: false, type: String, default: 'member, uniquemember'
34
+
35
+
36
+ include ::LitaLDAPHelper::Misc
37
+ include ::LitaLDAPHelper::User
38
+ include ::LitaLDAPHelper::Group
39
+
40
+ route(
41
+ /^ldap\s+search\s+user\s+(\S+)$/,
42
+ :cmd_search_user,
43
+ command: true,
44
+ help: {
45
+ t('help.cmd_search_user_key') => t('help.cmd_search_user_value')
46
+ }
47
+ )
48
+
49
+ route(
50
+ /^ldap\s+search\s+group\s+(\S+)$/,
51
+ :cmd_search_group,
52
+ command: true,
53
+ help: {
54
+ t('help.cmd_search_group_key') => t('help.cmd_search_group_value')
55
+ }
56
+ )
57
+
58
+ def cmd_search_user(response)
59
+ search_string = response.matches[0][0]
60
+ #logger.info "searching user with #{search_string}"
61
+ results = search_user(search_string)
62
+ response.reply results
63
+ end
64
+
65
+ def cmd_search_group(response)
66
+ search_string = response.matches[0][0]
67
+ #logger.debug "searching group with #{search_string}"
68
+ results = search_group(search_string)
69
+ response.reply results
70
+ end
71
+
72
+ Lita.register_handler(self)
73
+ end #class
74
+ end # module
75
+ end #module
data/lib/lita-ldap.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "lita"
2
+ require 'lita/logger'
3
+
4
+ Lita.load_locales Dir[File.expand_path(
5
+ File.join("..", "..", "locales", "*.yml"), __FILE__
6
+ )]
7
+
8
+
9
+ require 'ldaphelper/misc.rb'
10
+ require 'ldaphelper/user.rb'
11
+ require 'ldaphelper/group.rb'
12
+ require "lita/handlers/ldap"
13
+
14
+ Lita::Handlers::Ldap.template_root File.expand_path(
15
+ File.join("..", "..", "templates"),
16
+ __FILE__
17
+ )
data/lita-ldap.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-ldap"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Wang, Dawei"]
5
+ spec.email = ["daweiwang.gatekeeper@gmail.com"]
6
+ spec.description = "Lita LDAP operations like search user and group."
7
+ spec.summary = "LDAP operations for Lita Chatbot"
8
+ spec.homepage = "https://github.com/af6140/lita-ldap"
9
+ spec.license = "Apache-2.0"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "rack", "~> 1.6" #set to 1.6 so that we can run under ruby 2.1
18
+ spec.add_runtime_dependency "lita", ">= 4.7"
19
+ spec.add_runtime_dependency 'net-ldap', ">= 0.14"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ #spec.add_development_dependency "pry-byebug"
23
+ spec.add_development_dependency "rake"
24
+ #spec.add_development_dependency "rack-test"
25
+ spec.add_development_dependency "rspec", ">= 3.0.0"
26
+ spec.add_development_dependency "docker-api"
27
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,8 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ ldap:
5
+ cmd_search_user_key: 'ldap search user SEARCH_STRING'
6
+ cmd_search_user_value: 'Search user with search string'
7
+ cmd_search_group_key: 'ldap search user SEARCH_STRING'
8
+ cmd_search_group_value: 'Search user with search string'
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+ require 'docker'
3
+
4
+ describe Lita::Handlers::Ldap, lita_handler: true do
5
+
6
+ before :all do
7
+ @image = Docker::Image.create('fromImage' => 'accenture/adop-ldap:0.1.2')
8
+ #check docker image documentation
9
+
10
+ #see docker image documentation
11
+ # some password need to be of complexity
12
+ default_account_settings = [
13
+ 'SLAPD_PASSWORD=admin',
14
+ 'INITIAL_ADMIN_USER=admin_user',
15
+ 'INITIAL_ADMIN_PASSWORD=Jpk66g63ZifGYIcShSGM',
16
+ 'GERRIT_PASSWORD=Jpk66g63ZifGYIcShSGM',
17
+ 'JENKINS_PASSWORD=Jpk66g63ZifGYIcShSGM',
18
+ ]
19
+
20
+ @container = Docker::Container.create( 'Image' => 'accenture/adop-ldap:latest',
21
+ 'Env'=> default_account_settings,
22
+ 'ExposedPorts' => {
23
+ '389/tcp' => {}
24
+ },
25
+ 'HostConfig' => {
26
+ 'PortBindings' => { '389/tcp' => [{ 'HostPort' => '1389' }] }
27
+ }
28
+ )
29
+ @container.rename('lita_ldap')
30
+ @container.start
31
+ sleep 5
32
+ #@container.logs(stdout: true)
33
+
34
+ puts "****** Start lita_ldap container ******"
35
+
36
+ end
37
+ #
38
+ after :all do
39
+ puts "****** Stop lita_ldap container ******"
40
+ @container.stop
41
+ sleep 2
42
+ @container.delete(:force => true)
43
+ end
44
+
45
+ before do
46
+ registry.config.handlers.ldap.host = 'localhost'
47
+ registry.config.handlers.ldap.port = 1389
48
+ registry.config.handlers.ldap.bind_dn = 'cn=admin,dc=ldap,dc=example,dc=com'
49
+ registry.config.handlers.ldap.bind_password = 'admin'
50
+ registry.config.handlers.ldap.base_dn = 'dc=ldap,dc=example,dc=com'
51
+ registry.config.handlers.ldap.user_base_dn = 'ou=people'
52
+ registry.config.handlers.ldap.group_base_dn = 'ou=groups'
53
+ end
54
+
55
+ it do
56
+ is_expected.to route_command('ldap search user nexus').to(:cmd_search_user)
57
+ is_expected.to route_command('ldap search group nx-admin').to(:cmd_search_group)
58
+ end
59
+
60
+ describe '#search user' do
61
+ it 'search user' do
62
+ send_command("ldap search user nexus")
63
+ puts replies
64
+ end
65
+ end
66
+
67
+ describe '#search group' do
68
+ it 'search group' do
69
+ send_command("ldap search group nx-admin")
70
+ puts replies
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,13 @@
1
+ require "lita-ldap"
2
+ require "lita/rspec"
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
7
+
8
+ RSpec.configure do |config|
9
+ config.before do
10
+ registry.register_handler(Lita::Handlers::Ldap)
11
+ #registry.register_hook(:trigger_route, Lita::Extensions::KeywordArguments)
12
+ end
13
+ end
File without changes
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-ldap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wang, Dawei
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: lita
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: net-ldap
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0.14'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: docker-api
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Lita LDAP operations like search user and group.
112
+ email:
113
+ - daweiwang.gatekeeper@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - LICENSE
121
+ - README.md
122
+ - Rakefile
123
+ - lib/ldaphelper/group.rb
124
+ - lib/ldaphelper/misc.rb
125
+ - lib/ldaphelper/user.rb
126
+ - lib/lita-ldap.rb
127
+ - lib/lita/handlers/ldap.rb
128
+ - lita-ldap.gemspec
129
+ - locales/en.yml
130
+ - spec/lita/handlers/ldap_spec.rb
131
+ - spec/spec_helper.rb
132
+ - templates/.gitkeep
133
+ homepage: https://github.com/af6140/lita-ldap
134
+ licenses:
135
+ - Apache-2.0
136
+ metadata:
137
+ lita_plugin_type: handler
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.4.3
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: LDAP operations for Lita Chatbot
158
+ test_files:
159
+ - spec/lita/handlers/ldap_spec.rb
160
+ - spec/spec_helper.rb