@@ -31,6 +31,7 @@ resource "google_project_service" "cloudbuild_api" {
31
31
disable_on_destroy = false
32
32
}
33
33
34
+ # # Service usage API is required for roles/serviceusage.serviceUsageViewer.
34
35
resource "google_project_service" "serviceusage_api" {
35
36
service = " serviceusage.googleapis.com"
36
37
disable_on_destroy = false
@@ -93,6 +94,7 @@ resource "google_cloudbuild_trigger" "build_trigger" {
93
94
" -f" , " ./cmd/gcp/ci/Dockerfile" ,
94
95
" ."
95
96
]
97
+ wait_for = [" docker_build_sctfe_gcp" ]
96
98
}
97
99
98
100
# # Push the conformance Docker container image to Artifact Registry.
@@ -104,7 +106,7 @@ resource "google_cloudbuild_trigger" "build_trigger" {
104
106
" --all-tags" ,
105
107
local . conformance_gcp_docker_image
106
108
]
107
- wait_for = [" docker_build_conformance_gcp" ]
109
+ wait_for = [" preclean_env " , " docker_build_conformance_gcp" ]
108
110
}
109
111
110
112
# # Apply the deployment/live/gcp/ci terragrunt config.
@@ -134,20 +136,46 @@ resource "google_cloudbuild_trigger" "build_trigger" {
134
136
id = " bearer_token"
135
137
name = " gcr.io/cloud-builders/gcloud"
136
138
script = << EOT
137
- curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/${ local . cloudbuild_service_account } /identity?audience=$(cat /workspace/conformance_url)" > /workspace/cb_identity
139
+ curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/${ local . cloudbuild_service_account } /identity?audience=$(cat /workspace/conformance_url)" > /workspace/cb_identity
138
140
EOT
139
141
wait_for = [" terraform_apply_conformance_ci" ]
140
142
}
141
143
144
+ # # Generate the test certificate for submission.
145
+ # # TODO: Remove this with CT Hammer when it is ready.
146
+ step {
147
+ id = " gen_test_cert"
148
+ name = " gcr.io/cloud-builders/gcloud"
149
+ script = << EOT
150
+ mkdir -p /tmp/httpschain
151
+ openssl genrsa -out /tmp/httpschain/cert.key 2048
152
+ openssl req -new -key /tmp/httpschain/cert.key -out /tmp/httpschain/cert.csr -config=testdata/fake-ca.cfg
153
+ openssl x509 -req -days 3650 -in /tmp/httpschain/cert.csr -CAkey testdata/fake-ca.privkey.pem -CA testdata/fake-ca.cert -passin pass:"gently" -outform pem -out /tmp/httpschain/chain.pem -provider legacy -provider default
154
+ cat testdata/fake-ca.cert >> /tmp/httpschain/chain.pem
155
+ EOT
156
+ wait_for = [" terraform_apply_conformance_ci" ]
157
+ }
158
+
159
+ # # Prepare the add-chain request body
160
+ # # TODO: Remove this with CT Hammer when it is ready.
161
+ step {
162
+ id = " prepare_add_chain_request_body"
163
+ name = " ghcr.io/jqlang/jq"
164
+ script = << EOT
165
+ cat /tmp/httpschain/chain.pem | jq --raw-input --slurp --compact-output 'split("\n-----END CERTIFICATE-----\n") | map(select(length > 0) | sub("^-----BEGIN CERTIFICATE-----\n"; "") | sub("\n-----END CERTIFICATE-----$"; "")) | { "chain": . }' > /tmp/httpschain/chain.json
166
+ EOT
167
+ wait_for = [" gen_test_cert" ]
168
+ }
169
+
142
170
# # Test against the conformance server.
143
171
# # TODO: Replace this with CT Hammer when it is ready.
144
172
step {
145
173
id = " curl_test"
146
174
name = " curlimages/curl"
147
175
script = << EOT
148
- curl -iX POST $(cat /workspace/conformance_url)/ci-${ var . project_id } /ct/v1/add-pre-chain -H "Authorization: Bearer $(cat /workspace/cb_identity)"
176
+ curl -i -X POST --data @/tmp/httpschain/chain.json -H "Content-Type: application/json" -H "Authorization: Bearer $(cat /workspace/cb_identity)" $(cat /workspace/ conformance_url)/ci-${ var . project_id } /ct/v1/add-pre-chain
149
177
EOT
150
- wait_for = [" bearer_token" ]
178
+ wait_for = [" bearer_token" , " prepare_add_chain_request_body " ]
151
179
}
152
180
153
181
# # Destroy the deployment/live/gcp/ci terragrunt config.
0 commit comments