Skip to content

Commit e5bba07

Browse files
committed
tests unitaires
1 parent 5394d3b commit e5bba07

12 files changed

Lines changed: 612 additions & 71 deletions

File tree

unittest/files_backend_utils/config1.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
host=ldap://ldap-test
2-
dn=uid=admin,cn=internal,dc=test,dc=local
1+
host=ldap://127.0.0.1
2+
dn=cn=admin,dc=test,dc=local
33
password=XXXXXX
44
base=dc=test,dc=local
5-
userbase=ou=PERSONNES,dc=test,dc=local
5+
userbase=dc=test,dc=local
66
rdnattribute=uid
77
branchForEtd=ou=etd
88
branchForEsn=ou=esn

unittest/ldapBinTest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ def test_02upsertidentity_add(self):
3838
self.assertEqual(ret['returncode'], 0)
3939
result = json.loads(ret["stdout"])
4040
self.assertEqual(result["status"], 0)
41-
self.assertEqual(result["message"], "Entree uid=omaton,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr add")
41+
self.assertEqual(result["message"], "Entree uid=omaton,ou=adm,dc=test,dc=local add")
4242

4343
def test_03upsertidentity_mod(self):
4444
ret = self.run_backend('upsertidentity.py', './files_ad_utils/identity1.json')
4545
self.assertEqual(ret['returncode'], 0)
4646
result = json.loads(ret["stdout"])
4747
self.assertEqual(result["status"], 0)
48-
self.assertEqual(result["message"], "Entree uid=omaton,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr mod")
48+
self.assertEqual(result["message"], "Entree uid=omaton,ou=adm,dc=test,dc=local mod")
4949

5050
def test_05init_password(self):
5151
ret = self.run_backend('resetpwd.py', './files_ad_utils/resetpassword.json')
@@ -122,13 +122,13 @@ def test_19delentity(self):
122122
self.assertEqual(ret['returncode'], 0)
123123
result = json.loads(ret["stdout"])
124124
self.assertEqual(result["status"], 0)
125-
self.assertEqual(result["message"], "user : uid=omaton,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr deleted")
125+
self.assertEqual(result["message"], "user : uid=omaton,ou=adm,dc=test,dc=local deleted")
126126
def test_20eduperson(self):
127127
ret = self.run_backend('upsertidentity.py', './files_ad_utils/eduPersonTest.json')
128128
self.assertEqual(ret['returncode'], 0)
129129
result = json.loads(ret["stdout"])
130130
self.assertEqual(result["status"], 0)
131-
self.assertEqual(result["message"], "Entree uid=omounier,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr mod")
131+
self.assertEqual(result["message"], "Entree uid=xx,ou=adm,dc=test,dc=local add")
132132

133133
def test_21lifecycle(self):
134134
ret =self.run_backend('lifecycle.py', './files_ad_utils/lifecycle.json')

unittest/ldapUtilsTest.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ def test02_composedn(self):
1616
ldap.set_config(config)
1717
entity = u.readjsonfile("./files_ad_utils/identity1.json")
1818
dn=ldap.compose_dn(entity)
19-
self.assertEqual(dn,'uid=omaton,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr')
19+
self.assertEqual(dn,'uid=omaton,ou=adm,dc=test,dc=local')
2020
def test03_composedn_template(self):
2121
config = u.read_config('./files_backend_utils/config1.conf')
2222
u.__CONFIG__.set('config', 'dnTemplate', 'cn={{e.cn}},{{branch}},ou=myspecialbranch,{{config.base}}')
2323
ldap.set_config(config)
2424
entity = u.readjsonfile("./files_ad_utils/identity1.json")
2525
dn = ldap.compose_dn(entity)
26-
self.assertEqual(dn, 'cn=Maton Olivier,ou=adm,ou=myspecialbranch,dc=lyon,dc=archi,dc=fr')
26+
self.assertEqual(dn, 'cn=Maton Olivier,ou=adm,ou=myspecialbranch,dc=test,dc=local')
2727

2828
def test04_compose_dn_otherpopulation(self):
2929
config = u.read_config('./files_backend_utils/config1.conf')
@@ -32,14 +32,14 @@ def test04_compose_dn_otherpopulation(self):
3232
entity = u.readjsonfile("./files_ad_utils/identity1.json")
3333
entity['payload']['identity']['identity']['inetOrgPerson']['departmentNumber']=['test']
3434
dn = ldap.compose_dn(entity)
35-
self.assertEqual(dn, 'uid=omaton,ou=test,ou=PERSONNES,dc=lyon,dc=archi,dc=fr')
35+
self.assertEqual(dn, 'uid=omaton,ou=test,dc=test,dc=local')
3636

