Skip to content

feat: Added support for Authenticated Datafiles#271

Merged
pthompson127 merged 19 commits into
masterfrom
peter/datafile-auth-v2
Jun 17, 2020
Merged

feat: Added support for Authenticated Datafiles#271
pthompson127 merged 19 commits into
masterfrom
peter/datafile-auth-v2

Conversation

@pthompson127
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Contributor

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

@aliabbasrizvi
Copy link
Copy Markdown
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.

Comment thread optimizely/config_manager.py Outdated
Comment thread optimizely/config_manager.py
Comment thread optimizely/optimizely.py Outdated
skip_json_validation=False,
user_profile_service=None,
sdk_key=None,
access_token=None,
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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.

Comment thread optimizely/optimizely.py Outdated
Comment thread optimizely/config_manager.py Outdated
Comment thread tests/test_optimizely.py Outdated
Copy link
Copy Markdown
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?

Comment thread optimizely/config_manager.py
Copy link
Copy Markdown
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
Copy Markdown
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.

6 participants