Flank / flank

:speedboat: Massively parallel Android and iOS test runner for Firebase Test Lab
https://firebase.community/
Apache License 2.0
677 stars 115 forks source link

Flank missing HTTP header X-Goog-User-Project #2347

Closed vinaypotluri closed 1 year ago

vinaypotluri commented 1 year ago

Describe the bug

A clear and concise description of what the bug is.

Flank is failing with http error code 403 when using end user credentials to authenticate and run tests. Based on the error the HTTP requests are missing the 'X-Goog-User-Project' header which are required for quota and billing purposes.


To Reproduce

Steps to reproduce the behavior:

  1. Run the command in terminal

    gcloud auth application-default login

  2. Run the commands within the android project and follow the instructions

    ./gradlew flankAuth ./gradlew runFlank

  3. Error Returned: "message": "Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the testing.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/. If you are getting this error with curl or similar tools, you may need to specify 'X-Goog-User-Project' HTTP header for quota and billing purposes. For more information regarding 'X-Goog-User-Project' header, please check https://cloud.google.com/apis/docs/system-parameters.", "status": "PERMISSION_DENIED"


Expected behavior

A clear and concise description of what you expected to happen.

Flank should pass the required header (X-Goog-User-Project) irrespective of the login type (i.e. End User login or Service Account) and users must be able to run tests.


Details (please complete the following information):

Have you tested on the latest Flank snapshot? Yes

Post the output of flank --version. version: v23.01.0 revision: 7ad3d5ba4097f189965110ca52b93fd0645715e0


Additional context

Add any other context about the problem here.

Complete Error Log:

Mar 08, 2023 3:04:01 AM com.google.auth.oauth2.DefaultCredentialsProvider warnAboutProblematicCredentials
WARNING: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/.
ftl.run.exception.PermissionDenied: Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
GET https://testing.googleapis.com/v1/testEnvironmentCatalog/ios?projectId=abc-12345678
{
  "code": 403,
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.ErrorInfo",
      "reason": "SERVICE_DISABLED"
    }
  ],
  "errors": [
    {
      "domain": "usageLimits",
      "message": "Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the testing.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/. If you are getting this error with curl or similar tools, you may need to specify 'X-Goog-User-Project' HTTP header for quota and billing purposes. For more information regarding 'X-Goog-User-Project' header, please check https://cloud.google.com/apis/docs/system-parameters.",
      "reason": "accessNotConfigured",
      "extendedHelp": "https://console.developers.google.com"
    }
  ],
  "message": "Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the testing.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/. If you are getting this error with curl or similar tools, you may need to specify 'X-Goog-User-Project' HTTP header for quota and billing purposes. For more information regarding 'X-Goog-User-Project' header, please check https://cloud.google.com/apis/docs/system-parameters.",
  "status": "PERMISSION_DENIED"
}
        at ftl.http.ExecuteWithRetryKt$executeWithRetry$$inlined$withRetry$1.invokeSuspend(ExecuteWithRetry.kt:30)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at ftl.http.ExecuteWithRetryKt.executeWithRetry(ExecuteWithRetry.kt:44)
        at ftl.client.google.IosCatalog.iosDeviceCatalog(IosCatalog.kt:53)
        at ftl.client.google.IosCatalog.getModels(IosCatalog.kt:21)
        at ftl.client.google.AndroidCatalog.isVirtualDevice(AndroidCatalog.kt:51)
        at ftl.args.PrepareAndroidCommonConfigKt.resolveDeviceType(PrepareAndroidCommonConfig.kt:14)
        at ftl.args.PrepareAndroidCommonConfigKt.prepareAndroidCommonConfig(PrepareAndroidCommonConfig.kt:10)
        at ftl.args.CreateAndroidArgsKt.createAndroidArgs$default(CreateAndroidArgs.kt:15)
        at ftl.domain.RunTestAndroidKt.invoke(RunTestAndroid.kt:41)
        at ftl.presentation.cli.firebase.test.android.AndroidRunCommand.run(AndroidRunCommand.kt:58)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at ftl.Main$main$1.invoke(Main.kt:12)
        at ftl.Main$main$1.invoke(Main.kt:10)
        at ftl.run.exception.ExceptionHandlerKt.withGlobalExceptionHandling(ExceptionHandler.kt:24)
        at ftl.run.exception.ExceptionHandlerKt.withGlobalExceptionHandling(ExceptionHandler.kt:14)
        at ftl.Main.main(Main.kt:10)

Total run duration: 0m  1s