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
6 changes: 6 additions & 0 deletions src/plugin/__tests__/__snapshots__/withAuth0-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ exports[`addAndroidAuth0Manifest with multiple domains and schemes should have t
{
"$": {
"android:host": "sample.us.auth0.com",
"android:pathPrefix": "/android/com.sample.application/callback",
"android:scheme": "com.sample.us.auth0",
},
},
{
"$": {
"android:host": "sample.eu.auth0.com",
"android:pathPrefix": "/android/com.sample.application/callback",
"android:scheme": "com.sample.eu.auth0",
},
},
Expand Down Expand Up @@ -138,12 +140,14 @@ exports[`addAndroidAuth0Manifest with multiple domains should have that value an
{
"$": {
"android:host": "sample.us.auth0.com",
"android:pathPrefix": "/android/com.sample.application/callback",
"android:scheme": "com.sample.application.auth0",
},
},
{
"$": {
"android:host": "sample.eu.auth0.com",
"android:pathPrefix": "/android/com.sample.application/callback",
"android:scheme": "com.sample.application.auth0",
},
},
Expand Down Expand Up @@ -216,6 +220,7 @@ exports[`addAndroidAuth0Manifest with scheme should have that value 1`] = `
{
"$": {
"android:host": "sample.auth0.com",
"android:pathPrefix": "/android/undefined/callback",
"android:scheme": "com.sample.application",
},
},
Expand Down Expand Up @@ -288,6 +293,7 @@ exports[`addAndroidAuth0Manifest without scheme should have package name 1`] = `
{
"$": {
"android:host": "sample.auth0.com",
"android:pathPrefix": "/android/com.auth0.sample/callback",
"android:scheme": "com.auth0.sample.auth0",
},
},
Expand Down
63 changes: 63 additions & 0 deletions src/plugin/__tests__/withAuth0-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,69 @@ describe(addAndroidAuth0Manifest, () => {
}
expect(check()).toMatchSnapshot();
});

it(`should correctly add pathPrefix to Android manifest with application ID`, () => {
const config = getConfig();
const result = addAndroidAuth0Manifest(
[{ domain: 'sample.auth0.com' }],
config,
'com.auth0.testapp'
);

// Access the RedirectActivity to check if the pathPrefix is correctly added
const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(
result.modResults
);
const redirectActivity = mainApplication.activity?.find(
(activity) =>
activity.$['android:name'] ===
'com.auth0.android.provider.RedirectActivity'
);

const intentFilter = redirectActivity?.['intent-filter']?.[0];
const dataElement = intentFilter?.data?.[0];

expect(dataElement).toBeDefined();
expect(dataElement?.$['android:pathPrefix']).toBe(
'/android/com.auth0.testapp/callback'
);
expect(dataElement?.$['android:scheme']).toBe('com.auth0.testapp.auth0');
expect(dataElement?.$['android:host']).toBe('sample.auth0.com');
});

it(`should correctly add pathPrefix to Android manifest with custom scheme`, () => {
const config = getConfig();
const result = addAndroidAuth0Manifest(
[
{
domain: 'sample.auth0.com',
customScheme: 'com.custom.scheme',
},
],
config,
'com.auth0.testapp'
);

// Access the RedirectActivity to check if the pathPrefix is correctly added
const mainApplication = AndroidConfig.Manifest.getMainApplicationOrThrow(
result.modResults
);
const redirectActivity = mainApplication.activity?.find(
(activity) =>
activity.$['android:name'] ===
'com.auth0.android.provider.RedirectActivity'
);

const intentFilter = redirectActivity?.['intent-filter']?.[0];
const dataElement = intentFilter?.data?.[0];

expect(dataElement).toBeDefined();
expect(dataElement?.$['android:pathPrefix']).toBe(
'/android/com.auth0.testapp/callback'
);
expect(dataElement?.$['android:scheme']).toBe('com.custom.scheme');
expect(dataElement?.$['android:host']).toBe('sample.auth0.com');
});
});

describe(addIOSAuth0ConfigInInfoPList, () => {
Expand Down
1 change: 1 addition & 0 deletions src/plugin/withAuth0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const addAndroidAuth0Manifest = (
const dataElement = {
$: {
'android:scheme': auth0Scheme,
'android:pathPrefix': `/android/${applicationId}/callback`,
'android:host': config.domain,
},
};
Expand Down