mirror of
https://github.com/kakwa/ldapcherry
synced 2025-07-03 11:57:41 +02:00
adding method and unit tests to get all the attributes of one backend
This commit is contained in:
parent
5b03596ed7
commit
74ed8fa0d4
2 changed files with 27 additions and 2 deletions
|
@ -10,7 +10,7 @@ import sys
|
|||
|
||||
from ldapcherry.pyyamlwrapper import loadNoDump
|
||||
from ldapcherry.pyyamlwrapper import DumplicatedKey
|
||||
from ldapcherry.exceptions import MissingAttributesFile, MissingKey, WrongAttributeType
|
||||
from ldapcherry.exceptions import MissingAttributesFile, MissingKey, WrongAttributeType, WrongBackend
|
||||
from sets import Set
|
||||
import yaml
|
||||
|
||||
|
@ -22,6 +22,7 @@ class Attributes:
|
|||
self.attributes_file = attributes_file
|
||||
self.backends = Set([])
|
||||
self.self_attributes = Set([])
|
||||
self.backend_attributes = {}
|
||||
try:
|
||||
stream = open(attributes_file, 'r')
|
||||
except:
|
||||
|
@ -40,6 +41,9 @@ class Attributes:
|
|||
self.self_attributes.add(attrid)
|
||||
for b in attr['backends']:
|
||||
self.backends.add(b)
|
||||
if b not in self.backend_attributes:
|
||||
self.backend_attributes[b] = []
|
||||
self.backend_attributes[b].append(attr['backends'][b])
|
||||
|
||||
def _mandatory_check(self, attr):
|
||||
for m in ['description', 'display_name', 'type', 'backends']:
|
||||
|
@ -54,6 +58,11 @@ class Attributes:
|
|||
"""return the list of backends in roles file"""
|
||||
return self.backends
|
||||
|
||||
def get_backend_attributes(self, backend):
|
||||
if backend not in self.backends:
|
||||
raise WrongBackend(backend)
|
||||
return self.backend_attributes[backend]
|
||||
|
||||
def get_attributes(self):
|
||||
"""get the list of groups from roles"""
|
||||
return self.self_attributes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue