diff --git a/package.json b/package.json index a480bca09ff..f35f9435a47 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "tests:packager:jet-reset-cache": "cd tests && cross-env REACT_DEBUGGER=\"echo nope\" node_modules/.bin/react-native start --reset-cache --no-interactive", "tests:emulator:start": "cd ./.github/workflows/scripts && ./start-firebase-emulator.sh --no-daemon", "tests:emulator:start-ci": "cd ./.github/workflows/scripts && ./start-firebase-emulator.sh", - "tests:android:build": "cd tests && yarn detox build --configuration android.emu.debug", + "tests:android:build": "cd tests && FIREBASE_APP_CHECK_DEBUG_TOKEN=\"698956B2-187B-49C6-9E25-C3F3530EEBAF\" yarn detox build --configuration android.emu.debug", "tests:android:build-release": "cd tests && yarn detox build --configuration android.emu.release", "tests:android:test": "cd tests && yarn detox test --configuration android.emu.debug", "tests:android:test:debug": "cd tests && yarn detox test --configuration android.emu.debug --inspect", diff --git a/packages/app-check/e2e/appcheck.e2e.js b/packages/app-check/e2e/appcheck.e2e.js index 54894f37fbe..2880d2c4138 100644 --- a/packages/app-check/e2e/appcheck.e2e.js +++ b/packages/app-check/e2e/appcheck.e2e.js @@ -42,6 +42,7 @@ describe('appCheck()', function () { }); describe('getToken())', function () { it('token fetch attempt should work', async function () { + await firebase.appCheck().activate('ignored', false); // Our tests configure a debug provider with shared secret so we should get a valid token const { token } = await firebase.appCheck().getToken(); token.should.not.equal(''); @@ -71,23 +72,5 @@ describe('appCheck()', function () { return Promise.reject(e); } }); - // Dynamic providers are not possible on iOS, so the debug provider is always working - it('token fetch attempt should work but fail attestation', async function () { - if (device.getPlatform() === 'android') { - try { - // Activating on Android clobbers the shared secret in the debug provider shared secret, should fail now - await firebase.appCheck().getToken(true); - return Promise.reject( - 'Should have thrown after resetting shared secret on debug provider', - ); - } catch (e) { - e.message.should.containEql('[appCheck/token-error]'); - e.message.should.containEql('App attestation failed'); - return Promise.resolve(); - } - } else { - this.skip(); - } - }); }); }); diff --git a/tests/android/app/src/androidTest/java/com/invertase/testing/DetoxTest.java b/tests/android/app/src/androidTest/java/com/invertase/testing/DetoxTest.java index 9542b6fec19..1d3bcbf96a7 100644 --- a/tests/android/app/src/androidTest/java/com/invertase/testing/DetoxTest.java +++ b/tests/android/app/src/androidTest/java/com/invertase/testing/DetoxTest.java @@ -28,40 +28,8 @@ public class DetoxTest { @Test public void runDetoxTests() { - - try { - // 1) Detox makes it extremely difficult to pass unencoded arguments directly to the instrumentation runner on Android: - // https://github.com/wix/Detox/issues/2933 - // - // 2) AppCheck will only let you set a debug AppCheck token in CI via their test helpers via instrumentation runner args - // https://firebase.google.com/docs/app-check/android/debug-provider#ci - // - // Here we avoid the Detox argument-passing / AppCheck argument-reading difficulty by directly putting the String in. - // - // This is unwanted in nearly all scenarios as it leaks an AppCheck token, but the react-native-firebase test - // project does not have AppCheck set to enforcing, so this is okay for this project. - // - // This has a great potential for leaking your token in a real app that wants to enforce and rely on AppCheck. - Class testHelperClass = DebugAppCheckTestHelper.class; - Method[] methods = testHelperClass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals("fromString")) { - Method testHelperMethod = methods[i]; - testHelperMethod.setAccessible(true); - DebugAppCheckTestHelper debugAppCheckTestHelper = - (DebugAppCheckTestHelper)testHelperMethod.invoke(null, "698956B2-187B-49C6-9E25-C3F3530EEBAF"); - debugAppCheckTestHelper.withDebugProvider(() -> { - - // This is the standard Detox androidTest implementation: - Detox.runTests(mActivityRule); - - dumpCoverageData(); - }); - } - } - } catch (Exception e) { - throw new RuntimeException("Unable to force AppCheck debug token: ", e); - } + Detox.runTests(mActivityRule); + dumpCoverageData(); } // If you send '-e coverage' as part of the instrumentation command line, it should dump coverage as the Instrumentation finishes. diff --git a/tests/e2e/.mocharc.js b/tests/e2e/.mocharc.js index 8ef68ce7522..a914e4a597d 100644 --- a/tests/e2e/.mocharc.js +++ b/tests/e2e/.mocharc.js @@ -11,22 +11,22 @@ module.exports = { recursive: true, require: 'node_modules/jet/platform/node', spec: [ - '../packages/app/e2e/**/*.e2e.js', + // '../packages/app/e2e/**/*.e2e.js', '../packages/app-check/e2e/**/*.e2e.js', - '../packages/app-distribution/e2e/**/*.e2e.js', - '../packages/analytics/e2e/**/*.e2e.js', - '../packages/auth/e2e/**/*.e2e.js', - '../packages/crashlytics/e2e/**/*.e2e.js', - '../packages/database/e2e/**/*.e2e.js', - '../packages/dynamic-links/e2e/**/*.e2e.js', - '../packages/firestore/e2e/**/*.e2e.js', - '../packages/functions/e2e/**/*.e2e.js', - '../packages/perf/e2e/**/*.e2e.js', - '../packages/messaging/e2e/**/*.e2e.js', - '../packages/ml/e2e/**/*.e2e.js', - '../packages/in-app-messaging/e2e/**/*.e2e.js', - '../packages/installations/e2e/**/*.e2e.js', - '../packages/remote-config/e2e/**/*.e2e.js', - '../packages/storage/e2e/**/*.e2e.js', + // '../packages/app-distribution/e2e/**/*.e2e.js', + // '../packages/analytics/e2e/**/*.e2e.js', + // '../packages/auth/e2e/**/*.e2e.js', + // '../packages/crashlytics/e2e/**/*.e2e.js', + // '../packages/database/e2e/**/*.e2e.js', + // '../packages/dynamic-links/e2e/**/*.e2e.js', + // '../packages/firestore/e2e/**/*.e2e.js', + // '../packages/functions/e2e/**/*.e2e.js', + // '../packages/perf/e2e/**/*.e2e.js', + // '../packages/messaging/e2e/**/*.e2e.js', + // '../packages/ml/e2e/**/*.e2e.js', + // '../packages/in-app-messaging/e2e/**/*.e2e.js', + // '../packages/installations/e2e/**/*.e2e.js', + // '../packages/remote-config/e2e/**/*.e2e.js', + // '../packages/storage/e2e/**/*.e2e.js', ], };