Skip to content

Commit 0714916

Browse files
committed
Initial commit
0 parents  commit 0714916

File tree

2,023 files changed

+28855
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,023 files changed

+28855
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages/
2+
build_out/

Dockerfile.bootstrap

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Must be 11 or less because of https://issues.apache.org/jira/browse/DIRSTUDIO-1277
2+
FROM openjdk:11-jre-slim
3+
4+
WORKDIR /opt
5+
6+
COPY packages/apacheds.deb .
7+
COPY bootstrap bootstrap
8+
COPY tools/import-ldif.sh /usr/local/bin/import-ldif
9+
COPY tools/ldap-ready.sh /usr/local/bin/ldap-ready
10+
11+
RUN apt-get update && \
12+
apt-get install -y --no-install-recommends ldap-utils procps && \
13+
rm -rf /var/lib/apt/lists/* && \
14+
dpkg -i apacheds.deb && \
15+
rm -f apacheds.deb
16+
17+
ENV LDAP_BINDDN=${LDAP_BINDDN:-"uid=admin,ou=system"}
18+
ENV LDAP_SECRET=${LDAP_SECRET:-"secret"}
19+
ENV APACHEDS_VERSION=${APACHEDS_VERSION:-"2.0.0.AM26"}
20+
ENV APACHEDS_INSTANCE_DIR=/var/lib/apacheds-${APACHEDS_VERSION}/default
21+
22+
ENV PATH=/opt/apacheds-${APACHEDS_VERSION}/bin:${PATH}
23+
24+
EXPOSE 10389 10636
25+
26+
ENTRYPOINT ["/opt/bootstrap/bootstrap.sh"]

Dockerfile.final

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Based upon:
2+
# https://github.com/OpenIdentityPlatform/OpenDJ/blob/825e1d6/opendj-packages/opendj-docker/Dockerfile
3+
4+
# Must be 11 or less because of https://issues.apache.org/jira/browse/DIRSTUDIO-1277
5+
FROM openjdk:11-jre-slim
6+
7+
WORKDIR /tmp
8+
9+
COPY packages/apacheds.deb .
10+
COPY packages/dumb-init /usr/local/bin/dumb-init
11+
COPY build_out/data.tar .
12+
COPY tools/ldap-ready.sh /usr/local/bin/ldap-ready
13+
COPY run.sh /run.sh
14+
15+
ENV LDAP_BINDDN=${LDAP_BINDDN:-"uid=admin,ou=system"}
16+
ENV LDAP_SECRET=${LDAP_SECRET:-"secret"}
17+
ENV APACHEDS_VERSION=${APACHEDS_VERSION:-"2.0.0.AM26"}
18+
ENV APACHEDS_INSTANCE=${APACHEDS_INSTANCE:-"default"}
19+
ENV APACHEDS_INSTANCE_DIR=/var/lib/apacheds-${APACHEDS_VERSION}/${APACHEDS_INSTANCE}
20+
21+
RUN apt-get update && \
22+
apt-get install -y --no-install-recommends ldap-utils procps && \
23+
rm -rf /var/lib/apt/lists/* && \
24+
dpkg -i apacheds.deb && \
25+
rm -f apacheds.deb && \
26+
tar -xf data.tar -C /var/lib/apacheds-${APACHEDS_VERSION}/ && \
27+
rm -f data.tar ${APACHEDS_INSTANCE_DIR}/conf/config.ldif
28+
29+
ENV PATH=/opt/apacheds-${APACHEDS_VERSION}/bin:${PATH}
30+
31+
EXPOSE 10389 10636
32+
33+
WORKDIR /
34+
ENTRYPOINT ["/run.sh"]

Readme.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# docker-test-apacheds
2+
3+
The purpose of this repository is to provide an [Apache
4+
DS](https://directory.apache.org/apacheds/) Docker image that can be used for
5+
integration testing. The main goal being to be able to test the VirtualListView
6+
control.
7+
8+
## Building And Running
9+
10+
1. Run `build.sh` to generate the image
11+
2. Run `docker run --rm -it -p 389:10389 --name apacheds apacheds` to start
12+
a server
13+
14+
## Testing The VLV Control
15+
16+
Using the `ldapsearch` tool from the [UnboundId
17+
SDK](https://github.com/pingidentity/ldapsdk/releases), we can issue a search
18+
that contains the VLV control by:
19+
20+
```sh
21+
/ldapsearch --hostname localhost --port 389 \
22+
--bindDN 'uid=admin,ou=system' --bindPassword 'secret' \
23+
--baseDN 'dc=planetexpress,dc=com' \
24+
--requestedAttribute 'uid' \
25+
--sortOrder '+uid:2.5.13.6' \
26+
--virtualListView 0:2:1:1 \
27+
'(objectClass=person)'
28+
```
29+
30+
Note: the ordering rule `2.5.13.6` is `caseExactOrderingMatch`.
31+
32+
If we capture the above request with [Wireshark](https://wireshark.org/),
33+
we can see that the request is:
34+
35+
```
36+
02 00 00 00 45 00 00 e3 00 00 40 00 40 06 00 00 ....E.....@.@...
37+
7f 00 00 01 7f 00 00 01 d8 5f 01 85 9d 64 ea 73 ........._...d.s
38+
af 77 1e fa 80 18 18 eb fe d7 00 00 01 01 08 0a .w..............
39+
1a d2 0d 02 1a d2 0c fe 30 81 ac 02 01 02 63 46 ........0.....cF
40+
04 17 64 63 3d 70 6c 61 6e 65 74 65 78 70 72 65 ..dc=planetexpre
41+
73 73 2c 64 63 3d 63 6f 6d 0a 01 02 0a 01 00 02 ss,dc=com.......
42+
01 00 02 01 00 01 01 00 a3 15 04 0b 6f 62 6a 65 ............obje
43+
63 74 43 6c 61 73 73 04 06 70 65 72 73 6f 6e 30 ctClass..person0
44+
05 04 03 75 69 64 a0 5f 30 2d 04 16 31 2e 32 2e ...uid._0-..1.2.
45+
38 34 30 2e 31 31 33 35 35 36 2e 31 2e 34 2e 34 840.113556.1.4.4
46+
37 33 04 13 30 11 30 0f 04 03 75 69 64 80 08 32 73..0.0...uid..2
47+
2e 35 2e 31 33 2e 36 30 2e 04 17 32 2e 31 36 2e .5.13.60...2.16.
48+
38 34 30 2e 31 2e 31 31 33 37 33 30 2e 33 2e 34 840.1.113730.3.4
49+
2e 39 01 01 ff 04 10 30 0e 02 01 00 02 01 02 a0 .9.....0........
50+
06 02 01 01 02 01 01 .......
51+
52+
```
53+
54+
And thus the controls are:
55+
56+
```
57+
30 2d 04 16 31 2e 32 2e 38 34 30 2e 31 31 33 35
58+
35 36 2e 31 2e 34 2e 34 37 33 04 13 30 11 30 0f
59+
04 03 75 69 64 80 08 32 2e 35 2e 31 33 2e 36 30
60+
2e 04 17 32 2e 31 36 2e 38 34 30 2e 31 2e 31 31
61+
33 37 33 30 2e 33 2e 34 2e 39 01 01 ff 04 10 30
62+
0e 02 01 00 02 01 02 a0 06 02 01 01 02 01 01
63+
64+
```
65+
66+
Specifically, the Server Side Sorting control is:
67+
68+
```
69+
30 2d 04 16 31 2e 32 2e 38 34 30 2e 31 31 33 35
70+
35 36 2e 31 2e 34 2e 34 37 33 04 13 30 11 30 0f
71+
04 03 75 69 64 80 08 32 2e 35 2e 31 33 2e 36
72+
```
73+
74+
And the Virtual List View control is:
75+
76+
```
77+
30 2e 04 17 32 2e 31 36 2e 38 34 30 2e 31 2e 31
78+
31 33 37 33 30 2e 33 2e 34 2e 39 01 01 ff 04 10
79+
30 0e 02 01 00 02 01 02 a0 06 02 01 01 02 01 01
80+
```
81+
82+
Finally, the resulting response is:
83+
84+
```
85+
02 00 00 00 45 00 00 65 00 00 40 00 40 06 00 00 ....E..e..@.@...
86+
7f 00 00 01 7f 00 00 01 01 85 d8 5f af 77 21 35 ..........._.w!5
87+
9d 64 eb 22 80 18 18 e8 fe 59 00 00 01 01 08 0a .d.".....Y......
88+
1a d2 0d 0e 1a d2 0d 08 30 2f 02 01 02 65 07 0a ........0/...e..
89+
01 00 04 00 04 00 a0 21 30 1f 04 16 31 2e 32 2e .......!0...1.2.
90+
38 34 30 2e 31 31 33 35 35 36 2e 31 2e 34 2e 34 840.113556.1.4.4
91+
37 34 04 05 30 03 0a 01 00 74..0....
92+
```
93+
94+
The end result being that a `SortResult` control is included but not a
95+
`VLVResponse` control. Thus, we conclude that at this time Apache Directory
96+
Server does not actually support the VLV control. This is despite the server
97+
returning the control as supported when querying for the list of supported
98+
controls.

bootstrap/bootstrap.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
BOOTSTRAP_DIR=/opt/bootstrap
6+
CONFIG_DIR=${BOOTSTRAP_DIR}/config
7+
DATA_DIR=${BOOTSTRAP_DIR}/data/
8+
9+
echo "Bootstrapping server ..."
10+
apacheds start default
11+
ldap-ready
12+
wait
13+
14+
data=$(find ${CONFIG_DIR} -maxdepth 1 -name \*_\*.ldif -type f | sort)
15+
for ldif in ${data}; do
16+
echo "Processing file ${ldif}..."
17+
ldapadd -x -H ldap://localhost:10389/ \
18+
-D ${LDAP_BINDDN} \
19+
-w ${LDAP_SECRET} \
20+
-f ${ldif}
21+
done
22+
23+
apacheds restart default
24+
ldap-ready
25+
wait
26+
27+
echo "Load data..."
28+
data=$(find ${DATA_DIR} -maxdepth 1 -name \*_\*.ldif -type f | sort)
29+
for ldif in ${data}; do
30+
echo "Processing file ${ldif}..."
31+
ldapadd -x -H ldap://localhost:10389/ \
32+
-D ${LDAP_BINDDN} \
33+
-w ${LDAP_SECRET} \
34+
-f ${ldif}
35+
done
36+
37+
apacheds stop default
38+
cd /var/lib/apacheds-${APACHEDS_VERSION}/
39+
tar cf /build_out/data.tar .

bootstrap/config/00_partition.ldif

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# https://unix.stackexchange.com/a/577250
2+
3+
dn: ads-partitionId=planetexpress,ou=partitions,ads-directoryServiceId=default,ou=config
4+
objectclass: top
5+
objectClass: ads-base
6+
objectclass: ads-partition
7+
objectclass: ads-jdbmPartition
8+
ads-partitionSuffix: dc=planetexpress,dc=com
9+
ads-contextentry:: ZG46IGRjPXBsYW5ldGV4cHJlc3MsZGM9Y29tCmRjOiBwbGFuZXRleHByZXNzCm9iamVjdGNsYXNzOiBkb21haW4Kb2JqZWN0Y2xhc3M6IHRvcA==
10+
ads-jdbmpartitionoptimizerenabled: TRUE
11+
ads-partitioncachesize: 10000
12+
ads-partitionsynconwrite: TRUE
13+
ads-partitionid: planetexpress
14+
ads-enabled: TRUE
15+
16+
dn: ou=indexes,ads-partitionId=planetexpress,ou=partitions,ads-directoryServiceId=default,ou=config
17+
objectclass: top
18+
objectclass: organizationalUnit
19+
ou: indexes
20+
21+
dn: ads-indexAttributeId=uid,ou=indexes,ads-partitionId=planetexpress,ou=partitions,ads-directoryServiceId=default,ou=config
22+
objectclass: top
23+
objectclass: ads-base
24+
objectclass: ads-index
25+
objectclass: ads-jdbmIndex
26+
ads-indexAttributeId: uid
27+
ads-enabled: TRUE
28+
ads-indexhasreverse: FALSE
29+
30+
dn: ads-indexAttributeId=dc,ou=indexes,ads-partitionId=planetexpress,ou=partitions,ads-directoryServiceId=default,ou=config
31+
objectclass: top
32+
objectclass: ads-base
33+
objectclass: ads-index
34+
objectclass: ads-jdbmIndex
35+
ads-indexAttributeId: dc
36+
ads-enabled: TRUE
37+
ads-indexhasreverse: FALSE

bootstrap/config/01_msad.ldif

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## https://stackoverflow.com/a/34502363
2+
3+
## Define base schema
4+
dn: cn=planetexpress, ou=schema
5+
objectclass: metaSchema
6+
objectclass: top
7+
cn: planetexpress
8+
9+
dn: ou=attributetypes, cn=planetexpress, ou=schema
10+
objectclass: organizationalUnit
11+
objectclass: top
12+
ou: attributetypes
13+
14+
## Add sAMAccountName
15+
dn: m-oid=1.2.840.113556.1.4.221, ou=attributetypes, cn=planetexpress, ou=schema
16+
objectclass: metaAttributeType
17+
objectclass: metaTop
18+
objectclass: top
19+
m-oid: 1.2.840.113556.1.4.221
20+
m-name: sAMAccountName
21+
m-equality: caseIgnoreMatch
22+
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
23+
m-singleValue: TRUE
24+
25+
## Add memberOf
26+
dn: m-oid=1.2.840.113556.1.4.222, ou=attributetypes, cn=planetexpress, ou=schema
27+
objectclass: metaAttributeType
28+
objectclass: metaTop
29+
objectclass: top
30+
m-oid: 1.2.840.113556.1.4.222
31+
m-name: memberOf
32+
m-equality: caseIgnoreMatch
33+
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
34+
m-singleValue: FALSE
35+
36+
dn: ou=objectclasses, cn=planetexpress, ou=schema
37+
objectclass: organizationalUnit
38+
objectclass: top
39+
ou: objectClasses
40+
41+
dn: m-oid=1.2.840.113556.1.5.6, ou=objectclasses, cn=planetexpress, ou=schema
42+
objectclass: metaObjectClass
43+
objectclass: metaTop
44+
objectclass: top
45+
m-oid: 1.2.840.113556.1.5.6
46+
m-name: simulatedMicrosoftSecurityPrincipal
47+
m-supObjectClass: top
48+
m-typeObjectClass: AUXILIARY
49+
m-must: sAMAccountName
50+
m-may: memberOf
51+
52+
### Add the groupType Attribute
53+
dn: m-oid=1.2.840.113556.1.4.750, ou=attributetypes, cn=planetexpress, ou=schema
54+
objectclass: metaAttributeType
55+
objectclass: metaTop
56+
objectclass: top
57+
m-oid: 1.2.840.113556.1.4.750
58+
m-name: groupType
59+
m-equality: caseIgnoreMatch
60+
m-syntax: 1.3.6.1.4.1.1466.115.121.1.27
61+
m-singleValue: TRUE
62+
63+
### Add the group class
64+
dn: m-oid= 1.2.840.113556.1.5.8, ou=objectclasses, cn=planetexpress, ou=schema
65+
objectclass: metaObjectClass
66+
objectclass: metaTop
67+
objectclass: top
68+
m-oid: 1.2.840.113556.1.5.8
69+
m-description: A group of users
70+
m-name: Group
71+
m-supObjectClass: top
72+
m-typeObjectClass: STRUCTURAL
73+
m-must: groupType
74+
m-must: cn
75+
m-may: member

bootstrap/data/00_people.ldif

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dn: ou=people,dc=planetexpress,dc=com
2+
objectClass: top
3+
objectClass: organizationalUnit
4+
description: Planet Express crew
5+
ou: people

bootstrap/data/10_people_amy.ldif

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
dn: cn=Amy Wong+sn=Kroker,ou=people,dc=planetexpress,dc=com
2+
objectClass: top
3+
objectClass: person
4+
objectClass: organizationalPerson
5+
objectClass: inetOrgPerson
6+
cn: Amy Wong
7+
sn: Kroker
8+
description: Human
9+
givenName: Amy
10+
11+
ou: Intern
12+
uid: amy
13+
userPassword:: e3NzaGF9M3UzcUdCSmFMc2tiUEg0OVJrYlFtUk9HTktFb1lOUXZkU2lOZmc9P
14+
Q==

0 commit comments

Comments
 (0)