-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
UI: Test business logic for oidc callback params #19727
Conversation
Co-authored-by: claire bontempo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for working on this! 🙏
Just some questions, nothing blocking
path: 'oidc-path', | ||
namespace: 'my-namespace', | ||
}; | ||
const results = getParamsForCallback(params, '?code=my-code&state=my-state&namespace=my-namespace'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the namespace in the search string should be different from the namespace in the params so we are testing it's correctly preferring the namespace from the query string? But I see below there's a test for that so I'm not exactly sure what we're testing for here 🤔 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string is basically the expected URL, and the namespace in the params is what the Ember route parses from the URL. So we're not testing differences here, just trying to match the real world scenario :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - so many params! I got mixed up because I thought the queryString passed to getParamsForCallback
was always whatever was from window.location.search
and I never saw namespace=
as part of that search string
test('it parses params correctly with regular inputs and namespace in state (unencoded)', function (assert) { | ||
const searchString = '?code=my-code&state=my-state,ns=foo/bar'; | ||
const params = { | ||
state: 'my-state,ns', // Ember parses the QP incorrectly if unencoded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩
}); | ||
}); | ||
|
||
test('namespace in state takes precedence over namespace in route (unencoded)', function (assert) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen the namespace sent in the route like this! When does this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the URL includes the namespace parameter that's the "in route" version. It might not be an actual case in the wild, but behaviorally the method overwrites the route namespace param with the one in state so I wanted to capture that behavior as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha! Thanks for explaining 😄
This PR moves the logic that happens in
beforeModel
for the oidc callback route into an easily-testable method.