Skip to content

Commit

Permalink
Patch impersonation test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyrzhao committed Jun 29, 2022
1 parent 83dbd0d commit 6261c5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 37 deletions.
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 6261c5a

Please sign in to comment.