Skip to content

Commit faf71ce

Browse files
authored
Merge branch 'main' into model-armor-node-codeowners
2 parents 525d9bf + 33177b6 commit faf71ce

File tree

12 files changed

+132
-39
lines changed

12 files changed

+132
-39
lines changed

.github/config/nodejs-dev.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
"run/image-processing",
203203
"run/jobs",
204204
"run/logging-manual",
205+
"run/idp-sql",
205206
"run/markdown-preview/editor",
206207
"run/markdown-preview/renderer",
207208
"run/pubsub",

.github/config/nodejs-prod.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
"functions/slack", // TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type ... Received undefined
9393
"healthcare/fhir", // Error: Cannot find module 'whatwg-url'
9494
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
95-
"run/idp-sql", // (untested) Error: Invalid contents in the credentials file
9695
"storagetransfer", // CredentialsError: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
9796
"video-intelligence", // PERMISSION_DENIED: The caller does not have permission
9897
"workflows", // SyntaxError: Cannot use import statement outside a module

endpoints/getting-started/app.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
'use strict';
1717

1818
// [START endpoints_server_setup]
19-
// [START setup]
2019
const express = require('express');
2120

2221
const app = express();
@@ -25,7 +24,6 @@ app.set('case sensitive routing', true);
2524

2625
// This middleware is available in Express v4.16.0 onwards
2726
app.use(express.json());
28-
// [END setup]
2927
// [END endpoints_server_setup]
3028

