Skip to content

Commit

Permalink
Add Github Action for integration test (#135)
Browse files Browse the repository at this point in the history
This will replace the old Travis CI presubmits, which appears to have stopped working due to deprecation. Also patching impersonation test.
  • Loading branch information
andyrzhao authored Jun 29, 2022
1 parent 8130b7b commit c142cd9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.13

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./integration/...

21 changes: 6 additions & 15 deletions integration/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,21 +516,12 @@ func TestServiceAccountImpersonationFlow(t *testing.T) {
}

processOutput := func(output string) string {

method := "\"method\": \"google.iam.credentials.v1.IAMCredentials.GenerateAccessToken\""
service := "\"service\": \"iamcredentials.googleapis.com\""

mPos := strings.Index(output, method)
sPos := strings.Index(output, service)

// If service appears later than method, revert order to match output
if sPos > mPos {
output = strings.Replace(output, method, "**MARKER-1**", 1)
output = strings.Replace(output, service, method, 1)
output = strings.Replace(output, "**MARKER-1**", service, 1)
}

return output
//Error details are constantly changing, so we will strip out "error.details" field.
var jsonData map[string]interface{}
json.Unmarshal([]byte(output), &jsonData) // nolint:errcheck
delete(jsonData["error"].(map[string]interface{}), "details")
jsonString, _ := json.Marshal(jsonData)
return string(jsonString)
}

runTestScenariosWithInputAndProcessedOutput(t, tests, nil, processOutput)
Expand Down
23 changes: 1 addition & 22 deletions integration/golden/fetch-impersonation.golden
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"detail": "Authentication error: 16; Error Details: Credential sent is invalid. Unknown token version 0 for token string: ya29.GltDB_y~"
},
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED",
"metadata": {
"service": "iamcredentials.googleapis.com",
"method": "google.iam.credentials.v1.IAMCredentials.GenerateAccessToken"
}
}
]
}
}

{"error":{"code":401,"message":"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status":"UNAUTHENTICATED"}}

0 comments on commit c142cd9

Please sign in to comment.