1
0
Fork 0
mirror of https://github.com/kakwa/ldapcherry synced 2025-07-03 03:47:35 +02:00

change backend key name in attributes + methods

* adding get_backends
* adding get_selfattributes (attributes users can change themselves)
* adding unit tests
* rename backend-attributes -> bakends (for homogeneity with role.yml)
This commit is contained in:
kakwa 2015-05-18 12:30:51 +02:00
parent a71093038c
commit 7cdbe459b6
8 changed files with 211 additions and 29 deletions

View file

@ -1 +0,0 @@
../../conf/attributes.yml

112
tests/cfg/attributes.yml Normal file
View file

@ -0,0 +1,112 @@
cn:
description: "Firt Name and Display Name"
display_name: "Display Name"
type: string
autofill:
function: cn
args:
- $first-name
- $name
backends:
ldap: cn
ad: CN
first-name:
description: "First name of the user"
display_name: "First Name"
type: string
backends:
ldap: givenName
ad: givenName
name:
description: "Family name of the user"
display_name: "Name"
type: string
backends:
ldap: sn
ad: sn
email:
description: "Email of the user"
display_name: "Name"
type: email
autofill:
function: email
args:
- $first-name
- $last-name
- '@example.com'
backends:
ldap: email
ad: EMAIL
uid:
description: "UID of the user"
display_name: "UID"
type: string
autofill:
function: uid
args:
- $first-name
- $last-name
backends:
ldap: uid
ad: UID
uidNumber:
description: "User ID Number of the user"
display_name: "UID Number"
type: int
autofill:
function: uidNumber
args:
- $first-name
- $last-name
backends:
ldap: uidNumber
ad: UIDNumber
gidNumber:
description: "Group ID Number of the user"
display_name: "GID Number"
type: int
default: 10000
backends:
ldap: gidNumber
ad: GIDNumber
shell:
description: "Shell of the user"
display_name: "Shell"
self: True
type: stringlist
values:
- /bin/bash
- /bin/zsh
- /bin/sh
backends:
ldap: shell
ad: SHELL
home:
description: "Home user path"
display_name: "Home"
type: string
autofill:
function: home
args:
- $first-name
- $last-name
- /home/
backends:
ldap: home
ad: Home
password:
description: "Password of the user"
display_name: "Password"
self: True
type: password
backends:
ldap: userPassword
ad: userPassword
logscript:
description: "Windows login script"
display_name: "Login script"
type: fix
value: login1.bat
backends:
ad: logonScript

View file

@ -7,21 +7,21 @@ cn:
args:
- $first-name
- $name
backend-attributes:
bakends:
ldap: cn
ad: CN
first-name:
description: "First name of the user"
display_name: "First Name"
type: string
backend-attributes:
bakends:
ldap: givenName
ad: givenName
name:
description: "Family name of the user"
display_name: "Name"
type: string
backend-attributes:
bakends:
ldap: sn
ad: sn
email:
@ -34,7 +34,7 @@ email:
- $first-name
- $last-name
- '@example.com'
backend-attributes:
bakends:
ldap: email
ad: EMAIL
uid:
@ -45,7 +45,7 @@ uid:
args:
- $first-name
- $last-name
backend-attributes:
bakends:
ldap: uid
ad: UID
uidNumber:
@ -57,7 +57,7 @@ uidNumber:
args:
- $first-name
- $last-name
backend-attributes:
bakends:
ldap: uidNumber
ad: UIDNumber
gidNumber:
@ -65,7 +65,7 @@ gidNumber:
display_name: "GID Number"
type: int
default: 10000
backend-attributes:
bakends:
ldap: gidNumber
ad: GIDNumber
shell:
@ -77,7 +77,7 @@ shell:
- /bin/bash
- /bin/zsh
- /bin/sh
backend-attributes:
bakends:
ldap: shell
ad: SHELL
home:
@ -90,7 +90,7 @@ home:
- $first-name
- $last-name
- /home/
backend-attributes:
bakends:
ldap: home
ad: Home
@ -99,7 +99,7 @@ password:
display_name: "Password"
self: True
type: password
backend-attributes:
bakends:
ldap: userPassword
ad: userPassword
logscript:
@ -107,5 +107,5 @@ logscript:
display_name: "Login script"
type: fix
value: login1.bat
backend-attributes:
bakends:
ad: logonScript

View file

@ -7,7 +7,7 @@ cn:
args:
- $first-name
- $name
backend-attributes:
backends:
ldap: cn
ad: CN
@ -15,6 +15,6 @@ first-name:
description: "First name of the user"
display_name: "First Name"
type: string
backend-attributes:
backends:
ldap: givenName
ad: givenName

View file

@ -1 +0,0 @@
../../conf/roles.yml

47
tests/cfg/roles.yml Normal file
View file

@ -0,0 +1,47 @@
admin-lv3:
display_name: Administrators Level 3
backends:
ldap:
groups:
- cn=dns admins,ou=group,dc=example,dc=com
- cn=nagios admins,ou=group,dc=example,dc=com
- cn=puppet admins,ou=group,dc=example,dc=com
- cn=users,ou=group,dc=example,dc=com
ad:
groups:
- Domain Users
- Administrators
- Domain Controllers
admin-lv2:
display_name: Administrators Level 2
LC_admins: True
backends:
ldap:
groups:
- cn=nagios admins,ou=group,dc=example,dc=com
- cn=users,ou=group,dc=example,dc=com
ad:
groups:
- Domain Users
developpers:
display_name: Developpers
backends:
ldap:
groups:
- cn=developpers,ou=group,dc=example,dc=com
- cn=users,ou=group,dc=example,dc=com
ad:
groups:
- Domain Users
users:
display_name: Simple Users
backends:
ldap:
groups:
- cn=users,ou=group,dc=example,dc=com
ad:
groups:
- Domain Users

View file

@ -17,6 +17,18 @@ class TestError(object):
inv = Attributes('./tests/cfg/attributes.yml')
return True
def testGetSelfAttributes(self):
inv = Attributes('./tests/cfg/attributes.yml')
ret = inv.get_selfattributes()
expected = Set(['password', 'shell'])
assert ret == expected
def testGetSelfAttributes(self):
inv = Attributes('./tests/cfg/attributes.yml')
ret = inv.get_backends()
expected = Set(['ldap', 'ad'])
assert ret == expected
def testNoFile(self):
try:
inv = Attributes('./tests/cfg/dontexist')