Skip to content

Commit

Permalink
Merge pull request #236 from auth0/fix-conn-scope
Browse files Browse the repository at this point in the history
Make connection_scope separate values with comma
  • Loading branch information
lbalmaceda committed May 28, 2019
2 parents 0de595b + e452257 commit 362915e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public Builder withScope(@NonNull String scope) {
public Builder withConnectionScope(@NonNull String... connectionScope) {
StringBuilder sb = new StringBuilder();
for (String s : connectionScope) {
sb.append(s.trim()).append(" ");
sb.append(s.trim()).append(",");
}
if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,37 +407,37 @@ public void shouldNotHaveDefaultConnectionScope() throws Exception {

@Test
public void shouldSetConnectionScopeFromParameters() throws Exception {
Map<String, Object> parameters = Collections.singletonMap("connection_scope", (Object) "openid email contacts");
Map<String, Object> parameters = Collections.singletonMap("connection_scope", (Object) "openid,email,contacts");
WebAuthProvider.init(account)
.withConnectionScope("profile super_scope")
.withConnectionScope("profile", "super_scope")
.withParameters(parameters)
.start(activity, callback);

verify(activity).startActivity(intentCaptor.capture());
Uri uri = intentCaptor.getValue().getParcelableExtra(AuthenticationActivity.EXTRA_AUTHORIZE_URI);
assertThat(uri, is(notNullValue()));

assertThat(uri, hasParamWithValue("connection_scope", "openid email contacts"));
assertThat(uri, hasParamWithValue("connection_scope", "openid,email,contacts"));
}

@Test
public void shouldSetConnectionScopeFromSetter() throws Exception {
Map<String, Object> parameters = Collections.singletonMap("connection_scope", (Object) "openid email contacts");
Map<String, Object> parameters = Collections.singletonMap("connection_scope", (Object) "openid,email,contacts");
WebAuthProvider.init(account)
.withParameters(parameters)
.withConnectionScope("profile super_scope")
.withConnectionScope("profile", "super_scope")
.start(activity, callback);

verify(activity).startActivity(intentCaptor.capture());
Uri uri = intentCaptor.getValue().getParcelableExtra(AuthenticationActivity.EXTRA_AUTHORIZE_URI);
assertThat(uri, is(notNullValue()));

assertThat(uri, hasParamWithValue("connection_scope", "profile super_scope"));
assertThat(uri, hasParamWithValue("connection_scope", "profile,super_scope"));
}

@Test
public void shouldNotOverrideConnectionScopeValueWithDefaultConnectionScope() throws Exception {
Map<String, Object> parameters = Collections.singletonMap("connection_scope", (Object) "openid email contacts");
Map<String, Object> parameters = Collections.singletonMap("connection_scope", (Object) "openid,email,contacts");
WebAuthProvider.init(account)
.withParameters(parameters)
.start(activity, callback);
Expand All @@ -446,7 +446,7 @@ public void shouldNotOverrideConnectionScopeValueWithDefaultConnectionScope() th
Uri uri = intentCaptor.getValue().getParcelableExtra(AuthenticationActivity.EXTRA_AUTHORIZE_URI);
assertThat(uri, is(notNullValue()));

assertThat(uri, hasParamWithValue("connection_scope", "openid email contacts"));
assertThat(uri, hasParamWithValue("connection_scope", "openid,email,contacts"));
}

@Test
Expand All @@ -459,7 +459,7 @@ public void shouldSetConnectionScope() throws Exception {
Uri uri = intentCaptor.getValue().getParcelableExtra(AuthenticationActivity.EXTRA_AUTHORIZE_URI);
assertThat(uri, is(notNullValue()));

assertThat(uri, hasParamWithValue("connection_scope", "the scope of my connection"));
assertThat(uri, hasParamWithValue("connection_scope", "the,scope,of,my,connection"));
}


Expand Down

0 comments on commit 362915e

Please sign in to comment.