From 21ab08b88b2e8d6b6ac0b0cc1560368a1c87b989 Mon Sep 17 00:00:00 2001 From: Tim De Pauw Date: Sun, 15 Jan 2023 05:19:32 +0100 Subject: [PATCH] Inherit OS stdio in curl command (#147) * Inherit OS stdio in curl command * Hide curl progress bar in integration tests --- integration/cli_test.go | 12 +++++++----- util/curl.go | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/integration/cli_test.go b/integration/cli_test.go index fcc3e4d..6902e3a 100644 --- a/integration/cli_test.go +++ b/integration/cli_test.go @@ -1,11 +1,10 @@ -// // Copyright 2019 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -325,7 +324,8 @@ func Test3LOFlow(t *testing.T) { }, { "curl; 3lo", - []string{"curl", "--scope", "pubsub", "--credentials", "integration/fixtures/fake-client-secrets.json", "--url", "http://localhost:8080/curl"}, + []string{"curl", "--scope", "pubsub", "--credentials", "integration/fixtures/fake-client-secrets.json", "--url", "http://localhost:8080/curl", + "--", "-s"}, "curl-3lo.golden", false, }, @@ -417,7 +417,8 @@ func Test3LOLoopbackFlow(t *testing.T) { "curl; 3lo loopback", []string{"curl", "--scope", "pubsub", "--credentials", "integration/fixtures/fake-client-secrets-3lo-loopback.json", "--url", "http://localhost:8080/curl", "--consentPageInteractionTimeout", CONSENT_PAGE_TIMEOUT, "--consentPageInteractionTimeoutUnits", CONSENT_PAGE_TIMEOUT_UNITS, - "--disableAutoOpenConsentPage"}, + "--disableAutoOpenConsentPage", + "--", "-s"}, "curl-3lo-loopback.golden", false, }, @@ -588,7 +589,8 @@ func Test2LOFlow(t *testing.T) { }, { "curl; 2lo", - []string{"curl", "--scope", "pubsub", "--credentials", "integration/fixtures/fake-service-account.json", "--url", "http://localhost:8080/curl"}, + []string{"curl", "--scope", "pubsub", "--credentials", "integration/fixtures/fake-service-account.json", "--url", "http://localhost:8080/curl", + "--", "-s"}, "curl-2lo.golden", false, }, diff --git a/util/curl.go b/util/curl.go index 6e35530..dace617 100644 --- a/util/curl.go +++ b/util/curl.go @@ -15,8 +15,8 @@ package util import ( - "bytes" "fmt" + "os" "os/exec" ) @@ -33,11 +33,11 @@ func CurlCommand(cli string, header string, url string, extraArgs ...string) { cmdArgs := append(requiredArgs, extraArgs...) cmd := exec.Command(cli, cmdArgs...) - var out bytes.Buffer - cmd.Stdout = &out + cmd.Stdin = os.Stdin + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr err := cmd.Run() if err != nil { - fmt.Println(err) + fmt.Fprintln(os.Stderr, err) } - print(out.String()) }