From 9242e2300554be3acd890430c923561b0196f79f Mon Sep 17 00:00:00 2001 From: DatDang Date: Fri, 4 Oct 2024 15:05:55 +0700 Subject: [PATCH] Remove the use of secrets file --- integration_test/base/test_base.dart | 3 --- integration_test/tests/compose/send_email_test.dart | 11 +++++------ .../tests/login/login_with_basic_auth_test.dart | 9 ++++----- .../tests/login/login_with_oidc_test_disabled.dart | 7 +++---- pubspec.yaml | 1 - scripts/integration-tests.sh | 8 +++++++- 6 files changed, 19 insertions(+), 20 deletions(-) diff --git a/integration_test/base/test_base.dart b/integration_test/base/test_base.dart index e5f7287715..ac7229d4c1 100644 --- a/integration_test/base/test_base.dart +++ b/integration_test/base/test_base.dart @@ -1,5 +1,4 @@ import 'package:flutter/foundation.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:tmail_ui_user/main.dart' as app; class TestBase { @@ -10,7 +9,5 @@ class TestBase { FlutterError.onError = (FlutterErrorDetails details) { originalOnError(details); }; - - await dotenv.load(fileName: 'secrets.env', mergeWith: dotenv.env); } } \ No newline at end of file diff --git a/integration_test/tests/compose/send_email_test.dart b/integration_test/tests/compose/send_email_test.dart index e81a4cef0a..8793c47b46 100644 --- a/integration_test/tests/compose/send_email_test.dart +++ b/integration_test/tests/compose/send_email_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:patrol/patrol.dart'; @@ -20,14 +19,14 @@ void main() { await TestBase().runTestApp(); final loginWithBasicAuthScenario = LoginWithBasicAuth($, - username: dotenv.get('USERNAME'), - hostUrl: dotenv.get('BASIC_AUTH_URL'), - email: dotenv.get('BASIC_AUTH_EMAIL'), - password: dotenv.get('PASSWORD'), + username: const String.fromEnvironment('USERNAME'), + hostUrl: const String.fromEnvironment('BASIC_AUTH_URL'), + email: const String.fromEnvironment('BASIC_AUTH_EMAIL'), + password: const String.fromEnvironment('PASSWORD'), ); final sendEmailScenario = SendEmail($, loginWithBasicAuthScenario: loginWithBasicAuthScenario, - additionalRecipient: dotenv.get('ADDITIONAL_MAIL_RECIPIENT'), + additionalRecipient: const String.fromEnvironment('ADDITIONAL_MAIL_RECIPIENT'), subject: 'Test subject', content: 'Test content'); diff --git a/integration_test/tests/login/login_with_basic_auth_test.dart b/integration_test/tests/login/login_with_basic_auth_test.dart index 34103d0fe1..47b1c7a7a8 100644 --- a/integration_test/tests/login/login_with_basic_auth_test.dart +++ b/integration_test/tests/login/login_with_basic_auth_test.dart @@ -1,4 +1,3 @@ -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:patrol/patrol.dart'; @@ -19,10 +18,10 @@ void main() { await TestBase().runTestApp(); final loginWithBasicAuthScenario = LoginWithBasicAuth($, - username: dotenv.get('USERNAME'), - hostUrl: dotenv.get('BASIC_AUTH_URL'), - email: dotenv.get('BASIC_AUTH_EMAIL'), - password: dotenv.get('PASSWORD'), + username: const String.fromEnvironment('USERNAME'), + hostUrl: const String.fromEnvironment('BASIC_AUTH_URL'), + email: const String.fromEnvironment('BASIC_AUTH_EMAIL'), + password: const String.fromEnvironment('PASSWORD'), ); await loginWithBasicAuthScenario.execute(); diff --git a/integration_test/tests/login/login_with_oidc_test_disabled.dart b/integration_test/tests/login/login_with_oidc_test_disabled.dart index a3c22f784c..54a42af162 100644 --- a/integration_test/tests/login/login_with_oidc_test_disabled.dart +++ b/integration_test/tests/login/login_with_oidc_test_disabled.dart @@ -1,4 +1,3 @@ -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:patrol/patrol.dart'; @@ -19,9 +18,9 @@ void main() { await TestBase().runTestApp(); final loginWithOidcScenario = LoginWithOidc($, - email: dotenv.get('USERNAME'), - password: dotenv.get('PASSWORD'), - hostUrl: dotenv.get('HOST_URL')); + email: const String.fromEnvironment('USERNAME'), + password: const String.fromEnvironment('PASSWORD'), + hostUrl: const String.fromEnvironment('HOST_URL')); await loginWithOidcScenario.execute(); }); diff --git a/pubspec.yaml b/pubspec.yaml index 4fae56a2fb..11001a4594 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -303,7 +303,6 @@ flutter: - env.file - configurations/ - configurations/icons/ - - secrets.env # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. diff --git a/scripts/integration-tests.sh b/scripts/integration-tests.sh index 5b403a869f..da76ff3e3f 100755 --- a/scripts/integration-tests.sh +++ b/scripts/integration-tests.sh @@ -1,7 +1,13 @@ #!/usr/bin/env bash dart pub global activate patrol_cli -patrol build android +patrol build android \ + --dart-define=USERNAME=$USERNAME \ + --dart-define=PASSWORD=$PASSWORD \ + --dart-define=HOST_URL=$HOST_URL \ + --dart-define=ADDITIONAL_MAIL_RECIPIENT=$ADDITIONAL_MAIL_RECIPIENT \ + --dart-define=BASIC_AUTH_EMAIL=$BASIC_AUTH_EMAIL \ + --dart-define=BASIC_AUTH_URL=$BASIC_AUTH_URL gcloud firebase test android run \ --type instrumentation \ --app build/app/outputs/apk/debug/app-debug.apk \