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

feat: Added support for Authenticated Datafiles #271

Merged
merged 19 commits into from
Jun 17, 2020

Conversation

pthompson127
Copy link
Contributor

@pthompson127 pthompson127 commented Jun 10, 2020

Summary

  • Added support for Authenticated Datafiles
  • Added new config manager class (AuthDatafilePollingConfigManager) that extends PollingConfigManager
  • Modify conditional logic in optimizely.py to determine the type of config manager that will be used depending on input parameters

Test Plan

  • Added tests for AuthDatafilePollingConfigManager
  • Ran manual tests with a valid access token and corresponding sdk key

@pthompson127 pthompson127 requested a review from a team as a code owner June 10, 2020 23:14
@pthompson127 pthompson127 self-assigned this Jun 10, 2020
@pthompson127 pthompson127 marked this pull request as draft June 10, 2020 23:16
@coveralls
Copy link

coveralls commented Jun 11, 2020

Coverage Status

Coverage decreased (-0.01%) to 97.085% when pulling 058d728 on peter/datafile-auth-v2 into 30ff44c on master.

@pthompson127 pthompson127 marked this pull request as ready for review June 11, 2020 00:16
@pthompson127 pthompson127 removed their assignment Jun 11, 2020
Copy link
Contributor

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

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

LGTM, although I still think the changes are negligible and it would be easier to do it in existing PollingConfigManager by adding access_token as an optional parameter. Also, it would be easier to make a change in the code if users decided to instantiate PollingConfigManager themselves and switched to private datafiles instead.

@mikeproeng37
Copy link
Contributor

Please wait for @aliabbasrizvi to take a look as well :)

@aliabbasrizvi
Copy link
Contributor

Also, it would be easier to make a change in the code if users decided to instantiate PollingConfigManager themselves and switched to private datafiles instead.

I think the choice will be very explicit here.

optimizely/config_manager.py Outdated Show resolved Hide resolved
optimizely/config_manager.py Show resolved Hide resolved
@@ -40,6 +41,7 @@ def __init__(
skip_json_validation=False,
user_profile_service=None,
sdk_key=None,
access_token=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break the SDK, since a user can choose not to use named arguments, but rather pass them in as positional arguments. This should be the last argument in the method.

Also, I am not sure if access_token needs to be introduced here. It is a concept in the config manager and one can simple invoke the AuthDatafilePollingConfigManager and pass that in. So this is probably not useful.

Copy link

Choose a reason for hiding this comment

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

Agree that constructing AuthDatafilePollingConfigManager then passing it here as config_manager is a good way to go. I think this is how you customize other aspects of datafile fetching like URL and polling interval. The token isn't relevant to the Optimizely class.

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch on the order of arguments, wondering how it passed the unit tests.

IMO, adding access_token here as the last optional argument does not hurt and even makes sense. Each config manager (Polling and Static) with default parameters is referenced in here, so not sure why AuthDatafilePollingConfigManager has to be the exception. If access_token was set on PollingConfigManager then this could be considered as an option just like poling interval, but AuthDatafilePollingConfigManager is a separate entity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Though, I think that access_token should still be included in the constructor in order to use AuthDatafilePollingConfigManager in the case where someone chooses to create an optimizely instance.

optimizely/optimizely.py Outdated Show resolved Hide resolved
optimizely/config_manager.py Outdated Show resolved Hide resolved
tests/test_optimizely.py Outdated Show resolved Hide resolved
Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

Just a question on the class name. Looks good otherwise. @pawels-optimizely thoughts?

optimizely/config_manager.py Show resolved Hide resolved
Copy link
Contributor

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

LGTM

@pthompson127 pthompson127 merged commit 93689b9 into master Jun 17, 2020
@pthompson127 pthompson127 deleted the peter/datafile-auth-v2 branch June 17, 2020 18:34
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

6 participants