Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.auth0.android.request.internal

import java.util.*

/**
* Small utility class to handle OpenID Connect conformance
*/
Expand All @@ -19,8 +17,7 @@ internal object OidcUtils {
*/
fun includeRequiredScope(scope: String): String {
val existingScopes = scope.split(" ")
.map { it.toLowerCase(Locale.ROOT) }
return if (!existingScopes.contains(REQUIRED_SCOPE)) {
return if (existingScopes.none { it == REQUIRED_SCOPE }) {
(existingScopes + REQUIRED_SCOPE).joinToString(separator = " ").trim()
} else {
scope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public void shouldSetRefreshToken() {
assertThat(parameters, hasEntry("refresh_token", DEVICE));
}

@Test
public void shouldKeepScopeCaseWhenAddingRequiredScope() {
Map<String, String> parameters = builder.setScope("profile read:Messages").asDictionary();
assertThat(parameters, hasEntry("scope", "profile read:Messages openid"));
}

@Test
public void shouldAddRequiredScopeWhenOnlyAnotherCaseIsPresent() {
Map<String, String> parameters = builder.setScope("OpenID profile").asDictionary();
assertThat(parameters, hasEntry("scope", "OpenID profile openid"));
}

@Test
public void shouldSetScopeWithOfflineAccess() {
Map<String, String> parameters = builder.setScope(ParameterBuilder.SCOPE_OFFLINE_ACCESS).asDictionary();
Expand Down
Loading