3737
def test05_compose_dn_nobranch(self):
3838
config = u.read_config('./files_backend_utils/config1.conf')
3939
entity = u.readjsonfile("./files_ad_utils/identity1.json")
4040
entity['payload']['identity']['identity']['inetOrgPerson']['departmentNumber']=['test']
4141
dn = ldap.compose_dn(entity)
42-
self.assertEqual(dn, 'uid=omaton,ou=PERSONNES,dc=lyon,dc=archi,dc=fr')
42+
self.assertEqual(dn, 'uid=omaton,dc=test,dc=local')
4343

4444
def test06_testrdn(self):
4545
config = u.read_config('./files_backend_utils/config1.conf')
@@ -51,9 +51,10 @@ def test06_testrdn(self):
5151
self.assertEqual(rdn, 'cn=Maton Olivier')
5252

5353
def test07_dnsuperior(self):
54-
self.assertEqual(ldap.dn_superior("uid=omaton,ou=PERSONNES,dc=lyon,dc=archi,dc=fr"),"ou=PERSONNES,dc=lyon,dc=archi,dc=fr")
54+
self.assertEqual(ldap.dn_superior("uid=omaton,ou=PERSONNES,dc=test,dc=local"),"ou=PERSONNES,dc=test,dc=local")
5555

5656
def test08_make_objectclass(self):
57+
config = u.read_config('./files_backend_utils/config1.conf')
5758
entity = u.readjsonfile("./files_ad_utils/identity1.json")
5859
test=u.make_objectclass(entity,[])
5960
self.assertEqual(len(test),6)
@@ -68,7 +69,7 @@ def test09_upsertEntry(self):
6869
x=ldap.upsert_entry(l,entity)
6970
result=json.loads(x)
7071
self.assertEqual(result['status'],0)
71-
self.assertEqual(result['message'], "Entree uid=omaton,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr add")
72+
self.assertEqual(result['message'], "Entree uid=omaton,ou=adm,dc=test,dc=local add")
7273

7374
def test10_upsertMod(self):
7475
config = u.read_config('./files_backend_utils/config1.conf')
@@ -80,7 +81,7 @@ def test10_upsertMod(self):
8081
x = ldap.upsert_entry(l, entity)
8182
result = json.loads(x)
8283
self.assertEqual(result['status'], 0)
83-
self.assertEqual(result['message'], "Entree uid=omaton,ou=adm,ou=PERSONNES,dc=lyon,dc=archi,dc=fr mod")
84+
self.assertEqual(result['message'], "Entree uid=omaton,ou=adm,dc=test,dc=local mod")
8485

8586
def test11_move_entry(self):
8687
config = u.read_config('./files_backend_utils/config1.conf')
@@ -92,7 +93,7 @@ def test11_move_entry(self):
9293
x = ldap.upsert_entry(l, entity)
9394
result = json.loads(x)
9495
self.assertEqual(result['status'], 0)
95-
self.assertEqual(result['message'], "Entree uid=omaton,ou=esn,ou=PERSONNES,dc=lyon,dc=archi,dc=fr rename")
96+
self.assertEqual(result['message'], "Entree uid=omaton,ou=esn,dc=test,dc=local rename")
9697

9798
def test12_initpassword(self):
9899
config = u.read_config('./files_backend_utils/config1.conf')
@@ -110,15 +111,15 @@ def test15_testpassword(self):
110111
ldap.set_config(config)
111112
data = u.get_config()
112113
## test du mot de passe
113-
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,ou=PERSONNES,dc=lyon,dc=archi,dc=fr','Abbert1xIEIIE88!')
114+
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,dc=test,dc=local','Abbert1xIEIIE88!')
114115
self.assertNotEqual(l1,1)
115116

116117
def test16_test_wrongpassword(self):
117118
config = u.read_config('./files_backend_utils/config1.conf')
118119
ldap.set_config(config)
119120
data = u.get_config()
120121
## test du mot de passe
121-
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,ou=PERSONNES,dc=lyon,dc=archi,dc=fr',
122+
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,dc=test,dc=local',
122123
'xx')
123124
self.assertEqual(l1, 1)
124125

@@ -138,15 +139,15 @@ def test21_testpassword(self):
138139
ldap.set_config(config)
139140
data = u.get_config()
140141
## test du mot de passe
141-
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,ou=PERSONNES,dc=lyon,dc=archi,dc=fr','AbCx34IddWZE1!')
142+
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,dc=test,dc=local','AbCx34IddWZE1!')
142143
self.assertNotEqual(l1,1)
143144

