Skip to content

feat: Added support for Authenticated Datafiles #255

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

Merged
merged 11 commits into from
Jun 6, 2020

Conversation

zashraf1985
Copy link
Contributor

@zashraf1985 zashraf1985 commented Jun 3, 2020

Summary

Added support for Authenticated Datafiles

Test plan

Added new unit tests

@coveralls
Copy link

coveralls commented Jun 3, 2020

Coverage Status

Coverage increased (+0.02%) to 99.561% when pulling c1a8e13 on zeeshan/datafile-auth into 1e4247b on master.

@zashraf1985 zashraf1985 marked this pull request as ready for review June 3, 2020 22:15
@zashraf1985 zashraf1985 requested a review from a team as a code owner June 3, 2020 22:15
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-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

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

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

Actually, can you add a couple of simple tests in http_project_config_manager_spec.rb? Make sure the header is there, etc.

@zashraf1985
Copy link
Contributor Author

Hey @thomaszurkan-optimizely . Thanks for reviewing quickly. I am already writing tests. That's what I mentioned in the PR summary too.

Comment on lines 468 to 486
it 'should add authorization header when auth token is provided' do
allow(Optimizely::Helpers::HttpUtils).to receive(:make_request)
@http_project_config_manager = Optimizely::HTTPProjectConfigManager.new(
sdk_key: 'valid_sdk_key',
datafile_access_token: 'the-token'
)
sleep 0.1
expect(Optimizely::Helpers::HttpUtils).to have_received(:make_request).with(anything, anything, anything, hash_including('Authorization' => 'Bearer the-token'), anything)
end

it 'should add authorization header when auth token is provided' do
allow(Optimizely::Helpers::HttpUtils).to receive(:make_request)
@http_project_config_manager = Optimizely::HTTPProjectConfigManager.new(
sdk_key: 'valid_sdk_key',
datafile_access_token: 'the-token'
)
sleep 0.1
expect(Optimizely::Helpers::HttpUtils).to have_received(:make_request).with(anything, anything, anything, hash_including('Authorization' => 'Bearer the-token'), anything)
end

Choose a reason for hiding this comment

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

Just out of curiosity, is there a reason why this part of the spec is duplicated? Seems like the two blocks are exactly the same.
Wondering if this is instead supposed to test the case where an invalid SDK key is provided (not sure if that is handled / error-checked elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @pthompson127 ... good eye... its just a plain stupid mistake :). i wil fix it.

Choose a reason for hiding this comment

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

@zashraf1985 ahh gotcha :)

@zashraf1985 zashraf1985 removed their assignment Jun 5, 2020
@zashraf1985 zashraf1985 closed this Jun 5, 2020
@zashraf1985 zashraf1985 reopened this Jun 5, 2020
Copy link

@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.

looks good, but I am wondering if this was actually tested with a proper access token and sdk key

@zashraf1985
Copy link
Contributor Author

zashraf1985 commented Jun 5, 2020

looks good, but I am wondering if this was actually tested with a proper access token and sdk key

The last commit where i changed the url was not tested because that url is not working yet. it was thoroughly tested on the previous test url though. @mjc1283 told me he was changing the url to the one we will eventually use to avoid creating a new PR and re-releasing in case of javascript. I asked him should i change the url for ruby too as it is not merged yet, he agreed, thats why we did this to save us a hassle of another PR just to modify the url.

@zashraf1985 zashraf1985 closed this Jun 5, 2020
@zashraf1985 zashraf1985 reopened this Jun 5, 2020
@zashraf1985 zashraf1985 closed this Jun 5, 2020
@zashraf1985 zashraf1985 reopened this Jun 5, 2020
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-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

@thomaszurkan-optimizely thomaszurkan-optimizely merged commit 75aae12 into master Jun 6, 2020
@mikeproeng37 mikeproeng37 deleted the zeeshan/datafile-auth branch June 6, 2020 02: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.

6 participants