-
Notifications
You must be signed in to change notification settings - Fork 126
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #247 +/- ##
===========================================
+ Coverage 57.91% 70.93% +13.01%
===========================================
Files 49 49
Lines 5910 4816 -1094
Branches 815 812 -3
===========================================
- Hits 3423 3416 -7
+ Misses 2157 1066 -1091
- Partials 330 334 +4
Continue to review full report at Codecov.
|
I checked how the attribute looks on the object, and all looks fine. I suggest adding this extra test. Could you quickly review it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc string of ObjectClass
needs to be updated, too.
AttributeType also doesn't have info about 'X-ORIGIN' in its docstring. Should I update it too? Test looks good to me. |
On Thu, Oct 25, 2018, 18:05 Simon Pichugin ***@***.***> wrote:
AttributeType also doesn't have info about 'X-ORIGIN' in its docstring.
Should I update it too?
That would be great.
|
I've added the docstrings. One more issue popped up. It is described here - So should I implement it? Are you okay with it? |
As I see it, the problem with X-ATTR is that it's not really standardized anywhere. Is that right? |
Yes, it's right.
At least, Oracle's Directory Server uses it the same way we are. :) Anyway, if we'll add the multi-value support it wouldn't hurt the existing functionality. Also, currently, if we have X-ORIGIN ( 'my objectclass' 'user defined' ), the existing python-ldap implementation will just print the first value, which is wrong. |
I've added the functionality I mentioned before and a test for it (also, I used FreeIPA LDIFs which have multi-valued X-ORIGIN, btw). Please, check. |
Are there any objections? :) |
Tests pass, but there's standard to verify that the behavior is correct. I can't find anything to suggest that there's agreement between LDAP servers on what X-ORIGIN actually means. |
as seen on Another usage example in LDAP server implementation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's put it in. @tiran, if you could confirm this is OK, that would be great.
I'm missing a test that setting x_origin
works, and a test of the behavior of setting x_origin
(to values like None
, list, tuple, or single string).
Let me know if I should write it.
Lib/ldap/schema/models.py
Outdated
@@ -126,6 +126,9 @@ class ObjectClass(SchemaElement): | |||
sup | |||
This list of strings contains NAMEs or OIDs of object classes | |||
this object class is derived from | |||
x-origin | |||
This string contains the X-ORIGIN text which is typically used to indicate | |||
the source of the associated schema element. It can a list of strings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the source of the associated schema element. It can a list of strings | |
the source of the associated schema element. It should be a tuple of strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. But it has a small typo - "be be"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should we change other docstrings then for the consistency? For example, 'may' also should be a tuple but the docstring states 'This list of strings':
may
This list of strings contains NAMEs or OIDs of additional attributes
an entry of the object class may have
I can add one more commit here for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess "sequence" is the exact thing we want here.
Perhaps write it out as "sequence (list/tuple)", to aid people who don't actively know that definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, list wouldn't work because the SchemaElement class explicitly requires a 'tuple'.
class SchemaElement:
def key_list(self,key,values,sep=' ',quoted=0):
assert type(values)==tuple,TypeError("values has to be a tuple, was %r" % values)
Sure. So if I missed something and it's there (or you have tools for that) feel free point me to it :) |
Well, new features need tests, even if old ones don't have them. |
Sure, I agree. Thank you very much! |
The sequences are always tuples, not lists. String attributes are None when missing.
Can I ask for a quick check of these? |
Looks great! Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross-reviewed by me and @droideck
389 Directory Server uses X-ORIGIN ObjectClass attribute for determining if the ObjectClass is 'user defined' or not. 389 Directory Server UI currently depends on it.
Also, X-ORIGIN is already supported for AttributeType schema element. So it makes sense to make it consistent across these two schema elements.