Skip to content

Commit 9c48d3e

Browse files
committed
Test types and values of ObjectClass and AttributeType attributes
1 parent 7b76b00 commit 9c48d3e

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

Tests/t_ldap_schema_subentry.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,82 @@ def test_set_origin_tuple(self):
161161
self.assertIn(" X-ORIGIN 'user defined' ", str(attr))
162162

163163

164+
class TestAttributes(unittest.TestCase):
165+
def get_schema(self):
166+
openldap_uri = 'file://{}'.format(TEST_SUBSCHEMA_FILES[0])
167+
dn, schema = ldap.schema.urlfetch(openldap_uri)
168+
return schema
169+
170+
def test_empty_attributetype_attrs(self):
171+
"""Check types and values of attributes of a minimal AttributeType"""
172+
# (OID 2.999 is actually "/Example", for use in documentation)
173+
attr = AttributeType('( 2.999 )')
174+
self.assertEqual(attr.oid, '2.999')
175+
self.assertEqual(attr.names, ())
176+
self.assertEqual(attr.desc, None)
177+
self.assertEqual(attr.obsolete, False)
178+
self.assertEqual(attr.single_value, False)
179+
self.assertEqual(attr.syntax, None)
180+
self.assertEqual(attr.no_user_mod, False)
181+
self.assertEqual(attr.equality, None)
182+
self.assertEqual(attr.substr, None)
183+
self.assertEqual(attr.ordering, None)
184+
self.assertEqual(attr.usage, 0)
185+
self.assertEqual(attr.sup, ())
186+
self.assertEqual(attr.x_origin, ())
187+
188+
def test_empty_objectclass_attrs(self):
189+
"""Check types and values of attributes of a minimal ObjectClass"""
190+
# (OID 2.999 is actually "/Example", for use in documentation)
191+
cls = ObjectClass('( 2.999 )')
192+
self.assertEqual(cls.oid, '2.999')
193+
self.assertEqual(cls.names, ())
194+
self.assertEqual(cls.desc, None)
195+
self.assertEqual(cls.obsolete, False)
196+
self.assertEqual(cls.must, ())
197+
self.assertEqual(cls.may, ())
198+
self.assertEqual(cls.kind, 0)
199+
self.assertEqual(cls.sup, ('top',))
200+
self.assertEqual(cls.x_origin, ())
201+
202+
def test_attributetype_attrs(self):
203+
"""Check types and values of an AttributeType object's attributes"""
204+
schema = self.get_schema()
205+
attr = schema.get_obj(AttributeType, '1.3.6.1.4.1.11.1.3.1.1.3')
206+
expected_desc = (
207+
'Maximum time an agent or service allows for a search to complete'
208+
)
209+
self.assertEqual(attr.oid, '1.3.6.1.4.1.11.1.3.1.1.3')
210+
self.assertEqual(attr.names, ('searchTimeLimit',))
211+
self.assertEqual(attr.desc, expected_desc)
212+
self.assertEqual(attr.obsolete, False)
213+
self.assertEqual(attr.single_value, True)
214+
self.assertEqual(attr.syntax, '1.3.6.1.4.1.1466.115.121.1.27')
215+
self.assertEqual(attr.no_user_mod, False)
216+
self.assertEqual(attr.equality, 'integerMatch')
217+
self.assertEqual(attr.ordering, 'integerOrderingMatch')
218+
self.assertEqual(attr.sup, ())
219+
self.assertEqual(attr.x_origin, ('RFC4876', 'user defined'))
220+
221+
def test_objectclass_attrs(self):
222+
"""Check types and values of an ObjectClass object's attributes"""
223+
schema = self.get_schema()
224+
cls = schema.get_obj(ObjectClass, '2.5.6.9')
225+
expected_may = (
226+
'member', 'businessCategory', 'seeAlso', 'owner', 'ou', 'o',
227+
'description',
228+
)
229+
self.assertEqual(cls.oid, '2.5.6.9')
230+
self.assertEqual(cls.names, ('groupOfNames',))
231+
self.assertEqual(cls.desc, None)
232+
self.assertEqual(cls.obsolete, False)
233+
self.assertEqual(cls.must, ('cn',))
234+
self.assertEqual(cls.may, expected_may)
235+
self.assertEqual(cls.kind, 0)
236+
self.assertEqual(cls.sup, ('top',))
237+
self.assertEqual(cls.x_origin, ('RFC 4519',))
238+
239+
164240
class TestSubschemaUrlfetchSlapd(SlapdTestCase):
165241
ldap_object_class = SimpleLDAPObject
166242

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy