Skip to content

Add support for X-ORIGIN in schema element class ObjectClass #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 7, 2019
5 changes: 4 additions & 1 deletion Lib/ldap/schema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class ObjectClass(SchemaElement):
'AUXILIARY':None,
'ABSTRACT':None,
'MUST':(()),
'MAY':()
'MAY':(),
'X-ORIGIN':(None,)
}

def _set_attrs(self,l,d):
Expand All @@ -146,6 +147,7 @@ def _set_attrs(self,l,d):
self.desc = d['DESC'][0]
self.must = d['MUST']
self.may = d['MAY']
self.x_origin = d['X-ORIGIN'][0]
# Default is STRUCTURAL, see RFC2552 or draft-ietf-ldapbis-syntaxes
self.kind = 0
if d['ABSTRACT']!=None:
Expand All @@ -168,6 +170,7 @@ def __str__(self):
result.append({0:' STRUCTURAL',1:' ABSTRACT',2:' AUXILIARY'}[self.kind])
result.append(self.key_list('MUST',self.must,sep=' $ '))
result.append(self.key_list('MAY',self.may,sep=' $ '))
result.append(self.key_attr('X-ORIGIN',self.x_origin,quoted=1))
return '( %s )' % ''.join(result)


Expand Down
20 changes: 18 additions & 2 deletions Tests/t_ldap_schema_subentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import ldif
from ldap.ldapobject import SimpleLDAPObject
import ldap.schema
from ldap.schema.models import ObjectClass
from ldap.schema.models import ObjectClass, AttributeType
from slapdtest import SlapdTestCase, requires_ldapi

HERE = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -61,10 +61,26 @@ def test_urlfetch_file(self):
str(obj),
"( 2.5.6.9 NAME 'groupOfNames' SUP top STRUCTURAL MUST cn "
"MAY ( member $ businessCategory $ seeAlso $ owner $ ou $ o "
"$ description ) )"
"$ description ) X-ORIGIN 'RFC 4519' )"
)


class TestXOrigin(unittest.TestCase):
def get_attribute_type(self, oid):
openldap_uri = 'file://{}'.format(TEST_SUBSCHEMA_FILES[1])
dn, schema = ldap.schema.urlfetch(openldap_uri)
return schema.get_obj(AttributeType, oid)

def test_origin_none(self):
self.assertEqual(
self.get_attribute_type('2.5.4.0').x_origin, None)

def test_origin_string(self):
self.assertEqual(
self.get_attribute_type('1.3.6.1.4.1.3401.8.2.8').x_origin,
'Pretty Good Privacy (PGP)')


class TestSubschemaUrlfetchSlapd(SlapdTestCase):
ldap_object_class = SimpleLDAPObject

Expand Down
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