-
Notifications
You must be signed in to change notification settings - Fork 393
Oauth scopes are now optional in bootconfig file #2778
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
Conversation
Added tests in BootConfigTest to make sure empty or missing scopes are gracefully handled both when the config is XML and JSON NB: I converted BootConfigTest to Kotlin to be able to use mockk - which was needed for the tests that read the config from the XML. Also added tests in OAuth2Test for getAuthorizationUrl I was initially focused on scopes, but ended adding tests for other parameters for completeness
| * @param ctx The context used to read XML resources. | ||
| * @return A BootConfig representing the native boot config object. | ||
| */ | ||
| static BootConfig getNativeBootConfig(Context ctx) { |
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.
Used by new tests that check bootconfig from xml.
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.
Is is possible that customers get this confused with the 'Native Login' feature?
Edit: That probably doesn't make sense.
| config.put(REMOTE_ACCESS_CONSUMER_KEY, remoteAccessConsumerKey); | ||
| config.put(OAUTH_REDIRECT_URI, oauthRedirectURI); | ||
| config.put(OAUTH_SCOPES, new JSONArray(Arrays.asList(oauthScopes))); | ||
| if (oauthScopes != null) { |
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.
Oauth scopes are optional so might not be there.
| remoteAccessConsumerKey = res.getString(R.string.remoteAccessConsumerKey); | ||
| oauthRedirectURI = res.getString(R.string.oauthRedirectURI); | ||
| oauthScopes = res.getStringArray(R.array.oauthScopes); | ||
| try { |
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.
Oauth scopes are optional so might not be there.
| * @throws URISyntaxException See {@link URISyntaxException}. | ||
| */ | ||
| @Test | ||
| public void testGetAuthorizationUrlWithLoginHint() throws URISyntaxException { |
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.
Unrelated to test - to improve coverage of the getAuthorizationUrl() method.
| * @throws URISyntaxException See {@link URISyntaxException}. | ||
| */ | ||
| @Test | ||
| public void testGetAuthorizationUrlWithCustomDisplayType() throws URISyntaxException { |
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.
Unrelated to test - to improve coverage of the getAuthorizationUrl() method.
| tryScopes(new String[] {}, null); | ||
|
|
||
| //null scopes -- should not find scopes | ||
| tryScopes(null, null); |
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.
Making sure null scopes are handled - null scopes can now happen with the change to BootConfig.java
| validateBootConfig(config, "Validation should fail with relative unauthenticatedStartPage value.") | ||
| } | ||
|
|
||
| fun testBootConfigJsonWithOauthScopes() { |
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.
NB: Only the tests named test*OauthScopes are new.
Added tests in BootConfigTest to make sure empty or missing scopes are gracefully handled both when the config is XML and JSON
NB: I converted BootConfigTest to Kotlin to be able to use mockk - which was needed for the tests that read the config from the XML.
Also added tests in OAuth2Test for getAuthorizationUrl.
I was initially focused on scopes, but ended adding tests for other parameters also for completeness.