diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-05-21 11:57:51 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-05-21 11:57:51 +0200 |
| commit | b708e86feb1235a6241cd12e1b8315cea19a12d5 (patch) | |
| tree | 3946e8dc8792199eab45e6fee3d31775aa773fb8 | |
| parent | ee8c0578c5d7f330b40272cdec1ee62af2c5fd20 (diff) | |
| parent | f2b6a3d2d04d33e106b794ae489d506651f41f91 (diff) | |
| download | mullvadvpn-b708e86feb1235a6241cd12e1b8315cea19a12d5.tar.xz mullvadvpn-b708e86feb1235a6241cd12e1b8315cea19a12d5.zip | |
Merge branch 'rework-localproperties-and-e2eproperties-droid-1430'
24 files changed, 229 insertions, 184 deletions
diff --git a/.github/workflows/android-app.yml b/.github/workflows/android-app.yml index caf8a9e700..5896844b3a 100644 --- a/.github/workflows/android-app.yml +++ b/.github/workflows/android-app.yml @@ -488,7 +488,10 @@ jobs: VALID_TEST_ACCOUNT_NUMBER: ${{ env.RESOLVED_TEST_ACCOUNT }} INVALID_TEST_ACCOUNT_NUMBER: '0000000000000000' ENABLE_HIGHLY_RATE_LIMITED_TESTS: ${{ github.event_name == 'schedule' && 'true' || 'false' }} - ENABLE_ACCESS_TO_LOCAL_API_TESTS: true + ENABLE_RAAS_TESTS: true + RAAS_HOST: '192.168.105.1' + RAAS_TRAFFIC_GENERATOR_TARGET_HOST: '45.83.223.209' + RAAS_TRAFFIC_GENERATOR_TARGET_PORT: '80' REPORT_DIR: ${{ steps.prepare-report-dir.outputs.report_dir }} run: ./android/scripts/run-instrumented-tests-repeat.sh ${{ needs.prepare.outputs.E2E_TEST_REPEAT }} @@ -513,7 +516,7 @@ jobs: invalid_test_account_number=0000000000000000,\ ENABLE_HIGHLY_RATE_LIMITED_TESTS=${{ github.event_name == 'schedule' && 'true' || 'false' }},\ partner_auth=${{ secrets.STAGEMOLE_PARTNER_AUTH }},\ - ENABLE_ACCESS_TO_LOCAL_API_TESTS=false" + ENABLE_RAAS_TESTS=false" strategy: fail-fast: false matrix: diff --git a/android/BuildInstructions.md b/android/BuildInstructions.md index da38741f40..161685fa89 100644 --- a/android/BuildInstructions.md +++ b/android/BuildInstructions.md @@ -207,7 +207,7 @@ in the following way: 1. Run update script: ```bash - ./scripts/update-lockfile.sh + ./scripts/lockfile -u ``` If you're on macOS make sure GNU sed is installed. Install with `brew install gnu-sed` and add it to your `PATH` so that it is used instead of the `sed` macOS ships with `PATH="$HOMEBREW_PREFIX/opt/gnu-sed/libexec/gnubin:$PATH"` @@ -221,25 +221,30 @@ rm ./gradle/verification-metadata.xml ``` ## Gradle properties -Some gradle properties can be set to simplify development. These are listed below. +Some gradle properties can be set to simplify development, for the full list see `android/gradle.properties`. +In order to override them, add the properties in `<USER_GRADLE_HOME>/gradle.properties`. See the +[gradle documentation](https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties) +for more info of the prioritization of properties. ### Override version code and version name -To avoid or override the rust based version generation, the `OVERRIDE_VERSION_CODE` and -`OVERRIDE_VERSION_NAME` properties can be set in `local.properties`. For example: +To avoid or override the rust based version generation, the `mullvad.app.config.override.versionCode` and +`mullvad.app.config.override.versionName` properties can be set: ``` -OVERRIDE_VERSION_CODE=123 -OVERRIDE_VERSION_NAME=1.2.3 +mullvad.app.config.override.versionCode=123 +mullvad.app.config.override.versionName=1.2.3 ``` ### Disable version in-app notifications To disable in-app notifications related to the app version during development or testing, -the `ENABLE_IN_APP_VERSION_NOTIFICATIONS` property can be set in `local.properties`: +the `mullvad.app.config.inAppVersionNotifications.enable` property can be set: ``` -ENABLE_IN_APP_VERSION_NOTIFICATIONS=false +mullvad.app.config.inAppVersionNotifications.enable=false ``` ### Run tests highly affected by rate limiting -To avoid being rate limited we avoid running tests sending requests that are highly rate limited too often. If you want to run these tests you can set `enable_highly_rate_limited_tests=true` in `local.properties`. The default value is `false`. +To avoid being rate limited we avoid running tests sending requests that are highly rate limited +too often. If you want to run these tests you can override the +`mullvad.test.e2e.config.runHighlyRateLimitedTests` gradle properties. The default value is `false`. ## Reproducible builds @@ -249,7 +254,7 @@ The Mullvad Android app is by default reproducible when built using our build co When building without the container on Linux systems, reproducibility depends on having the exact same versions of system tools (compilers, build tools, etc) installed. Small differences in tool versions or configurations can lead to different build outputs even when using the same source code. -> **Make sure that the `local.properties` file has not changed keys that affect the reproducibility of the build such as `CARGO_TARGETS` and `ENABLE_IN_APP_VERSION_NOTIFICATIONS`.** +> **Make sure that any `gradle.properties` has not changed or been overridden it will affect the reproducibility of the build such as changing `mullvad.app.build.cargo.targets` and `mullvad.app.config.inAppVersionNotifications.enable`.** To maximize reproducibility when building without the container: diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index d40b7bd8b2..9571b9819a 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -1,4 +1,3 @@ -import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import com.android.build.gradle.internal.tasks.factory.dependsOn import com.github.triplet.gradle.androidpublisher.ReleaseStatus import java.io.FileInputStream @@ -20,7 +19,7 @@ plugins { val repoRootPath = rootProject.projectDir.absoluteFile.parentFile.absolutePath val relayListDirectory = file("$repoRootPath/dist-assets/relays/").absolutePath -val defaultChangelogAssetsDirectory = "$repoRootPath/android/src/main/play/release-notes/" +val changelogAssetsDirectory = "$repoRootPath/android/src/main/play/release-notes/" val rustJniLibsDir = layout.buildDirectory.dir("rustJniLibs/android").get() val credentialsPath = "${rootProject.projectDir}/credentials" @@ -38,13 +37,11 @@ android { ndkVersion = Versions.ndkVersion defaultConfig { - val localProperties = gradleLocalProperties(rootProject.projectDir, providers) - applicationId = "net.mullvad.mullvadvpn" minSdk = Versions.minSdkVersion targetSdk = Versions.targetSdkVersion - versionCode = generateVersionCode(localProperties) - versionName = generateVersionName(localProperties) + versionCode = generateVersionCode() + versionName = generateVersionName() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" lint { @@ -89,11 +86,7 @@ android { ) } getByName(BuildTypes.DEBUG) { - if ( - gradleLocalProperties(rootProject.projectDir, providers) - .getProperty("KEEP_DEBUG_SYMBOLS") - .toBoolean() - ) { + if (getBooleanProperty("mullvad.app.build.keepDebugSymbols")) { packaging { jniLibs.keepDebugSymbols.add("**/*.so") } } } @@ -133,13 +126,7 @@ android { } sourceSets { - getByName("main") { - val changelogDir = - gradleLocalProperties(rootProject.projectDir, providers) - .getOrDefault("OVERRIDE_CHANGELOG_DIR", defaultChangelogAssetsDirectory) - - assets.srcDirs(relayListDirectory, changelogDir) - } + getByName("main") { assets.srcDirs(relayListDirectory, changelogAssetsDirectory) } } buildFeatures { @@ -194,14 +181,10 @@ android { } applicationVariants.configureEach { - val enableInAppVersionNotifications = - gradleLocalProperties(rootProject.projectDir, providers) - .getProperty("ENABLE_IN_APP_VERSION_NOTIFICATIONS") ?: "true" - buildConfigField( "boolean", "ENABLE_IN_APP_VERSION_NOTIFICATIONS", - enableInAppVersionNotifications, + getBooleanProperty("mullvad.app.config.inAppVersionNotifications.enable").toString(), ) } @@ -267,18 +250,13 @@ junitPlatform { } cargo { - val localProperties = gradleLocalProperties(rootProject.projectDir, providers) val isReleaseBuild = isReleaseBuild() - val enableApiOverride = - !isReleaseBuild || isDevBuild(localProperties) || isAlphaBuild(localProperties) + val enableApiOverride = !isReleaseBuild || isDevBuild() || isAlphaBuild() module = repoRootPath libname = "mullvad-jni" // All available targets: // https://github.com/mozilla/rust-android-gradle/tree/master?tab=readme-ov-file#targets - targets = - gradleLocalProperties(rootProject.projectDir, providers) - .getProperty("CARGO_TARGETS") - ?.split(",") ?: listOf("arm", "arm64", "x86", "x86_64") + targets = getStringListProperty("mullvad.app.build.cargo.targets") profile = if (isReleaseBuild) { "release" @@ -305,11 +283,7 @@ tasks.register<Exec>("cargoClean") { commandLine("cargo", "clean") } -if ( - gradleLocalProperties(rootProject.projectDir, providers) - .getProperty("CLEAN_CARGO_BUILD") - ?.toBoolean() != false -) { +if (getBooleanProperty("mullvad.app.build.cargo.cleanBuild")) { tasks["clean"].dependsOn("cargoClean") } diff --git a/android/build.sh b/android/build.sh index 05337e21ac..3e63a4ce55 100755 --- a/android/build.sh +++ b/android/build.sh @@ -17,7 +17,6 @@ BUILD_BUNDLE="no" BUNDLE_TASKS=(createPlayProdReleaseDistBundle) RUN_PLAY_PUBLISH_TASKS="no" PLAY_PUBLISH_TASKS=() -LOCAL_PROPERTIES_FILE="local.properties" while [ -n "${1:-""}" ]; do if [[ "${1:-""}" == "--dev-build" ]]; then @@ -90,8 +89,4 @@ echo "" echo " Build checksums:" md5sum ../dist/MullvadVPN-"$PRODUCT_VERSION"* | sed 's/^/ /' echo "" -if [[ -f "$LOCAL_PROPERTIES_FILE" ]] && grep -q "^CARGO_TARGETS=" "$LOCAL_PROPERTIES_FILE"; then - echo " CARGO_TARGETS is set in $LOCAL_PROPERTIES_FILE, build may not be reproducible!" -fi -echo "" echo "**********************************" diff --git a/android/buildSrc/src/main/kotlin/Utils.kt b/android/buildSrc/src/main/kotlin/Utils.kt index b442ad453a..d939363827 100644 --- a/android/buildSrc/src/main/kotlin/Utils.kt +++ b/android/buildSrc/src/main/kotlin/Utils.kt @@ -8,24 +8,22 @@ fun Project.isReleaseBuild() = it.contains("release", ignoreCase = true) || it.contains("fdroid", ignoreCase = true) } -fun Project.isAlphaBuild(localProperties: Properties): Boolean { - val versionName = generateVersionName(localProperties) +fun Project.isAlphaBuild(): Boolean { + val versionName = generateVersionName() return versionName.contains("alpha") } -fun Project.isDevBuild(localProperties: Properties): Boolean { - val versionName = generateVersionName(localProperties) +fun Project.isDevBuild(): Boolean { + val versionName = generateVersionName() return versionName.contains("-dev-") } -fun Project.generateVersionCode(localProperties: Properties): Int { - return localProperties.getProperty("OVERRIDE_VERSION_CODE")?.toIntOrNull() - ?: execVersionCodeCargoCommand() -} +fun Project.generateVersionCode(): Int = + getIntPropertyOrNull("mullvad.app.config.override.versionCode") ?: execVersionCodeCargoCommand() -fun Project.generateVersionName(localProperties: Properties): String { - return localProperties.getProperty("OVERRIDE_VERSION_NAME") ?: execVersionNameCargoCommand() -} +fun Project.generateVersionName(): String = + getStringPropertyOrNull("mullvad.app.config.override.versionName") + ?: execVersionNameCargoCommand() fun Project.generateRemapArguments(): String { val script = "${projectDir.parent}/../building/rustc-remap-path-prefix.sh" @@ -48,3 +46,23 @@ private fun Project.execVersionNameCargoCommand() = .asText .get() .trim() + +fun Project.getStringPropertyOrNull(name: String): String? = findProperty(name)?.toString() + +fun Project.getIntPropertyOrNull(name: String): Int? = findProperty(name)?.toString()?.toInt() + +fun Project.getBooleanPropertyOrNull(name: String): Boolean? = + findProperty(name)?.toString()?.toBooleanStrict() + +fun Project.getStringProperty(name: String): String = properties[name].toString() + +fun Project.getIntProperty(name: String): Int = properties[name].toString().toInt() + +fun Project.getBooleanProperty(name: String): Boolean = + properties[name].toString().toBooleanStrict() + +// Fetch a string and that is split by `,` into a list of strings +const val STRING_LIST_SEPARATOR = ',' + +fun Project.getStringListProperty(name: String): List<String> = + properties[name].toString().split(STRING_LIST_SEPARATOR) diff --git a/android/gradle.properties b/android/gradle.properties index 2170a22f34..865475dd75 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,15 +1,67 @@ -# Android properties +### Android properties ### android.enableR8.fullMode=true android.nonTransitiveRClass=false android.useAndroidX=true -# Kotlin properties + +### Kotlin properties ### kotlin.code.style=official -# Gradle properties + +### Gradle properties ### org.gradle.caching=true org.gradle.jvmargs=-Xmx8192M -Dkotlin.daemon.jvm.options\="-Xmx8192M" -# Mullvad properties -test.e2e.enableAccessToLocalApiTests=false +### Mullvad properties ### + +# Show in app version notifications +mullvad.app.config.inAppVersionNotifications.enable=true + +# Optional property to override the version name and code +# app.config.override.versionName= +# app.config.override.versionCode= + +# Targets to build the daemon for +mullvad.app.build.cargo.targets=arm,arm64,x86,x86_64 + +# Perform a clean the cargo before each build +mullvad.app.build.cargo.cleanBuild=true + +# Keep debug symbols in debug builds, this will cause the debug artifacts +# to be substantially larger. +mullvad.app.build.keepDebugSymbols=false + +## E2E tests ## + +# To run e2e tests you need to provide credentails for the enviroment you +# are targeting. Either provide a partnerAuth that will automatically create +# accounts as needed or provide already valid credentaisl + +#mullvad.test.e2e.prod.partnerAuth= +# OR +#mullvad.test.e2e.stagemole.accountNumber.valid= +#mullvad.test.e2e.stagemole.accountNumber.invalid=1234123412341234 + +#mullvad.test.e2e.stagemole.partnerAuth= +# OR +#mullvad.test.e2e.prod.accountNumber.valid= +#mullvad.test.e2e.prod.accountNumber.invalid=1234123412341234 + + +# Run the highly rate limited tests, these will make the test run go for longer +# since it will have to be careful not to trigger the rate limiting. +mullvad.test.e2e.config.runHighlyRateLimitedTests=false + +# Whether to enable tests dependent on RAAS (Router As A Service), if enabled +# you need to provide the rest of the `test.e2e.config.raas.*` properties. +mullvad.test.e2e.config.raas.enable=false +# +# IP to the machine running RAAS +#mullvad.test.e2e.config.raas.host= +# +# IP address or host to send traffic to +#mullvad.test.e2e.config.raas.trafficGenerator.target.host= +# +# Port 1-65532 +#mullvad.test.e2e.config.raas.trafficGenerator.target.port= diff --git a/android/scripts/run-instrumented-tests.sh b/android/scripts/run-instrumented-tests.sh index 7606a2c634..96d8dc8eb6 100755 --- a/android/scripts/run-instrumented-tests.sh +++ b/android/scripts/run-instrumented-tests.sh @@ -17,7 +17,10 @@ PARTNER_AUTH="${PARTNER_AUTH:-}" VALID_TEST_ACCOUNT_NUMBER="${VALID_TEST_ACCOUNT_NUMBER:-}" INVALID_TEST_ACCOUNT_NUMBER="${INVALID_TEST_ACCOUNT_NUMBER:-}" ENABLE_HIGHLY_RATE_LIMITED_TESTS="${ENABLE_HIGHLY_RATE_LIMITED_TESTS:-false}" -ENABLE_ACCESS_TO_LOCAL_API_TESTS="${ENABLE_ACCESS_TO_LOCAL_API_TESTS:-false}" +ENABLE_RAAS_TESTS="${ENABLE_RAAS_TESTS:-false}" +RAAS_HOST="${RAAS_HOST:-}" +RAAS_TRAFFIC_GENERATOR_TARGET_HOST="${RAAS_TRAFFIC_GENERATOR_TARGET_HOST:-}" +RAAS_TRAFFIC_GENERATOR_TARGET_PORT="${RAAS_TRAFFIC_GENERATOR_TARGET_PORT:-}" REPORT_DIR="${REPORT_DIR:-}" while [[ "$#" -gt 0 ]]; do @@ -114,26 +117,35 @@ case "$TEST_TYPE" in echo "Error: The 'e2e' test type with billing flavor 'oss' require infra flavor 'prod'." exit 1 fi + OPTIONAL_TEST_ARGUMENTS="" if [[ -n ${INVALID_TEST_ACCOUNT_NUMBER-} ]]; then - OPTIONAL_TEST_ARGUMENTS+=" -e invalid_test_account_number $INVALID_TEST_ACCOUNT_NUMBER" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.$INFRA_FLAVOR.accountNumber.invalid $INVALID_TEST_ACCOUNT_NUMBER" else echo "Error: The variable INVALID_TEST_ACCOUNT_NUMBER must be set." exit 1 fi if [[ -n ${PARTNER_AUTH} ]]; then echo "Test account used for e2e test (provided/partner): partner" - OPTIONAL_TEST_ARGUMENTS+=" -e partner_auth $PARTNER_AUTH" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.$INFRA_FLAVOR.partnerAuth $PARTNER_AUTH" elif [[ -n ${VALID_TEST_ACCOUNT_NUMBER} ]]; then echo "Test account used for e2e test (provided/partner): provided" - OPTIONAL_TEST_ARGUMENTS+=" -e valid_test_account_number $VALID_TEST_ACCOUNT_NUMBER" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.$INFRA_FLAVOR.accountNumber.valid $VALID_TEST_ACCOUNT_NUMBER" else echo "" echo "Error: The variable PARTNER_AUTH or VALID_TEST_ACCOUNT_NUMBER must be set." exit 1 fi - OPTIONAL_TEST_ARGUMENTS+=" -e enable_access_to_local_api_tests $ENABLE_ACCESS_TO_LOCAL_API_TESTS" - OPTIONAL_TEST_ARGUMENTS+=" -e enable_highly_rate_limited_tests $ENABLE_HIGHLY_RATE_LIMITED_TESTS" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.config.raas.enable $ENABLE_RAAS_TESTS" + + if [[ -n ${ENABLE_RAAS_TESTS} ]]; then + echo "Tests dependent on local API enabled" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.config.raas.host $RAAS_HOST" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.config.raas.trafficGenerator.target.host $RAAS_TRAFFIC_GENERATOR_TARGET_HOST" + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.config.raas.trafficGenerator.target.port $RAAS_TRAFFIC_GENERATOR_TARGET_PORT" + fi + + OPTIONAL_TEST_ARGUMENTS+=" -e mullvad.test.e2e.config.runHighlyRateLimitedTests $ENABLE_HIGHLY_RATE_LIMITED_TESTS" USE_ORCHESTRATOR="true" PACKAGE_NAME="net.mullvad.mullvadvpn" if [[ "$INFRA_FLAVOR" =~ ^(devmole|stagemole)$ ]]; then @@ -150,8 +162,6 @@ if [[ -z $REPORT_DIR || ! -d $REPORT_DIR ]]; then exit 1 fi -GRADLE_ENVIRONMENT_VARIABLES="TEST_E2E_ENABLEACCESSTOLOCALAPITESTS=$ENABLE_ACCESS_TO_LOCAL_API_TESTS" - INSTRUMENTATION_LOG_FILE_PATH="$REPORT_DIR/instrumentation-log.txt" LOGCAT_FILE_PATH="$REPORT_DIR/logcat.txt" LOCAL_SCREENSHOT_PATH="$REPORT_DIR/screenshots" @@ -229,7 +239,7 @@ else -e runnerBuilder de.mannodermaus.junit5.AndroidJUnit5Builder \ $TEST_PACKAGE_NAME/androidx.test.runner.AndroidJUnitRunner" fi -adb shell "$GRADLE_ENVIRONMENT_VARIABLES $INSTRUMENTATION_COMMAND" | tee "$INSTRUMENTATION_LOG_FILE_PATH" +adb shell "$INSTRUMENTATION_COMMAND" | tee "$INSTRUMENTATION_LOG_FILE_PATH" echo "" echo "### Stop logging ###" diff --git a/android/service/build.gradle.kts b/android/service/build.gradle.kts index 7fd560aa43..4fd794c765 100644 --- a/android/service/build.gradle.kts +++ b/android/service/build.gradle.kts @@ -1,5 +1,3 @@ -import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties - plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) @@ -13,8 +11,7 @@ android { defaultConfig { minSdk = Versions.minSdkVersion - val localProperties = gradleLocalProperties(rootProject.projectDir, providers) - val shouldRequireBundleRelayFile = isReleaseBuild() && !isDevBuild(localProperties) + val shouldRequireBundleRelayFile = isReleaseBuild() && !isDevBuild() buildConfigField( "Boolean", "REQUIRE_BUNDLED_RELAY_FILE", diff --git a/android/test/e2e/README.md b/android/test/e2e/README.md index adbcc042cd..58f6206c87 100644 --- a/android/test/e2e/README.md +++ b/android/test/e2e/README.md @@ -4,17 +4,14 @@ The tests in this module are end-to-end tests that rely on the publicly accessib ## How to run the tests ### Locally -Set account numbers in the below command and then execute the command in the `android` directory to run the tests on a local device: -``` -./gradlew :test:e2e:connectedDebugAndroidTest \ - -Pvalid_test_account_number=XXXX \ - -Pinvalid_test_account_number=XXXX -``` -For convenience, the numbers can also be set in `<REPO-ROOT>/android/local.properties` in the following way: +Configure all the `mullvad.test.e2e.xxxx` properties located in `android/gradle.properties` by adding them into your `<GRADLE_USER_HOME>/gradle.properties`. + +You can also set these properties or override them when executing the command in the following way: ``` -valid_test_account_number=XXXX -invalid_test_account_number=XXXX +./gradlew :test:e2e:connectedDebugAndroidTest \ + -Pmullvad.test.e2e.prod.accountNumber.valid=XXXX \ + -Pmullvad.test.e2e.prod.accountNumber.invalid==XXXX ``` It's also possible to provide the numbers to the test runner during test execution. However note that this requires [the APKs to be installed manually](https://developer.android.com/training/testing/instrumented-tests/androidx-test-libraries/runner#architecture). @@ -22,14 +19,12 @@ It's also possible to provide the numbers to the test runner during test executi adb shell 'CLASSPATH=$(pm path androidx.test.services) app_process / \ androidx.test.services.shellexecutor.ShellMain am instrument -w \ -e clearPackageData true \ - -e valid_test_account_number XXXX \ - -e invalid_test_account_number XXXX \ + -e mullvad.test.e2e.prod.accountNumber.valid XXXX \ + -e mullvad.test.e2e.prod.accountNumber.invalid XXXX \ -e targetInstrumentation net.mullvad.mullvadvpn.test.e2e/androidx.test.runner.AndroidJUnitRunner \ androidx.test.orchestrator/.AndroidTestOrchestrator' ``` -If you want to run tests that make use of APIs hosted at Mullvad HQ you need to set `ENABLE_ACCESS_TO_LOCAL_API_TESTS=true` in `e2e.properties` or pass it as a command line argument when launching tests. - ### Firebase Test Lab Firebase Test Lab can be used to run the tests on vast collection of physical and virtual devices. @@ -43,7 +38,7 @@ gcloud firebase test android run \ --test ./android/test/e2e/build/outputs/apk/debug/e2e-debug.apk \ --device model=redfin,version=30,locale=en,orientation=portrait \ --use-orchestrator \ - --environment-variables clearPackageData=true,valid_test_account_number=XXXX,invalid_test_account_number=XXXX + --environment-variables clearPackageData=true,ORG_GRADLE_PROJECT_mullvad.test.e2e.prod.accountNumber.valid=XXXX,ORG_GRADLE_PROJECT_mullvad.test.e2e.prod.accountNumber.invalid=XXXX ``` If using gcloud via the docker image, the following can be executed in the `android` directory to run the tests (on a Pixel 5e): @@ -54,7 +49,7 @@ docker run --rm --volumes-from gcloud-config -v ${PWD}:/android gcr.io/google.co --test ./android/test/e2e/build/outputs/apk/debug/e2e-debug.apk \ --device model=redfin,version=30,locale=en,orientation=portrait \ --use-orchestrator \ - --environment-variables clearPackageData=true,valid_test_account_number=XXXX,invalid_test_account_number=XXXX + --environment-variables clearPackageData=true,ORG_GRADLE_PROJECT_mullvad.test.e2e.prod.accountNumber.valid=XXXX,ORG_GRADLE_PROJECT_mullvad.test.e2e.prod.accountNumber.invalid=XXXX ``` ## Test artefacts diff --git a/android/test/e2e/build.gradle.kts b/android/test/e2e/build.gradle.kts index 31181aab52..debd5ff9b6 100644 --- a/android/test/e2e/build.gradle.kts +++ b/android/test/e2e/build.gradle.kts @@ -1,5 +1,3 @@ -import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties -import java.util.Properties import org.gradle.internal.extensions.stdlib.capitalized plugins { @@ -23,42 +21,16 @@ android { "de.mannodermaus.junit5.AndroidJUnit5Builder" targetProjectPath = ":app" - fun Properties.addRequiredPropertyAsBuildConfigField(name: String) { - val value = - System.getenv(name) - ?: getProperty(name) - ?: throw GradleException("Missing property: $name") + testInstrumentationRunnerArguments += buildMap { + put("clearPackageData", "true") - buildConfigField(type = "String", name = name, value = "\"$value\"") - } - - Properties().apply { - load(project.file("e2e.properties").inputStream()) - addRequiredPropertyAsBuildConfigField("API_VERSION") - addRequiredPropertyAsBuildConfigField("TRAFFIC_GENERATION_IP_ADDRESS") - addRequiredPropertyAsBuildConfigField("TEST_ROUTER_API_HOST") - } - - fun MutableMap<String, String>.addOptionalPropertyAsArgument(name: String) { - val value = - rootProject.properties.getOrDefault(name, null) as? String - ?: gradleLocalProperties(rootProject.projectDir, providers).getProperty(name) - - if (value != null) { - put(name, value) - } - } - - testInstrumentationRunnerArguments += - mutableMapOf<String, String>().apply { - put("clearPackageData", "true") - addOptionalPropertyAsArgument("enable_highly_rate_limited_tests") - addOptionalPropertyAsArgument("valid_test_account_number") - addOptionalPropertyAsArgument("invalid_test_account_number") - project.findProperty("test.e2e.enableAccessToLocalApiTests")?.let { - put("enable_access_to_local_api_tests", it.toString()) + // Add all properties starting with "test.e2e" to the testInstrumentationRunnerArguments + properties.forEach { + if (it.key.startsWith("mullvad.test.e2e")) { + put(it.key, it.value.toString()) } } + } } flavorDimensions += FlavorDimensions.BILLING diff --git a/android/test/e2e/e2e.properties b/android/test/e2e/e2e.properties deleted file mode 100644 index 1cfa0f6bd1..0000000000 --- a/android/test/e2e/e2e.properties +++ /dev/null @@ -1,3 +0,0 @@ -API_VERSION=v1 -TRAFFIC_GENERATION_IP_ADDRESS=45.83.223.209 -TEST_ROUTER_API_HOST=192.168.105.1 diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt index 4720fc5ce6..f23f74dd6a 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/ConnectionTest.kt @@ -20,6 +20,7 @@ import net.mullvad.mullvadvpn.test.e2e.api.relay.RelayApi import net.mullvad.mullvadvpn.test.e2e.misc.AccountTestRule import net.mullvad.mullvadvpn.test.e2e.misc.ClearFirewallRules import net.mullvad.mullvadvpn.test.e2e.router.firewall.DropRule +import net.mullvad.mullvadvpn.test.e2e.router.firewall.FirewallClient import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension @@ -34,6 +35,7 @@ class ConnectionTest : EndToEndTest() { private val connCheckClient = ConnectionCheckApi() private val relayClient = RelayApi() + private val firewallClient by lazy { FirewallClient() } @Test fun testConnect() { diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/LeakTest.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/LeakTest.kt index 3d5eb70cfa..9a2ec22fef 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/LeakTest.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/LeakTest.kt @@ -1,5 +1,6 @@ package net.mullvad.mullvadvpn.test.e2e +import androidx.test.platform.app.InstrumentationRegistry import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest @@ -17,6 +18,8 @@ import net.mullvad.mullvadvpn.test.common.page.enableShadowsocksStory import net.mullvad.mullvadvpn.test.common.page.on import net.mullvad.mullvadvpn.test.common.rule.ForgetAllVpnAppsInSettingsTestRule import net.mullvad.mullvadvpn.test.e2e.annotations.HasDependencyOnLocalAPI +import net.mullvad.mullvadvpn.test.e2e.constant.getTrafficGeneratorHost +import net.mullvad.mullvadvpn.test.e2e.constant.getTrafficGeneratorPort import net.mullvad.mullvadvpn.test.e2e.misc.AccountTestRule import net.mullvad.mullvadvpn.test.e2e.misc.NetworkTrafficChecker import net.mullvad.mullvadvpn.test.e2e.misc.NoTrafficToHostRule @@ -83,8 +86,8 @@ class LeakTest : EndToEndTest() { on<ConnectPage> { waitForConnectedLabel() } // Capture generated traffic to a specific host - val targetIpAddress = BuildConfig.TRAFFIC_GENERATION_IP_ADDRESS - val targetPort = 80 + val targetIpAddress = InstrumentationRegistry.getArguments().getTrafficGeneratorHost() + val targetPort = InstrumentationRegistry.getArguments().getTrafficGeneratorPort() val captureResult = PacketCapture().capturePackets { TrafficGenerator(targetIpAddress, targetPort).generateTraffic(10.milliseconds) { @@ -131,8 +134,8 @@ class LeakTest : EndToEndTest() { on<ConnectPage> { waitForConnectedLabel() } // Capture generated traffic to a specific host - val targetIpAddress = BuildConfig.TRAFFIC_GENERATION_IP_ADDRESS - val targetPort = 80 + val targetIpAddress = InstrumentationRegistry.getArguments().getTrafficGeneratorHost() + val targetPort = InstrumentationRegistry.getArguments().getTrafficGeneratorPort() val captureResult: PacketCaptureResult = PacketCapture().capturePackets { TrafficGenerator(targetIpAddress, targetPort).generateTraffic(10.milliseconds) { @@ -188,8 +191,8 @@ class LeakTest : EndToEndTest() { on<ConnectPage> { waitForConnectedLabel() } // Capture generated traffic to a specific host - val targetIpAddress = BuildConfig.TRAFFIC_GENERATION_IP_ADDRESS - val targetPort = 80 + val targetIpAddress = InstrumentationRegistry.getArguments().getTrafficGeneratorHost() + val targetPort = InstrumentationRegistry.getArguments().getTrafficGeneratorPort() val captureResult: PacketCaptureResult = PacketCapture().capturePackets { TrafficGenerator(targetIpAddress, targetPort).generateTraffic(10.milliseconds) { diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt index 12987df9e0..94b0bfa3f6 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HasDependencyOnLocalAPI.kt @@ -1,7 +1,7 @@ package net.mullvad.mullvadvpn.test.e2e.annotations import androidx.test.platform.app.InstrumentationRegistry -import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument +import net.mullvad.mullvadvpn.test.e2e.constant.isRaasEnabled import org.junit.jupiter.api.extension.ConditionEvaluationResult import org.junit.jupiter.api.extension.ExecutionCondition import org.junit.jupiter.api.extension.ExtendWith @@ -19,10 +19,7 @@ annotation class HasDependencyOnLocalAPI { context: ExtensionContext? ): ConditionEvaluationResult { - val enable = - InstrumentationRegistry.getArguments() - .getRequiredArgument("enable_access_to_local_api_tests") - .toBoolean() + val enable = InstrumentationRegistry.getArguments().isRaasEnabled() return if (enable) { ConditionEvaluationResult.enabled( diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt index 12280fcaf1..09124ca5a5 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/annotations/HighlyRateLimited.kt @@ -1,8 +1,7 @@ package net.mullvad.mullvadvpn.test.e2e.annotations import androidx.test.platform.app.InstrumentationRegistry -import net.mullvad.mullvadvpn.test.e2e.constant.ENABLE_HIGHLY_RATE_LIMITED_TESTS -import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument +import net.mullvad.mullvadvpn.test.e2e.constant.isHighlyRateLimitedTestsEnabled import org.junit.jupiter.api.extension.ConditionEvaluationResult import org.junit.jupiter.api.extension.ExecutionCondition import org.junit.jupiter.api.extension.ExtendWith @@ -19,10 +18,7 @@ annotation class HighlyRateLimited { override fun evaluateExecutionCondition( context: ExtensionContext? ): ConditionEvaluationResult { - val enable = - InstrumentationRegistry.getArguments() - .getRequiredArgument(ENABLE_HIGHLY_RATE_LIMITED_TESTS) - .toBoolean() + val enable = InstrumentationRegistry.getArguments().isHighlyRateLimitedTestsEnabled() return if (enable) { ConditionEvaluationResult.enabled("Running test highly affected by rate limiting.") diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/mullvad/MullvadApi.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/mullvad/MullvadApi.kt index d24a6d3c92..099808fcdb 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/mullvad/MullvadApi.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/mullvad/MullvadApi.kt @@ -84,8 +84,8 @@ class MullvadApi { companion object { private const val BASE_URL = "api.${BuildConfig.INFRASTRUCTURE_BASE_DOMAIN}" - private const val AUTH_PATH = "auth/${BuildConfig.API_VERSION}/token" - private const val DEVICES_PATH = "accounts/${BuildConfig.API_VERSION}/devices" + private const val AUTH_PATH = "auth/v1/token" + private const val DEVICES_PATH = "accounts/v1/devices" } } diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApi.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApi.kt index 647bb49b20..e6465f0b23 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApi.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApi.kt @@ -64,7 +64,7 @@ class PartnerApi(base64AuthCredentials: String) { companion object { private const val BASE_URL = "partner.${BuildConfig.INFRASTRUCTURE_BASE_DOMAIN}" - private const val ACCOUNT_PATH = "${BuildConfig.API_VERSION}/accounts" + private const val ACCOUNT_PATH = "v1/accounts" } } diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApiTest.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApiTest.kt index d6f91bb749..e2d723da22 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApiTest.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/partner/PartnerApiTest.kt @@ -2,7 +2,7 @@ package net.mullvad.mullvadvpn.test.e2e.api.partner import androidx.test.platform.app.InstrumentationRegistry import kotlinx.coroutines.test.runTest -import net.mullvad.mullvadvpn.test.e2e.constant.PARTNER_AUTH +import net.mullvad.mullvadvpn.test.e2e.constant.getPartnerAuth import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -10,8 +10,7 @@ import org.junit.jupiter.api.assertDoesNotThrow @Disabled("Only used developing the PartnerApi") class PartnerApiTest { - private val partnerApi = - PartnerApi(InstrumentationRegistry.getArguments().getString(PARTNER_AUTH, null)) + private val partnerApi = PartnerApi(InstrumentationRegistry.getArguments().getPartnerAuth()!!) @Test fun testCreateAccount() = runTest { diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/relay/RelayApi.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/relay/RelayApi.kt index 2b2017f210..767851bc1c 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/relay/RelayApi.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/api/relay/RelayApi.kt @@ -50,6 +50,6 @@ class RelayApi { companion object { private const val BASE_URL = "api.${BuildConfig.INFRASTRUCTURE_BASE_DOMAIN}" - private const val RELAY_PATH = "app/${BuildConfig.API_VERSION}/relays" + private const val RELAY_PATH = "app/v1/relays" } } diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt index 0c221f8ddf..8bcb5c2997 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/constant/Constants.kt @@ -1,9 +1,46 @@ package net.mullvad.mullvadvpn.test.e2e.constant +import android.os.Bundle +import androidx.test.platform.app.InstrumentationRegistry +import net.mullvad.mullvadvpn.test.e2e.BuildConfig +import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument + const val LOG_TAG = "mullvad-e2e" -const val PARTNER_AUTH = "partner_auth" -const val VALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY = "valid_test_account_number" -const val INVALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY = "invalid_test_account_number" -const val ENABLE_ACCESS_TO_LOCAL_API_TESTS = "enable_access_to_local_api_tests" -const val ENABLE_HIGHLY_RATE_LIMITED_TESTS = "enable_highly_rate_limited_tests" +fun Bundle.getPartnerAuth() = + InstrumentationRegistry.getArguments() + .getString("mullvad.test.e2e.${BuildConfig.FLAVOR_infrastructure}.partnerAuth") + +fun Bundle.getValidAccountNumber() = + InstrumentationRegistry.getArguments() + .getRequiredArgument( + "mullvad.test.e2e.${BuildConfig.FLAVOR_infrastructure}.accountNumber.valid" + ) + +fun Bundle.getInvalidAccountNumber() = + InstrumentationRegistry.getArguments() + .getRequiredArgument( + "mullvad.test.e2e.${BuildConfig.FLAVOR_infrastructure}.accountNumber.invalid" + ) + +fun Bundle.isRaasEnabled(): Boolean = + InstrumentationRegistry.getArguments() + .getRequiredArgument("mullvad.test.e2e.config.raas.enable") + .toBoolean() + +fun Bundle.isHighlyRateLimitedTestsEnabled(): Boolean = + InstrumentationRegistry.getArguments() + .getRequiredArgument("mullvad.test.e2e.config.runHighlyRateLimitedTests") + .toBoolean() + +fun Bundle.getRaasHost() = + InstrumentationRegistry.getArguments().getRequiredArgument("mullvad.test.e2e.config.raas.host") + +fun Bundle.getTrafficGeneratorHost(): String = + InstrumentationRegistry.getArguments() + .getRequiredArgument("mullvad.test.e2e.config.raas.trafficGenerator.target.host") + +fun Bundle.getTrafficGeneratorPort(): Int = + InstrumentationRegistry.getArguments() + .getRequiredArgument("mullvad.test.e2e.config.raas.trafficGenerator.target.port") + .toInt() diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountProvider.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountProvider.kt index 61fc023ade..799f33be64 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountProvider.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/AccountProvider.kt @@ -4,15 +4,13 @@ import androidx.test.platform.app.InstrumentationRegistry import net.mullvad.mullvadvpn.test.e2e.api.mullvad.MullvadApi import net.mullvad.mullvadvpn.test.e2e.api.mullvad.removeAllDevices import net.mullvad.mullvadvpn.test.e2e.api.partner.PartnerApi -import net.mullvad.mullvadvpn.test.e2e.constant.INVALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY -import net.mullvad.mullvadvpn.test.e2e.constant.PARTNER_AUTH -import net.mullvad.mullvadvpn.test.e2e.constant.VALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY -import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument +import net.mullvad.mullvadvpn.test.e2e.constant.getInvalidAccountNumber +import net.mullvad.mullvadvpn.test.e2e.constant.getPartnerAuth +import net.mullvad.mullvadvpn.test.e2e.constant.getValidAccountNumber object AccountProvider { private val mullvadClient = MullvadApi() - private val partnerAuth: String? = - InstrumentationRegistry.getArguments().getString(PARTNER_AUTH, null) + private val partnerAuth: String? = InstrumentationRegistry.getArguments().getPartnerAuth() private val partnerClient: PartnerApi by lazy { PartnerApi(partnerAuth!!) } suspend fun getValidAccountNumber() = @@ -23,14 +21,10 @@ object AccountProvider { partnerClient.addTime(accountNumber = accountNumber, daysToAdd = 1) accountNumber } else { - val validAccountNumber = - InstrumentationRegistry.getArguments() - .getRequiredArgument(VALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY) + val validAccountNumber = InstrumentationRegistry.getArguments().getValidAccountNumber() mullvadClient.removeAllDevices(validAccountNumber) validAccountNumber } - fun getInvalidAccountNumber() = - InstrumentationRegistry.getArguments() - .getRequiredArgument(INVALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY) + fun getInvalidAccountNumber() = InstrumentationRegistry.getArguments().getInvalidAccountNumber() } diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/CleanupAccountTestRule.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/CleanupAccountTestRule.kt index 3cf1f602b4..ae59231788 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/CleanupAccountTestRule.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/misc/CleanupAccountTestRule.kt @@ -5,8 +5,7 @@ import co.touchlab.kermit.Logger import kotlinx.coroutines.runBlocking import net.mullvad.mullvadvpn.test.e2e.api.mullvad.MullvadApi import net.mullvad.mullvadvpn.test.e2e.api.mullvad.removeAllDevices -import net.mullvad.mullvadvpn.test.e2e.constant.VALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY -import net.mullvad.mullvadvpn.test.e2e.extension.getRequiredArgument +import net.mullvad.mullvadvpn.test.e2e.constant.getValidAccountNumber import org.junit.jupiter.api.extension.BeforeEachCallback import org.junit.jupiter.api.extension.ExtensionContext @@ -15,9 +14,7 @@ class CleanupAccountTestRule : BeforeEachCallback { override fun beforeEach(context: ExtensionContext) { Logger.d("Cleaning up account before test: ${context.requiredTestMethod.name}") - val validTestAccountNumber = - InstrumentationRegistry.getArguments() - .getRequiredArgument(VALID_TEST_ACCOUNT_NUMBER_ARGUMENT_KEY) + val validTestAccountNumber = InstrumentationRegistry.getArguments().getValidAccountNumber() runBlocking { mullvadApi.removeAllDevices(validTestAccountNumber) } } } diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/firewall/FirewallClient.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/firewall/FirewallClient.kt index 3d6264047b..3f6a212497 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/firewall/FirewallClient.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/firewall/FirewallClient.kt @@ -1,5 +1,6 @@ package net.mullvad.mullvadvpn.test.e2e.router.firewall +import androidx.test.platform.app.InstrumentationRegistry import co.touchlab.kermit.Logger import io.ktor.client.HttpClient import io.ktor.client.engine.cio.CIO @@ -13,7 +14,7 @@ import io.ktor.http.URLProtocol import io.ktor.http.contentType import io.ktor.serialization.kotlinx.json.json import kotlinx.serialization.json.Json -import net.mullvad.mullvadvpn.test.e2e.BuildConfig +import net.mullvad.mullvadvpn.test.e2e.constant.getRaasHost class FirewallClient(private val httpClient: HttpClient = defaultHttpClient()) { suspend fun createRule(rule: DropRule) { @@ -40,7 +41,7 @@ private fun defaultHttpClient(): HttpClient = defaultRequest { url { protocol = URLProtocol.HTTP - host = BuildConfig.TEST_ROUTER_API_HOST + host = InstrumentationRegistry.getArguments().getRaasHost() } } diff --git a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/packetCapture/PacketCapture.kt b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/packetCapture/PacketCapture.kt index e192eacc4a..055d1620d0 100644 --- a/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/packetCapture/PacketCapture.kt +++ b/android/test/e2e/src/main/kotlin/net/mullvad/mullvadvpn/test/e2e/router/packetCapture/PacketCapture.kt @@ -1,5 +1,6 @@ package net.mullvad.mullvadvpn.test.e2e.router.packetCapture +import androidx.test.platform.app.InstrumentationRegistry import co.touchlab.kermit.Logger import io.ktor.client.HttpClient import io.ktor.client.call.body @@ -20,7 +21,7 @@ import java.util.UUID import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import net.mullvad.mullvadvpn.test.e2e.BuildConfig +import net.mullvad.mullvadvpn.test.e2e.constant.getRaasHost import net.mullvad.mullvadvpn.test.e2e.misc.Networking import net.mullvad.mullvadvpn.test.e2e.serializer.PacketCaptureSessionSerializer import org.junit.jupiter.api.fail @@ -60,7 +61,7 @@ class PacketCapture { private fun defaultHttpClient(): HttpClient = HttpClient(CIO) { - defaultRequest { url("http://${BuildConfig.TEST_ROUTER_API_HOST}") } + defaultRequest { url("http://${InstrumentationRegistry.getArguments().getRaasHost()}") } engine { requestTimeout = REQUEST_TIMEOUT_MS } install(ContentNegotiation) { |
