From 408bc298f10e9a2ba8a9d05462658e75f61a0b6c Mon Sep 17 00:00:00 2001 From: Tom Wiseman Date: Mon, 4 Dec 2023 13:42:03 -0500 Subject: [PATCH] [WX-1393] Add Content Length to Curl request (#7328) --- .../impl/tes/TesAsyncBackendJobExecutionActor.scala | 8 +++++--- .../impl/tes/TesAsyncBackendJobExecutionActorSpec.scala | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/supportedBackends/tes/src/main/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActor.scala b/supportedBackends/tes/src/main/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActor.scala index 92391296533..bd171d757b4 100644 --- a/supportedBackends/tes/src/main/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActor.scala +++ b/supportedBackends/tes/src/main/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActor.scala @@ -100,11 +100,11 @@ object TesAsyncBackendJobExecutionActor { | exit 1 | fi |fi - | + |curl --version + |jq --version |# Acquire bearer token, relying on the User Assigned Managed Identity of this VM. |echo Acquiring Bearer Token using User Assigned Managed Identity... |BEARER_TOKEN=$$(curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' -H Metadata:true -s | jq .access_token) - | |# Remove the leading and trailing quotes |BEARER_TOKEN="$${BEARER_TOKEN#\\"}" |BEARER_TOKEN="$${BEARER_TOKEN%\\"}" @@ -117,7 +117,9 @@ object TesAsyncBackendJobExecutionActor { | -X POST "$getSasWsmEndpoint" \\ | -H "Content-Type: application/json" \\ | -H "accept: */*" \\ - | -H "Authorization: Bearer $${BEARER_TOKEN}") + | -H "Authorization: Bearer $${BEARER_TOKEN}" \\ + | -H "Content-Length: 0" \\ + | -d "") | |# Store token as environment variable |export $environmentVariableName=$$(echo "$${sas_response_json}" | jq -r '.token') diff --git a/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala b/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala index b9082d2e01f..11267d238cf 100644 --- a/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala +++ b/supportedBackends/tes/src/test/scala/cromwell/backend/impl/tes/TesAsyncBackendJobExecutionActorSpec.scala @@ -141,7 +141,9 @@ class TesAsyncBackendJobExecutionActorSpec extends AnyFlatSpec with Matchers wit | -X POST "$expectedEndpoint" \\ | -H "Content-Type: application/json" \\ | -H "accept: */*" \\ - | -H "Authorization: Bearer $${BEARER_TOKEN}") + | -H "Authorization: Bearer $${BEARER_TOKEN}" \\ + | -H "Content-Length: 0" \\ + | -d "") |""".stripMargin val exportCommandSubstring = s"""export $mockEnvironmentVariableNameFromWom=$$(echo "$${sas_response_json}" | jq -r '.token')""" val echoCommandSubstring = s"""echo "Saving sas token: $${$mockEnvironmentVariableNameFromWom:0:4}**** to environment variable $mockEnvironmentVariableNameFromWom...""""