Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes missing HTTP header X-Goog-User-Project #2348

Conversation

vinaypotluri
Copy link
Contributor

@vinaypotluri vinaypotluri commented Mar 8, 2023

Flank does not pass the the HTTP header flag X-Goog-user-Project with project Id when using end user credentials. This results in HTTP error 403 (PERMISSION_DENIED). This fix sets the flag so the tests can be run by the user.

Fixes #2347

Test Plan

How do we know the code works?

Before:

./gradlew runFlank
"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"
Refer to #2347 for full error log

After:

./gradlew runFlank

This fix will pass HTTP header {"X-Goog-user-Project" : project Id} with requests for testing

> Task :execFlank
version: local_snapshot
revision: 2eefd478acad85f36cff0c6a4fe9e905b8c7bd3e
.........
Smart Flank cache hit: 0% (0 / 3)
  Shard times: 360s

1 matrix ids created in 0m 2s
  Raw results will be stored in your GCS bucket

Matrices webLink
  matrix-1234 https://console.firebase.google.com/project/abc-123456789/testlab/histories/abc.12345/matrices/12345566/details
.
.
.
Total run duration: 3m 36s
        - Preparation: 0m 1s
        - Scheduling tests: 0m 4s
        - Executing matrices: 3m 27s

Steps to build & test locally

  1. Checkout the branch

    git checkout vinaypotluri/missing-X-Goog-User-Project-2347

  2. Build the project

    ./gradlew build

    This generates a jar inside ~/.m2/repository/com/github/flank

  3. Configure your android project's fladle extension to use the generated local SNAPSHOT

fladle {
   projectId = "abc-123456789"
   resultsBucket = "my-bucket"
   resultsHistoryname = "my-app"
   flankVersion = "local-SNAPSHOT"
   ...
}
  1. Run tests in FTL using fladle

    ./gradlew runFlank

Summary of the Changes

2 client libraries are being used namely ToolResults.java (toolresults.googleapis.com) & Testing.java (testing.googleapis.com) to interact with Firebase / Google Client.
All the classes that use these client libraries need to pass in the required header while making a request, otherwise this will result in http error 403. Changes in this PR will make sure to set the header when the client libraries are called.

ex: {"x-goog-user-project", "my-project-id"}

Workflow:

Screen Shot 2023-03-08 at 2 49 30 PM

ToolResults.java

Screen Shot 2023-03-08 at 2 53 31 PM

Testing.java

Screen Shot 2023-03-08 at 2 53 02 PM

@google-cla
Copy link

google-cla bot commented Mar 8, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Flank does not pass the the HTTP header flag X-Goog-user-Project with project Id when
using end user credentials. This results in HTTP error 403 (PERMISSION_DENIED). This fix
sets the flag so the tests can be run by the user.

Fixes Flank#2347
@vinaypotluri vinaypotluri force-pushed the vinaypotluri/missing-X-Goog-User-Project-2347 branch from cc37670 to df2e41a Compare March 8, 2023 12:08
@adamvduke
Copy link
Contributor

@flank-it

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

Integration tests succeed for all OSs ✅
Windows Build scan:
MacOS Build scan:
Linux Build scan:
Workflow run https://github.com/Flank/flank/actions/runs/4366912290

@adamvduke adamvduke merged commit 327033f into Flank:master Mar 9, 2023
@tonybaroneee
Copy link
Contributor

Thanks @vinaypotluri!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flank missing HTTP header X-Goog-User-Project
3 participants