3129
app.post('/echo', (req, res) => {
@@ -46,13 +44,11 @@ app.get('/auth/info/googleidtoken', authInfoHandler);
4644

4745
if (module === require.main) {
4846
// [START endpoints_server_listen]
49-
// [START listen]
5047
const PORT = parseInt(process.env.PORT) || 8080;
5148
app.listen(PORT, () => {
5249
console.log(`App listening on port ${PORT}`);
5350
console.log('Press Ctrl+C to quit.');
5451
});
55-
// [END listen]
5652
// [END endpoints_server_listen]
5753
}
5854
// [END endpoints_express_auth]

recaptcha_enterprise/demosite/app/controllers/controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ const onCommentSubmit = async (req, res) => {
249249
};
250250

251251
// Classify the action as BAD/ NOT_BAD based on conditions specified.
252+
// See https://cloud.google.com/recaptcha/docs/interpret-assessment-website
252253
const checkForBadAction = function (assessmentResponse, recaptchaAction) {
253254
let label = Label.NOT_BAD;
254255
let reason = '';

run/idp-sql/ci-setup.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"env": {
3+
"SERVICE_NAME": "idp-sql-${RUN_ID}",
4+
"SAMPLE_VERSION": "${RUN_ID}",
5+
"CLOUD_SQL_CONNECTION_NAME": "nodejs-docs-samples-tests:us-central1:test-postgres-instance",
6+
"DB_NAME": "ci-database",
7+
"DB_USER": "ci-user"
8+
},
9+
"secrets": {
10+
"IDP_KEY": "nodejs-docs-samples-tests/long-door-651-idp-key",
11+
"DB_PASSWORD": "nodejs-docs-samples-tests/nodejs-docs-samples-test-postgres-instance-ci-user-password" }
12+
}

run/idp-sql/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
},
1515
"scripts": {
1616
"start": "node index.js",
17-
"test": "c8 mocha -p -j 2 test/app.test.js --timeout=120000 --exit",
18-
"system-test": "c8 mocha -p -j 2 test/system.test.js --timeout=1800000 --exit"
17+
"unit-test": "c8 mocha -p -j 2 test/app.test.js --timeout=120000 --exit",
18+
"system-test": "test/proxy-setup.sh && c8 mocha -p -j 2 test/system.test.js --timeout=1800000 --exit",
19+
"all-test": "npm run unit-test && npm run system-test",
20+
"test": "npm -- run all-test"
1921
},
2022
"dependencies": {
2123
"express": "^4.16.2",
22-
"firebase-admin": "^12.0.0",
24+
"firebase-admin": "^13.0.0",
2325
"gcp-metadata": "^6.0.0",
2426
"google-auth-library": "^9.0.0",
2527
"handlebars": "^4.7.6",

run/idp-sql/test/e2e_test_cleanup.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
116
steps:
217

318
- id: 'Delete resources'
@@ -12,11 +27,15 @@ steps:
1227
./test/retry.sh "gcloud container images describe gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION}" \
1328
"gcloud container images delete gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} --quiet"
1429
15-
./test/retry.sh "gcloud run services describe ${_SERVICE} --region ${_REGION} --platform ${_PLATFORM}" \
16-
"gcloud run services delete ${_SERVICE} --region ${_REGION} --platform ${_PLATFORM} --quiet"
30+
./test/retry.sh "gcloud run services describe ${_SERVICE} --region ${_REGION}" \
31+
"gcloud run services delete ${_SERVICE} --region ${_REGION} --quiet"
1732
1833
substitutions:
1934
_SERVICE: idp-sql
2035
_VERSION: manual
2136
_REGION: us-central1
22-
_PLATFORM: managed
37+
38+
serviceAccount: 'projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
39+
options:
40+
logging: CLOUD_LOGGING_ONLY
41+
dynamicSubstitutions: true

run/idp-sql/test/e2e_test_setup.yaml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
116
steps:
217

318
- id: 'Add a Secret to Secret Manager'
@@ -12,9 +27,13 @@ steps:
1227
sed -i "s/\"DB_USER\": \"postgres\"/\"DB_USER\": \"${_DB_USER}\"/" postgres-secrets.json
1328
1429
./test/retry.sh "gcloud secrets create ${_SERVICE}-secrets \
15-
--replication-policy="automatic" \
30+
--replication-policy=automatic \
1631
--data-file=postgres-secrets.json"
1732
33+
./test/retry.sh "gcloud secrets add-iam-policy-binding ${_SERVICE}-secrets \
34+
--member=serviceAccount:${_SERVICE_ACCOUNT} \
35+
--role=roles/secretmanager.secretAccessor"
36+
1837
- id: 'Build Container Image'
1938
name: 'gcr.io/cloud-builders/docker'
2039
entrypoint: '/bin/bash'
@@ -37,11 +56,11 @@ steps:
3756
args:
3857
- '-c'
3958
- |
40-
./test/retry.sh "gcloud beta run deploy ${_SERVICE} \
59+
./test/retry.sh "gcloud run deploy ${_SERVICE} \
4160
--image gcr.io/${PROJECT_ID}/${_SERVICE}:${_VERSION} \
4261
--allow-unauthenticated \
4362
--region ${_REGION} \
44-
--platform ${_PLATFORM} \
63+
--service-account ${_SERVICE_ACCOUNT} \
4564
--add-cloudsql-instances ${_CLOUD_SQL_CONNECTION_NAME} \
4665
--update-secrets CLOUD_SQL_CREDENTIALS_SECRET=${_SERVICE}-secrets:latest"
4766
@@ -52,8 +71,13 @@ substitutions:
5271
_SERVICE: idp-sql
5372
_VERSION: manual
5473
_REGION: us-central1
55-
_PLATFORM: managed
5674
_CLOUD_SQL_CONNECTION_NAME: $PROJECT_ID:us-central1:idp-sql-instance
5775
_DB_NAME: postgres
5876
_DB_USER: postgres
5977
_DB_PASSWORD: password1234
78+
_SERVICE_ACCOUNT: ${PROJECT_NUMBER}@cloudbuild.gserviceaccount.com
79+
80+
serviceAccount: 'projects/${PROJECT_ID}/serviceAccounts/${_SERVICE_ACCOUNT}'
81+
options:
82+
logging: CLOUD_LOGGING_ONLY
83+
dynamicSubstitutions: true

run/idp-sql/test/proxy-setup.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Proof of concept: setting up proxy
16+
17+
curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.15.1/cloud-sql-proxy.linux.amd64
18+
chmod +x cloud-sql-proxy
19+
cloud-sql-proxy -dir=/cloudsql -instances=$INSTANCE_CONNECTION_NAME &

run/idp-sql/test/retry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ do
5959
if ((attempt_num==max_attempts))
6060
then
6161
echo "Attempt $attempt_num / $max_attempts failed! No more retries left!"
62-
exit
62+
exit 1
6363
else
6464
echo "Attempt $attempt_num / $max_attempts failed!"
6565
sleep $((attempt_num++))

0 commit comments

Comments
 (0)