144145
def test22_testoldpassword(self):
145146
config = u.read_config('./files_backend_utils/config1.conf')
146147
ldap.set_config(config)
147148
data = u.get_config()
148149
## test du mot de passe
149-
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,ou=PERSONNES,dc=lyon,dc=archi,dc=fr',
150+
l1 = ldap.connect_ldap(data['host'], 'uid=omaton,ou=esn,dc=test,dc=local',
150151
'Abbert1xIEIIE88!')
151152
self.assertEqual(l1, 1)
152153

@@ -190,7 +191,7 @@ def test25_eduperson(self):
190191
x = ldap.upsert_entry(l, entity)
191192
result = json.loads(x)
192193
self.assertEqual(result['status'], 0)
193-
self.assertEqual(result['message'], "Entree uid=xx,ou=people,ou=PERSONNES,dc=lyon,dc=archi,dc=fr mod")
194+
self.assertEqual(result['message'], "Entree uid=xx,ou=adm,dc=test,dc=local add")
194195
def test26_delete_entry(self):
195196
config = u.read_config('./files_backend_utils/config1.conf')
196197
ldap.set_config(config)
@@ -200,7 +201,7 @@ def test26_delete_entry(self):
200201
x= ldap.delete_entity(l, entity)
201202
result = json.loads(x)
202203
self.assertEqual(result['status'], 0)
203-
self.assertEqual(result['message'], "user : uid=omaton,ou=esn,ou=PERSONNES,dc=lyon,dc=archi,dc=fr deleted")
204+
self.assertEqual(result['message'], "user : uid=omaton,ou=esn,dc=test,dc=local deleted")
204205

205206

206207

unittest/openldap_testserver/custom/01overlays.ldif

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
dn: cn=sogxmail,cn=schema,cn=config
2+
changeType: add
3+
objectClass: olcSchemaConfig
4+
cn: sogxmail
5+
olcAttributeTypes: {0}( 1.3.6.1.4.1.7383.20.1 NAME 'sogxdisableflag' DESC 'Acc
6+
ount disable flag' EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5Substrings
7+
Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
8+
olcAttributeTypes: {1}( 1.3.6.1.4.1.7383.20.2 NAME 'proxyaddress' DESC 'Emumat
9+
e AD proxyaddress' EQUALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5Substrings
10+
Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
11+
olcAttributeTypes: {2}( 1.3.6.1.4.1.7383.20.3 NAME 'sogxHomeServer' DESC 'serv
12+
er which keeps the users mailbox' EQUALITY caseIgnoreIA5Match SUBSTR caseIgno
13+
reIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
14+
olcAttributeTypes: {3}( 1.3.6.1.4.1.7383.20.4 NAME 'sogxQuota' EQUALITY caseIg
15+
noreIA5Match SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.
16+
121.1.26{256} )
17+
olcAttributeTypes: {4}( 1.3.6.1.4.1.7383.20.5 NAME 'sogxImapAcl' EQUALITY case
18+
IgnoreIA5Match SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.11
19+
5.121.1.26{256} )
20+
olcAttributeTypes: {5}( 1.3.6.1.4.1.7383.20.6 NAME 'postfix-mydestination' EQU
21+
ALITY caseIgnoreIA5Match SUBSTR caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4
22+
.1.1466.115.121.1.26{256} )
23+
olcObjectClasses: {0}( 1.3.6.1.4.1.7383.21.1 NAME 'sogxUser' DESC 'SogxUser' S
24+
UP top AUXILIARY MAY ( sogxQuota $ proxyaddress $ sogxHomeServer $ sogxDisabl
25+
eFlag ) )
26+
olcObjectClasses: {1}( 1.3.6.1.4.1.7383.21.2 NAME 'sogxMailList' DESC 'maillin
27+
g List ' SUP groupOfNames STRUCTURAL MAY ( mail $ sogxDisableFlag $ owner ) )
28+
olcObjectClasses: {2}( 1.3.6.1.4.1.7383.21.3 NAME 'sogxContainer' DESC 'Contai
29+
r emulation' SUP TOP STRUCTURAL MUST ( cn ) )
30+
olcObjectClasses: {3}( 1.3.6.1.4.1.7383.21.4 NAME 'sogxSharedFolder' DESC 'Ima
31+
pshared Folder' SUP TOP STRUCTURAL MUST ( cn $ mail $ sogxImapAcl ) )
32+
olcObjectClasses: {4}( 1.3.6.1.4.1.7383.21.5 NAME 'sogxMailConfig' DESC 'Confi
33+
gsogxmail' SUP TOP STRUCTURAL MUST ( cn $ postfix-mydestination ) )
34+
olcObjectClasses: {5}( 1.3.6.1.4.1.7383.21.6 NAME 'sogxTrashContainer' DESC 'T
35+
rash container' SUP TOP STRUCTURAL MUST ( cn ) )

0 commit comments

Comments
 (0)