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

Add session-related endpoints #269

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Conversation

cmatheson
Copy link
Contributor

Description

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@@ -76,7 +76,7 @@ http_interactions:
- cloudflare
body:
encoding: ASCII-8BIT
string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"}}'
string: '{"user":{"object":"user","id":"user_01H93ZY4F80YZRRS6N59Z2HFVS","email":"test@workos.app","email_verified":false,"first_name":"Lucille","last_name":"Bluth","created_at":"2023-08-30T19:50:13.214Z","updated_at":"2023-08-30T19:50:13.214Z","user_type":"managed","sso_profile_id":"prof_01H93ZTVWYPAT4RKDSPFPPXH0J"},"access_token":"access_token","refresh_token":"refresh_token"}'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i kind of hate vcr and i manually edited/added all of these responses. this is not technically the right way to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i added some code to properly sanitize these.

@cmatheson cmatheson force-pushed the add-session-management-endpoints branch 3 times, most recently from 06e57a3 to 167b246 Compare March 19, 2024 17:05
@cmatheson cmatheson force-pushed the add-session-management-endpoints branch from 167b246 to 94a0fc6 Compare March 19, 2024 17:11
Comment on lines 5 to 6
# The AuthenticationResponse class represents an Authentication Response as well as an corresponding
# response data that can later be appended on.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "an corresponding response data that can later be appended on" refer to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohhhh... this is a complete copy/paste from AuthenticationResponse. i'll come up with better wording 😬

sig do
params(
session_id: String,
).returns(NilClass)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use .void instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahhh, i knew there must be something like this. will fix.

Copy link
Contributor

@mthadley mthadley left a comment

Choose a reason for hiding this comment

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

Left a few nits but overall LGTM!

Comment on lines +29 to +34
config.filter_sensitive_data('<ACCESS_TOKEN>', :token) do |interaction|
JSON.parse(interaction.response.body)['access_token']
end
config.filter_sensitive_data('<REFRESH_TOKEN>', :token) do |interaction|
JSON.parse(interaction.response.body)['refresh_token']
end
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice if this was the default and test authors didn't need to remember to opt-in, though I don't know the best way to implement that behavior without it also being inconsistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh, i agree. i tried just having the handler work without tags but it errors out if you don't return something. (i guess i could return some bogus value?). this seemed to be the "vcr" way to handle this situation.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 78.78788% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 96.79%. Comparing base (6434928) to head (f08818e).

Files Patch % Lines
lib/workos/user_management.rb 64.70% 6 Missing ⚠️
lib/workos/refresh_authentication_response.rb 91.66% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #269      +/-   ##
==========================================
- Coverage   97.22%   96.79%   -0.44%     
==========================================
  Files          57       58       +1     
  Lines        1371     1403      +32     
==========================================
+ Hits         1333     1358      +25     
- Misses         38       45       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cmatheson cmatheson merged commit b75d2ef into main Mar 19, 2024
1 check passed
@cmatheson cmatheson deleted the add-session-management-endpoints branch March 19, 2024 20:20
@mthadley mthadley mentioned this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants