Skip to content
Closed
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
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Alex Chau <alexchau@google.com>
Benjamin Franz <bfranz@google.com>
Rebecka Gulliksson <rebecka.gulliksson@gmail.com>
Rahul Ravikumar <rahulrav@google.com>
Henning Nielsen Lund <henning.n.lund@jp.dk>
9 changes: 9 additions & 0 deletions library/java/net/openid/appauth/AuthorizationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ public CustomTabsIntent.Builder createCustomTabsIntentBuilder(Uri... possibleUri
return mCustomTabManager.createTabBuilder(possibleUris);
}

/**
* Creates a CustomTabsIntent, where the package is set to the one of the BrowserDescriptor.
*/
public CustomTabsIntent createCustomTabsIntent(Uri... possibleUris) {
CustomTabsIntent customTabsIntent = createCustomTabsIntentBuilder(possibleUris).build();
customTabsIntent.intent.setPackage(mBrowser.packageName);
return customTabsIntent;
}

/**
* Sends an authorization request to the authorization service, using a
* [custom tab](https://developer.chrome.com/multidevice/android/customtabs)
Expand Down
31 changes: 31 additions & 0 deletions library/javatests/net/openid/appauth/AuthorizationServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import net.openid.appauth.AppAuthConfiguration.Builder;
import net.openid.appauth.AuthorizationException.GeneralErrors;
import net.openid.appauth.browser.BrowserDescriptor;
import net.openid.appauth.browser.Browsers;
import net.openid.appauth.browser.CustomTabManager;
import net.openid.appauth.connectivity.ConnectionBuilder;
Expand Down Expand Up @@ -220,6 +221,36 @@ public void testGetAuthorizationRequestIntent_withCustomTabs_preservesTabSetting
.isEqualTo(CustomTabsIntent.SHOW_PAGE_TITLE);
}

@Test
public void testCreateCustomTabsIntent_Chrome() {
BrowserDescriptor browser = Browsers.Chrome.customTab("46");
mService = new AuthorizationService(
mContext,
new Builder()
.setConnectionBuilder(mConnectionBuilder)
.build(),
browser,
mCustomTabManager);
CustomTabsIntent customTabsIntent = mService.createCustomTabsIntent();
assertNotNull(customTabsIntent.intent.getPackage());
assertTrue(customTabsIntent.intent.getPackage().equals(browser.packageName));
}

@Test
public void testCreateCustomTabsIntent_Samsung() {
BrowserDescriptor browser = Browsers.SBrowser.customTab("7.2.10.33");
mService = new AuthorizationService(
mContext,
new Builder()
.setConnectionBuilder(mConnectionBuilder)
.build(),
browser,
mCustomTabManager);
CustomTabsIntent customTabsIntent = mService.createCustomTabsIntent();
assertNotNull(customTabsIntent.intent.getPackage());
assertTrue(customTabsIntent.intent.getPackage().equals(browser.packageName));
}

@Test
public void testTokenRequest() throws Exception {
InputStream is = new ByteArrayInputStream(AUTH_CODE_EXCHANGE_RESPONSE_JSON.getBytes());
Expand Down