-
Notifications
You must be signed in to change notification settings - Fork 54
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
Pureldap and pureber repr fixes #148
Conversation
* __repr__ method encoding fixes like showing LDAPResult(resultCode=0, matchedDN='uid=user') instead of LDAPResult(resultCode=0, matchedDN="b'uid=user'"); * showing userIdentity, oldPasswd and newPasswd in the LDAPPasswordModifyRequest.__repr__; * LDAPMatchingRuleAssertion.__init__ is now properly initialized with bytes attributes in Python 3; * LDAPExtendedResponse custom tag is now used.
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
==========================================
+ Coverage 92.42% 93.11% +0.69%
==========================================
Files 72 72
Lines 9663 9924 +261
Branches 929 976 +47
==========================================
+ Hits 8931 9241 +310
+ Misses 590 554 -36
+ Partials 142 129 -13
Continue to review full report at Codecov.
|
|
not sure why I have not received notifications for this PR.... is this ready for review? |
|
Yes, I think. Though I don't know what caused codecov errors this time. |
|
Hi....codecov is failing due to branch coverage... but the HTML view for codecov is not that nice If you run the test locally, you can check build/coverage-html and it should give you more hints about branch coverage, and which branch is not covered .... but I don't know why test_pureldap.py is not reported as 100% the idea is that for the code from tests we want a hard 100% coverage to make sure all the tests are executed and no test is always skipped. I will take a look at the coverage |
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.
Looks good. Only minor comments.
Sorry, I don't have much time to review this.
I don't really use repr and as long as toWire works I think that we can be relaxed in terms of repr.
When I use repr, I want to see the instance id :)
And now that we have toWire maybe we can add id value to repr... but can be done in a later PR
Thanks!
| if self.oldPasswd is not None: | ||
| l.append('oldPasswd={}'.format(repr(self.oldPasswd))) | ||
| if self.newPasswd is not None: | ||
| l.append('newPasswd={}'.format(repr(self.newPasswd))) |
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 don't know why this is TODO... but I think than unless there is an explicit request, is better to leave the password outside of the repr... is ok to have userIdentity... but maybe use a private member self._userIdentity
|
Great, thank you for the review! I am going to change the |
now show passwords as asterisks
|
Greetings! Fixed the issues with the password representations and |
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.
Looks good. Thanks.
Only minor comments.
| l = [] | ||
| l.append('version=%d' % self.version) | ||
| l.append('dn=%s' % repr(converter(self.dn))) | ||
| l.append('auth=%s' % repr(converter(self.auth))) | ||
| l.append('dn=%s' % repr(repr_converter(self.dn))) |
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.
sorry for spotting this only now.
but shouldn't rep(self.dn) already return a repr converted value? ... otherwise just use l.append('dn=%s' % repr_converter(self.dn)) as repr_converter should return the same value as repr.
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.
Not in all cases unfortunately. In Python 3 it may look as dn="b'uid=user'" if dn was specified as byte string. repr_converter is used to make it look like dn="uid=user".
repr function is also needed, without it the result may look like dn=uid=user.
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.
omg :) ok. thanks for the comment
this py3/py2 thing is ugly.
I think that this can be merge as it is and have a release
| class LDAPPasswordModifyRequest_oldPasswd(BEROctetString): | ||
| class LDAPPasswordModifyRequest_passwd(BEROctetString): | ||
| def __repr__(self): | ||
| value = '*' * len(self.value) |
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.
Minor comment:
For security freaks.... just use a single asterisks not to reveal the length of the password and empty if password was not set.
But I am ok with this implementation.. better than plain text :)
|
codecov/project/tests look ok... it reports a missing empty line https://codecov.io/gh/twisted/ldaptor/compare/ebef037bccdaa530de94b6e2afbfda1bd605491a...ab76a873dc2f7370edc696aa68a8c6030dafaea5/src/ldaptor/test/test_pureldap.py?before=ldaptor/test/test_pureldap.py#L33 looks like a bug in coverage or codecov |
|
Thank you! Can you help me with the last problem? This PR cannot be merged automatically so GitHub suggested to make it via command line. The last line in the given instructions is How to properly merge it to master? |
|
Done... by using my admin powers... but I have also used the to disable the requirement on code coverage. |
|
Thanks! A possible release has been discussed in the old pull request. Maybe the time has come? |
|
@GrayAn if you or @adiroiban can put the effort into making a PR for a new release, I'd be happy to tag and upload to pypi |
|
yes. a new PR is required to update the version and the release notes in NEWS.rst maybe we can also set up automatic pypi releases from travis like (https://github.com/twisted/twistedchecker/pull/108/files) but if @psi29a is ok with manual upload. that is not required. Thanks! |
pureldap and pureber minor fixes (mostly string representations):
__repr__method encoding fixes like showingLDAPResult(resultCode=0, matchedDN='uid=user')instead ofLDAPResult(resultCode=0, matchedDN="b'uid=user'");userIdentity,oldPasswdandnewPasswdin theLDAPPasswordModifyRequest.__repr__;LDAPMatchingRuleAssertion.__init__is now properly initialized with bytes attributes in Python 3;LDAPExtendedResponsecustom tag is now used.Showing passwords in the
LDAPPasswordModifyRequestrepresentation may sound not good butLDAPBindRequestwas implemented in the same way.Tests for
__repr__methods were added to avoid test coverage issues.LDAPMatchingRuleAssertionandLDAPExtendedResponsefixes are not actually__repr__fixes but they are rather trivial. Is it OK to have them in this PR?Contributor Checklist:
docs/source/NEWS.rstCONTRIBUTING.rst.