Skip to content
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

Remove init_config from LDAP3LoginManager #66

Merged
merged 2 commits into from
Aug 27, 2019

Conversation

gmacon
Copy link
Collaborator

@gmacon gmacon commented Aug 25, 2019

This is the first PR moving towards addressing #40. Without the need to support init_config any more, we can unconditionally store the LDAP3LoginManager state on the Flask application context.

The init_config method prevents us from storing LDAP3LoginManager state
on the Flask application context, which is needed to support certain
patterns of Flask usage.

Issue: nickw444#40
Previously, the mock ServerPool was never used with init_app. From the
docs, I would have expected MagicMock to implement __iter__, but it
wasn't working.
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.09%) to 95.833% when pulling 76e2188 on gmacon:issue-40-remove-init_config into 0ae76cd on nickw444:master.

@@ -49,7 +88,7 @@ class LDAP3LoginManager(object):
def __init__(self, app=None):

self._save_user = None
self.config = {}
self.config = dict(_CONFIG_DEFAULTS)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably lead to the question "why didn't you use a dict literal for _CONFIG_DEFAULTS. The reason is that, in the next PR, I'll change

self.config.update(app.config)

to

for k, v in _CONFIG_DEFAULTS:
    app.config.setdefault(k, v)

in init_app below.

Copy link
Owner

@nickw444 nickw444 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Some great steps toward solving some common issues in this library. Do you have any ideas around a release plan for these changes? I think it will be worth batching the changes part of the upcoming refactor/bug fixes and cut a major API incompatible release. What do you think?

self.config.setdefault(
'LDAP_GET_GROUP_ATTRIBUTES', ldap3.ALL_ATTRIBUTES)
self.config.setdefault('LDAP_ADD_SERVER', True)
self.config.update(app.config)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to config being moved to app.config in the next PR 😄

@@ -145,6 +124,13 @@ def init_config(self, config):
use_ssl=self.config['LDAP_USE_SSL']
)

if hasattr(app, 'teardown_appcontext'):
app.teardown_appcontext(self.teardown)
else: # pragma: no cover
Copy link
Owner

@nickw444 nickw444 Aug 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is something that we can phase out (less need to support old flask versions if we are doing a API incompatible release)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I created #67 to track that.

@gmacon
Copy link
Collaborator Author

gmacon commented Aug 27, 2019

I think bundling together several breaking changes is a good idea. I've created milestone 1.0 to track everything we want to include in the breaking release.

@gmacon gmacon merged commit 9914a31 into nickw444:master Aug 27, 2019
@gmacon gmacon deleted the issue-40-remove-init_config branch August 27, 2019 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants