ladle 0.1.0-java → 0.1.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/README.md +12 -3
- data/lib/ladle/default.ldif +53 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Main$1.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Main.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Main.java +6 -1
- data/lib/ladle/java/net/detailedbalance/ladle/Server.class +0 -0
- data/lib/ladle/java/net/detailedbalance/ladle/Server.java +6 -2
- data/lib/ladle/server.rb +15 -2
- data/lib/ladle/version.rb +1 -1
- data/spec/ladle/server_spec.rb +134 -59
- metadata +16 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.1.1
|
2
|
+
=====
|
3
|
+
|
4
|
+
- Allowed disabling anonymous access to the server. See the
|
5
|
+
`:allow_anonymous` option on {Ladle::Server#initialize}.
|
6
|
+
- Added passwords to default people.
|
7
|
+
- Internal: ensured that specs properly close sockets so that the
|
8
|
+
suite will pass on Linux.
|
9
|
+
|
1
10
|
0.1.0
|
2
11
|
=====
|
3
12
|
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ It is a wrapper around [ApacheDS][] (a pure-java embeddable LDAP
|
|
14
14
|
server), so it needs Java 1.5 or later available whether you are using
|
15
15
|
JRuby or not.
|
16
16
|
|
17
|
-
[ApacheDS]: http://directory.apache.org/apacheds/1.
|
17
|
+
[ApacheDS]: http://directory.apache.org/apacheds/1.0/index.html
|
18
18
|
|
19
19
|
Ladle in 30 seconds
|
20
20
|
-------------------
|
@@ -106,11 +106,20 @@ default data. You can peruse it in `lib/ladle/default.ldif`.
|
|
106
106
|
|
107
107
|
Note also that you will usually need to provide both the `:ldif` and
|
108
108
|
`:domain` configuration parameters. The latter must be the domain
|
109
|
-
matching the data in the former. (N.b. the implicit
|
110
|
-
the data to a single domain.)
|
109
|
+
component (dc) matching the data in the former. (N.b. the implicit
|
110
|
+
restriction of the data to a single domain.)
|
111
111
|
|
112
112
|
[rfc2849]: http://tools.ietf.org/rfc/rfc2849.txt
|
113
113
|
|
114
|
+
Project links
|
115
|
+
-------------
|
116
|
+
|
117
|
+
* [API documentation](http://rubydoc.info/github/rsutphin/ladle/master/frames)
|
118
|
+
* [Continuous integration](https://ctms-ci.nubic.northwestern.edu/hudson/job/ladle/)
|
119
|
+
* [Issue tracking](http://github.com/rsutphin/ladle/issues)
|
120
|
+
|
121
|
+
Non-issue questions can be sent to rhett@detailedbalance.net.
|
122
|
+
|
114
123
|
About
|
115
124
|
-----
|
116
125
|
|
data/lib/ladle/default.ldif
CHANGED
@@ -15,6 +15,8 @@ sn: Adams
|
|
15
15
|
givenName: Alexandra
|
16
16
|
mail: alexandra@example.org
|
17
17
|
uid: aa729
|
18
|
+
# Password is "smada"
|
19
|
+
userpassword: {SHA}pGlmZX1VOEdHHb30HZezeVNFxGM=
|
18
20
|
|
19
21
|
dn: uid=bb459,ou=people,dc=example,dc=org
|
20
22
|
objectClass: top
|
@@ -26,6 +28,8 @@ sn: Baldwin
|
|
26
28
|
givenName: Belle
|
27
29
|
mail: belle@example.org
|
28
30
|
uid: bb459
|
31
|
+
# Password is "niwdlab"
|
32
|
+
userpassword: {SHA}LRif2N+5TDSaO/rdkH2HHF8fF74=
|
29
33
|
|
30
34
|
dn: uid=cc414,ou=people,dc=example,dc=org
|
31
35
|
objectClass: top
|
@@ -37,6 +41,8 @@ sn: Carpenter
|
|
37
41
|
givenName: Claire
|
38
42
|
mail: claire@example.org
|
39
43
|
uid: cc414
|
44
|
+
# Password is "retneprac"
|
45
|
+
userpassword: {SHA}UL/iS+2R7GhwbhXOWoTHd4/qoMA=
|
40
46
|
|
41
47
|
dn: uid=dd945,ou=people,dc=example,dc=org
|
42
48
|
objectClass: top
|
@@ -48,6 +54,8 @@ sn: Dawson
|
|
48
54
|
givenName: Dorothy
|
49
55
|
mail: dorothy@example.org
|
50
56
|
uid: dd945
|
57
|
+
# Password is "noswad"
|
58
|
+
userpassword: {SHA}D0UlcTfbCddFLwih04ig4DEilAc=
|
51
59
|
|
52
60
|
dn: uid=ee855,ou=people,dc=example,dc=org
|
53
61
|
objectClass: top
|
@@ -59,6 +67,8 @@ sn: Emerson
|
|
59
67
|
givenName: Elizabeth
|
60
68
|
mail: elizabeth@example.org
|
61
69
|
uid: ee855
|
70
|
+
# Password is "nosreme"
|
71
|
+
userpassword: {SHA}pheE9wd/iTps6f8bJjM6AePjwrU=
|
62
72
|
|
63
73
|
dn: uid=ff531,ou=people,dc=example,dc=org
|
64
74
|
objectClass: top
|
@@ -70,6 +80,8 @@ sn: Fuller
|
|
70
80
|
givenName: Freya
|
71
81
|
mail: freya@example.org
|
72
82
|
uid: ff531
|
83
|
+
# Password is "relluf"
|
84
|
+
userpassword: {SHA}HLU2WZjFf/PF0Pp4qSDzoB3x+bs=
|
73
85
|
|
74
86
|
dn: uid=gg855,ou=people,dc=example,dc=org
|
75
87
|
objectClass: top
|
@@ -81,6 +93,8 @@ sn: Gonzales
|
|
81
93
|
givenName: Grace
|
82
94
|
mail: grace@example.org
|
83
95
|
uid: gg855
|
96
|
+
# Password is "selaznog"
|
97
|
+
userpassword: {SHA}zT4oO9pFXIj+ISIc60bvM8A5+UQ=
|
84
98
|
|
85
99
|
dn: uid=hh153,ou=people,dc=example,dc=org
|
86
100
|
objectClass: top
|
@@ -92,6 +106,8 @@ sn: Hatfield
|
|
92
106
|
givenName: Hilda
|
93
107
|
mail: hilda@example.org
|
94
108
|
uid: hh153
|
109
|
+
# Password is "dleiftah"
|
110
|
+
userpassword: {SHA}PTDJLPy4kwa7VZ/sGLyCPzZ7d3o=
|
95
111
|
|
96
112
|
dn: uid=ii711,ou=people,dc=example,dc=org
|
97
113
|
objectClass: top
|
@@ -103,6 +119,8 @@ sn: Ingram
|
|
103
119
|
givenName: Iona
|
104
120
|
mail: iona@example.org
|
105
121
|
uid: ii711
|
122
|
+
# Password is "margni"
|
123
|
+
userpassword: {SHA}L7qElLblWuLNFPrFku60uCuCr7Q=
|
106
124
|
|
107
125
|
dn: uid=jj243,ou=people,dc=example,dc=org
|
108
126
|
objectClass: top
|
@@ -114,6 +132,8 @@ sn: Jackson
|
|
114
132
|
givenName: Josephine
|
115
133
|
mail: josephine@example.org
|
116
134
|
uid: jj243
|
135
|
+
# Password is "noskcaj"
|
136
|
+
userpassword: {SHA}ElqdCxdbvRNqXBgdUdkCmGZlQmk=
|
117
137
|
|
118
138
|
dn: uid=kk891,ou=people,dc=example,dc=org
|
119
139
|
objectClass: top
|
@@ -125,6 +145,8 @@ sn: Kline
|
|
125
145
|
givenName: Kelly
|
126
146
|
mail: kelly@example.org
|
127
147
|
uid: kk891
|
148
|
+
# Password is "enilk"
|
149
|
+
userpassword: {SHA}WlNzQqBB/QoEKh3LRcLZHgnCGNw=
|
128
150
|
|
129
151
|
dn: uid=ll819,ou=people,dc=example,dc=org
|
130
152
|
objectClass: top
|
@@ -136,6 +158,8 @@ sn: Lawrence
|
|
136
158
|
givenName: Leah
|
137
159
|
mail: leah@example.org
|
138
160
|
uid: ll819
|
161
|
+
# Password is "ecnerwal"
|
162
|
+
userpassword: {SHA}CzyyPOSrIxgFCm24nSv2FA8wihQ=
|
139
163
|
|
140
164
|
dn: uid=mm405,ou=people,dc=example,dc=org
|
141
165
|
objectClass: top
|
@@ -147,6 +171,8 @@ sn: Maddox
|
|
147
171
|
givenName: Mona
|
148
172
|
mail: mona@example.org
|
149
173
|
uid: mm405
|
174
|
+
# Password is "xoddam"
|
175
|
+
userpassword: {SHA}WiCnxkOb4kpy16ON7ZC6mD/iqII=
|
150
176
|
|
151
177
|
dn: uid=nn297,ou=people,dc=example,dc=org
|
152
178
|
objectClass: top
|
@@ -158,6 +184,8 @@ sn: Nash
|
|
158
184
|
givenName: Noel
|
159
185
|
mail: noel@example.org
|
160
186
|
uid: nn297
|
187
|
+
# Password is "hsan"
|
188
|
+
userpassword: {SHA}1zOsG076wDkikQbnK5vAMM1BM/o=
|
161
189
|
|
162
190
|
dn: uid=oo981,ou=people,dc=example,dc=org
|
163
191
|
objectClass: top
|
@@ -169,6 +197,8 @@ sn: Osborn
|
|
169
197
|
givenName: Ophelia
|
170
198
|
mail: ophelia@example.org
|
171
199
|
uid: oo981
|
200
|
+
# Password is "nrobso"
|
201
|
+
userpassword: {SHA}w8mQw0kEa1UiWzMsNclD/LWzlgs=
|
172
202
|
|
173
203
|
dn: uid=pp468,ou=people,dc=example,dc=org
|
174
204
|
objectClass: top
|
@@ -180,6 +210,8 @@ sn: Patel
|
|
180
210
|
givenName: Penelope
|
181
211
|
mail: penelope@example.org
|
182
212
|
uid: pp468
|
213
|
+
# Password is "letap"
|
214
|
+
userpassword: {SHA}p7jaVoRIV9o8gDPbN10sEhXaYHk=
|
183
215
|
|
184
216
|
dn: uid=qq612,ou=people,dc=example,dc=org
|
185
217
|
objectClass: top
|
@@ -191,6 +223,8 @@ sn: Queen
|
|
191
223
|
givenName: Quin
|
192
224
|
mail: quin@example.org
|
193
225
|
uid: qq612
|
226
|
+
# Password is "neeuq"
|
227
|
+
userpassword: {SHA}v9ibNIx42giCH4tQnwUHJy6LeJg=
|
194
228
|
|
195
229
|
dn: uid=rr477,ou=people,dc=example,dc=org
|
196
230
|
objectClass: top
|
@@ -202,6 +236,8 @@ sn: Rowland
|
|
202
236
|
givenName: Ruth
|
203
237
|
mail: ruth@example.org
|
204
238
|
uid: rr477
|
239
|
+
# Password is "dnalwor"
|
240
|
+
userpassword: {SHA}S3eMb2C/ctXzbFnlgcH7ZQ/fozU=
|
205
241
|
|
206
242
|
dn: uid=ss198,ou=people,dc=example,dc=org
|
207
243
|
objectClass: top
|
@@ -213,6 +249,8 @@ sn: Solomon
|
|
213
249
|
givenName: Serena
|
214
250
|
mail: serena@example.org
|
215
251
|
uid: ss198
|
252
|
+
# Password is "nomolos"
|
253
|
+
userpassword: {SHA}EizIKlU79Kz1Y2WIV4deIh0MSA8=
|
216
254
|
|
217
255
|
dn: uid=tt882,ou=people,dc=example,dc=org
|
218
256
|
objectClass: top
|
@@ -224,6 +262,8 @@ sn: Torres
|
|
224
262
|
givenName: Talia
|
225
263
|
mail: talia@example.org
|
226
264
|
uid: tt882
|
265
|
+
# Password is "serrot"
|
266
|
+
userpassword: {SHA}yO0DcSZ4fTMcx3sTHnAPQGvMkwg=
|
227
267
|
|
228
268
|
dn: uid=uu972,ou=people,dc=example,dc=org
|
229
269
|
objectClass: top
|
@@ -235,6 +275,8 @@ sn: Underwood
|
|
235
275
|
givenName: Ursula
|
236
276
|
mail: ursula@example.org
|
237
277
|
uid: uu972
|
278
|
+
# Password is "doowrednu"
|
279
|
+
userpassword: {SHA}GQWGu8IvIEFU1PP34qGi5DyDF/c=
|
238
280
|
|
239
281
|
dn: uid=vv180,ou=people,dc=example,dc=org
|
240
282
|
objectClass: top
|
@@ -246,6 +288,8 @@ sn: Vickers
|
|
246
288
|
givenName: Vera
|
247
289
|
mail: vera@example.org
|
248
290
|
uid: vv180
|
291
|
+
# Password is "srekciv"
|
292
|
+
userpassword: {SHA}3UrzY38O4R1GLK6ccSSfL4D0efQ=
|
249
293
|
|
250
294
|
dn: uid=ww369,ou=people,dc=example,dc=org
|
251
295
|
objectClass: top
|
@@ -257,6 +301,8 @@ sn: Wise
|
|
257
301
|
givenName: Wendy
|
258
302
|
mail: wendy@example.org
|
259
303
|
uid: ww369
|
304
|
+
# Password is "esiw"
|
305
|
+
userpassword: {SHA}8gU4KSqUeeLRPov2tmXZXgOZw78=
|
260
306
|
|
261
307
|
dn: uid=xx396,ou=people,dc=example,dc=org
|
262
308
|
objectClass: top
|
@@ -268,6 +314,8 @@ sn: Xiong
|
|
268
314
|
givenName: Xara
|
269
315
|
mail: xara@example.org
|
270
316
|
uid: xx396
|
317
|
+
# Password is "gnoix"
|
318
|
+
userpassword: {SHA}Yc2En2R/sbdjlEOitkLlkwY4jAY=
|
271
319
|
|
272
320
|
dn: uid=yy423,ou=people,dc=example,dc=org
|
273
321
|
objectClass: top
|
@@ -279,6 +327,8 @@ sn: Yates
|
|
279
327
|
givenName: Yvette
|
280
328
|
mail: yvette@example.org
|
281
329
|
uid: yy423
|
330
|
+
# Password is "setay"
|
331
|
+
userpassword: {SHA}iKBhwF+Mbbct6mlmy6AvodIek3E=
|
282
332
|
|
283
333
|
dn: uid=zz882,ou=people,dc=example,dc=org
|
284
334
|
objectClass: top
|
@@ -290,3 +340,6 @@ sn: Zimmerman
|
|
290
340
|
givenName: Zana
|
291
341
|
mail: zana@example.org
|
292
342
|
uid: zz882
|
343
|
+
# Password is "namremmiz"
|
344
|
+
userpassword: {SHA}KlsWojnknRWCHXGoBOTlEZxxrG8=
|
345
|
+
|
Binary file
|
Binary file
|
@@ -40,7 +40,8 @@ public class Main {
|
|
40
40
|
new Integer(commandLine.getOptionValue("p")),
|
41
41
|
commandLine.getOptionValue("d"),
|
42
42
|
new File(commandLine.getOptionValue("l")),
|
43
|
-
new File(commandLine.getOptionValue(
|
43
|
+
new File(commandLine.getOptionValue('t')),
|
44
|
+
!commandLine.hasOption('A'));
|
44
45
|
|
45
46
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
46
47
|
public void run() {
|
@@ -110,6 +111,10 @@ public class Main {
|
|
110
111
|
withLongOpt("tmpdir").hasArg().isRequired().
|
111
112
|
withDescription("Specify the temporary directory to use").
|
112
113
|
create('t'))
|
114
|
+
.addOption(OptionBuilder.
|
115
|
+
withLongOpt("no-anonymous").
|
116
|
+
withDescription("Disable anonymous access").
|
117
|
+
create('A'))
|
113
118
|
;
|
114
119
|
CommandLineParser parser = new GnuParser();
|
115
120
|
|
Binary file
|
@@ -35,13 +35,17 @@ public class Server {
|
|
35
35
|
|
36
36
|
private final int port;
|
37
37
|
private final String domainComponent;
|
38
|
+
private final boolean allowAnonymous;
|
38
39
|
private final File tempDir;
|
39
40
|
private final File ldifDir;
|
40
41
|
private boolean running = false;
|
41
42
|
|
42
|
-
public Server(
|
43
|
+
public Server(
|
44
|
+
int port, String domainComponent, File ldifFile, File tempDirBase, boolean allowAnonymous
|
45
|
+
) {
|
43
46
|
this.port = port;
|
44
47
|
this.domainComponent = domainComponent;
|
48
|
+
this.allowAnonymous = allowAnonymous;
|
45
49
|
this.tempDir = createTempDir(tempDirBase);
|
46
50
|
this.ldifDir = prepareLdif(ldifFile);
|
47
51
|
}
|
@@ -98,7 +102,7 @@ public class Server {
|
|
98
102
|
cfg.setLdifDirectory(ldifDir);
|
99
103
|
cfg.setEnableNetworking(true);
|
100
104
|
cfg.setLdapPort(port);
|
101
|
-
cfg.setAllowAnonymousAccess(
|
105
|
+
cfg.setAllowAnonymousAccess(allowAnonymous);
|
102
106
|
cfg.setAccessControlEnabled(false);
|
103
107
|
cfg.setShutdownHookEnabled(false);
|
104
108
|
cfg.setContextPartitionConfigurations(
|
data/lib/ladle/server.rb
CHANGED
@@ -47,6 +47,8 @@ module Ladle
|
|
47
47
|
# :domain option to match.
|
48
48
|
# @option opts [String] :domain ("dc=example,dc=org") the domain
|
49
49
|
# for the data provided in the :ldif option.
|
50
|
+
# @option opts [Boolean] :allow_anonymous (true) whether anonymous
|
51
|
+
# users will be able to query the server.
|
50
52
|
# @option opts [Boolean] :verbose (false) if true, detailed
|
51
53
|
# information about the execution of the server will be printed
|
52
54
|
# to standard error.
|
@@ -66,6 +68,7 @@ module Ladle
|
|
66
68
|
@port = opts[:port] || 3897
|
67
69
|
@domain = opts[:domain] || "dc=example,dc=org"
|
68
70
|
@ldif = opts[:ldif] || File.expand_path("../default.ldif", __FILE__)
|
71
|
+
@allow_anonymous = opts[:allow_anonymous].nil? ? true : opts[:allow_anonymous]
|
69
72
|
@quiet = opts[:quiet]
|
70
73
|
@verbose = opts[:verbose]
|
71
74
|
@timeout = opts[:timeout] || 15
|
@@ -193,6 +196,15 @@ module Ladle
|
|
193
196
|
@verbose
|
194
197
|
end
|
195
198
|
|
199
|
+
##
|
200
|
+
# Whether anonymous users will be allowed access to the server
|
201
|
+
# once it is running.
|
202
|
+
#
|
203
|
+
# @return [Boolean]
|
204
|
+
def allow_anonymous?
|
205
|
+
@allow_anonymous
|
206
|
+
end
|
207
|
+
|
196
208
|
private
|
197
209
|
|
198
210
|
def create_process(*cmd)
|
@@ -216,8 +228,9 @@ module Ladle
|
|
216
228
|
"--port", port,
|
217
229
|
"--domain", domain,
|
218
230
|
"--ldif", ldif,
|
219
|
-
"--tmpdir", tmpdir
|
220
|
-
|
231
|
+
"--tmpdir", tmpdir,
|
232
|
+
("--no-anonymous" unless allow_anonymous?)
|
233
|
+
].compact + @additional_args
|
221
234
|
end
|
222
235
|
|
223
236
|
def classpath
|
data/lib/ladle/version.rb
CHANGED
data/spec/ladle/server_spec.rb
CHANGED
@@ -4,11 +4,28 @@ require 'net/ldap'
|
|
4
4
|
|
5
5
|
describe Ladle, "::Server" do
|
6
6
|
def create_server(opts = {})
|
7
|
-
|
7
|
+
default_opts = { :tmpdir => tmpdir }.merge(
|
8
|
+
ENV['LADLE_TRACE'] ? { :verbose => true } : { :quiet => true })
|
9
|
+
Ladle::Server.new(default_opts.merge(opts))
|
10
|
+
end
|
11
|
+
|
12
|
+
def should_be_running
|
13
|
+
s = nil
|
14
|
+
lambda { s = TCPSocket.new('localhost', @server.port) }.
|
15
|
+
should_not raise_error
|
16
|
+
s.close if s
|
17
|
+
end
|
18
|
+
|
19
|
+
def should_not_be_running
|
20
|
+
s = nil
|
21
|
+
lambda { s = TCPSocket.new('localhost', @server.port) }.
|
22
|
+
should raise_error(/Connection refused/)
|
23
|
+
s.close if s
|
8
24
|
end
|
9
25
|
|
10
26
|
before do
|
11
27
|
@server = create_server
|
28
|
+
should_not_be_running # fail early
|
12
29
|
end
|
13
30
|
|
14
31
|
after do
|
@@ -166,14 +183,19 @@ describe Ladle, "::Server" do
|
|
166
183
|
should == "#{tmpdir}/openjdk/jre"
|
167
184
|
end
|
168
185
|
end
|
169
|
-
end
|
170
186
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
187
|
+
describe ":allow_anonymous" do
|
188
|
+
it "defaults to true" do
|
189
|
+
Ladle::Server.new.allow_anonymous?.should be_true
|
190
|
+
end
|
191
|
+
|
192
|
+
it "can be overridden" do
|
193
|
+
Ladle::Server.new(:allow_anonymous => false).allow_anonymous?.should be_false
|
194
|
+
end
|
175
195
|
end
|
196
|
+
end
|
176
197
|
|
198
|
+
describe "running" do
|
177
199
|
it "blocks until the server is up" do
|
178
200
|
@server.start
|
179
201
|
should_be_running
|
@@ -192,8 +214,7 @@ describe Ladle, "::Server" do
|
|
192
214
|
@server.start
|
193
215
|
@server.stop
|
194
216
|
@server.start
|
195
|
-
|
196
|
-
should_not raise_error
|
217
|
+
should_be_running
|
197
218
|
end
|
198
219
|
|
199
220
|
it "throws an exception when the server doesn't start up" do
|
@@ -231,16 +252,20 @@ describe Ladle, "::Server" do
|
|
231
252
|
end
|
232
253
|
end
|
233
254
|
|
234
|
-
describe "
|
255
|
+
describe "LDAP implementation" do
|
235
256
|
before do
|
236
257
|
pending "Net::LDAP doesn't work on 1.9" if RUBY_VERSION =~ /1.9/
|
237
258
|
end
|
238
259
|
|
239
|
-
def with_ldap
|
260
|
+
def with_ldap(params={})
|
240
261
|
@server.start
|
241
|
-
Net::LDAP.open
|
242
|
-
|
243
|
-
|
262
|
+
# We don't use Net::LDAP.open because it seems to leak sockets,
|
263
|
+
# at least on Linux and with version 0.0.4 of the library.
|
264
|
+
ldap = Net::LDAP.new({
|
265
|
+
:host => 'localhost', :port => @server.port,
|
266
|
+
:auth => { :method => :anonymous }
|
267
|
+
}.merge(params))
|
268
|
+
yield ldap
|
244
269
|
end
|
245
270
|
|
246
271
|
def ldap_search(filter, base=nil)
|
@@ -248,58 +273,108 @@ describe Ladle, "::Server" do
|
|
248
273
|
ldap.search(
|
249
274
|
:base => base || 'dc=example,dc=org',
|
250
275
|
:filter => filter
|
251
|
-
)
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
def ldap_parameters
|
256
|
-
@ldap_parameters ||= {
|
257
|
-
:host => 'localhost', :port => @server.port,
|
258
|
-
:auth => { :method => :anonymous }
|
276
|
+
).tap {
|
277
|
+
ldap.get_operation_result.code.should == 0 # success
|
278
|
+
}
|
259
279
|
}
|
260
280
|
end
|
261
281
|
|
262
|
-
describe "
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
282
|
+
describe "data" do
|
283
|
+
describe "the default set" do
|
284
|
+
it "has 26 people" do
|
285
|
+
ldap_search(Net::LDAP::Filter.pres('uid')).should have(26).people
|
286
|
+
end
|
287
|
+
|
288
|
+
it "has 1 group" do
|
289
|
+
ldap_search(Net::LDAP::Filter.pres('ou')).should have(1).group
|
290
|
+
end
|
291
|
+
|
292
|
+
it "has given names" do
|
293
|
+
ldap_search(Net::LDAP::Filter.pres('uid')).
|
294
|
+
select { |res| !res[:givenname] || res[:givenname].empty? }.should == []
|
295
|
+
end
|
296
|
+
|
297
|
+
it "has e-mail addresses" do
|
298
|
+
ldap_search(Net::LDAP::Filter.pres('uid')).
|
299
|
+
select { |res| !res[:mail] || res[:mail].empty? }.should == []
|
300
|
+
end
|
301
|
+
|
302
|
+
it "can be searched by value" do
|
303
|
+
ldap_search(Net::LDAP::Filter.eq(:givenname, 'Josephine')).
|
304
|
+
collect { |res| res[:uid].first }.should == %w(jj243)
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
describe "with a provided set" do
|
309
|
+
before do
|
310
|
+
@server = create_server(
|
311
|
+
:domain => "dc=example,dc=net",
|
312
|
+
:ldif => File.expand_path("../animals.ldif", __FILE__)
|
313
|
+
)
|
314
|
+
end
|
315
|
+
|
316
|
+
it "has the groups provided by the other LDIF" do
|
317
|
+
ldap_search(Net::LDAP::Filter.pres('ou'), 'dc=example,dc=net').
|
318
|
+
collect { |result| result[:ou].first }.should == ["animals"]
|
319
|
+
end
|
320
|
+
|
321
|
+
it "has the individuals provided by the other LDIF" do
|
322
|
+
ldap_search(Net::LDAP::Filter.pres('uid'), 'dc=example,dc=net').
|
323
|
+
collect { |result| result[:givenname].first }.sort.should == %w(Ada Bob)
|
324
|
+
end
|
284
325
|
end
|
285
326
|
end
|
286
327
|
|
287
|
-
describe "
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
end
|
294
|
-
|
295
|
-
it "
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
328
|
+
describe "binding" do
|
329
|
+
it "works with a valid password" do
|
330
|
+
with_ldap do |ldap|
|
331
|
+
ldap.authenticate("uid=hh153,ou=people,dc=example,dc=org", "hatfield".reverse)
|
332
|
+
ldap.bind.should be_true
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
it "does not work with an invalid password" do
|
337
|
+
with_ldap do |ldap|
|
338
|
+
ldap.authenticate("uid=hh153,ou=people,dc=example,dc=org", "mccoy".reverse)
|
339
|
+
ldap.bind.should be_false
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
describe "with anonymous binding disabled" do
|
344
|
+
before do
|
345
|
+
@server = create_server(:allow_anonymous => false)
|
346
|
+
end
|
347
|
+
|
348
|
+
it "will not bind anonymously" do
|
349
|
+
with_ldap do |ldap|
|
350
|
+
# anonymous bind is successful even with anonymous access
|
351
|
+
# off, but searches fail appropriately
|
352
|
+
ldap.search(:filter => Net::LDAP::Filter.pres('uid'), :base => 'dc=example,dc=org')
|
353
|
+
ldap.get_operation_result.code.should == 50 # insufficient access
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
it "will bind with a username and valid password" do
|
358
|
+
with_ldap do |ldap|
|
359
|
+
ldap.authenticate("uid=kk891,ou=people,dc=example,dc=org", "enilk")
|
360
|
+
ldap.bind.should be_true
|
361
|
+
end
|
362
|
+
end
|
363
|
+
|
364
|
+
it "will not bind with a username and invalid password" do
|
365
|
+
with_ldap do |ldap|
|
366
|
+
ldap.authenticate("uid=kk891,ou=people,dc=example,dc=org", "kevin")
|
367
|
+
ldap.bind.should be_false
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
it "permits searches for authenticated users" do
|
372
|
+
with_ldap do |ldap|
|
373
|
+
ldap.authenticate("uid=kk891,ou=people,dc=example,dc=org", "enilk")
|
374
|
+
ldap.search(:filter => Net::LDAP::Filter.pres('uid'), :base => 'dc=example,dc=org').
|
375
|
+
should have(26).results
|
376
|
+
end
|
377
|
+
end
|
303
378
|
end
|
304
379
|
end
|
305
380
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: java
|
11
11
|
authors:
|
12
12
|
- Rhett Sutphin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-27 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +71,19 @@ dependencies:
|
|
71
71
|
version: 0.0.4
|
72
72
|
type: :development
|
73
73
|
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: ci_reporter
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 1
|
83
|
+
- 6
|
84
|
+
version: "1.6"
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id005
|
74
87
|
description: Provides an embedded LDAP server for BDD. The embedded server is built with ApacheDS.
|
75
88
|
email:
|
76
89
|
- rhett@detailedbalance.net
|