Skip to content

Conversation

@wmathurin
Copy link
Contributor

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

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) {
Copy link
Contributor Author

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.

Copy link
Contributor

@brandonpage brandonpage Oct 3, 2025

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) {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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);
Copy link
Contributor Author

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() {
Copy link
Contributor Author

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.

@wmathurin wmathurin merged commit ac6c9cc into forcedotcom:dev Oct 6, 2025
4 of 6 checks passed
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.

2 participants