Skip to content

Commit c138d76

Browse files
committed
update token
1 parent 524ca87 commit c138d76

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

run/idp-sql/postcreate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export SERVICE_ACCOUNT="idp-sql-identity"
2020

2121
# Update Cloud Run service to include Cloud SQL instance, Secret Manager secret,
2222
# and service account
23-
gcloud beta run services update ${K_SERVICE} \
23+
gcloud run services update ${K_SERVICE} \
2424
--platform managed \
2525
--region ${GOOGLE_CLOUD_REGION} \
2626
--service-account ${SERVICE_ACCOUNT}@${GOOGLE_CLOUD_PROJECT}.iam.gserviceaccount.com \

run/idp-sql/test/e2e_test.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,23 @@ def deployed_service() -> str:
144144
.stdout.strip()
145145
.decode()
146146
)
147+
auth_token = (
148+
subprocess.run(
149+
[
150+
"gcloud",
151+
"auth",
152+
"print-identity-token",
153+
"--project",
154+
GOOGLE_CLOUD_PROJECT,
155+
],
156+
stdout=subprocess.PIPE,
157+
check=True,
158+
)
159+
.stdout.strip()
160+
.decode()
161+
)
147162

148-
yield service_url
163+
yield service_url, auth_token
149164

150165
# Cleanup
151166

@@ -199,15 +214,15 @@ def jwt_token() -> str:
199214

200215
def test_end_to_end(jwt_token: str, deployed_service: str) -> None:
201216
token = jwt_token
202-
service_url = deployed_service
217+
service_url, auth_token = deployed_service
203218

204219
adapter = HTTPAdapter(max_retries=retry_strategy)
205220

206221
client = requests.session()
207222
client.mount("https://", adapter)
208223

209224
# Can successfully make a request
210-
response = client.get(service_url, headers={"Authorization": f"Bearer {token}"})
225+
response = client.get(service_url, headers={"Authorization": f"Bearer {auth_token}"})
211226
assert response.status_code == 200
212227

213228
# Can make post with token
@@ -218,7 +233,7 @@ def test_end_to_end(jwt_token: str, deployed_service: str) -> None:
218233
assert "Vote successfully cast" in response.content.decode("UTF-8")
219234

220235
# Confirm updated results
221-
response = client.get(service_url)
236+
response = client.get(service_url, headers={"Authorization": f"Bearer {auth_token}"})
222237
assert response.status_code == 200
223238
assert "🐶" in response.content.decode("UTF-8")
224239

run/idp-sql/test/e2e_test_setup.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ steps:
6363
args:
6464
- '-c'
6565
- |
66-
./test/retry.sh "gcloud beta run deploy ${_SERVICE} \
66+
./test/retry.sh "gcloud run deploy ${_SERVICE} \
6767
--project $PROJECT_ID \
6868
--image gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} \
6969
--allow-unauthenticated \

0 commit comments

Comments
 (0)