MCPcopy Create free account
hub / github.com/coder/coder / TestProvision_SafeEnv

Function TestProvision_SafeEnv

provisioner/terraform/provision_test.go:1259–1303  ·  view source on GitHub ↗

nolint:paralleltest

(t *testing.T)

Source from the content-addressed store, hash-verified

1257
1258// nolint:paralleltest
1259func TestProvision_SafeEnv(t *testing.T) {
1260 // #nosec
1261 const (
1262 passedValue = "superautopets"
1263 secretValue = "oinae3uinxase"
1264 )
1265
1266 t.Setenv("VALID_USER_ENV", passedValue)
1267
1268 // We ensure random CODER_ variables aren't passed through to avoid leaking
1269 // control plane secrets (e.g. PG URL).
1270 t.Setenv("CODER_SECRET", secretValue)
1271
1272 const echoResource = `
1273 resource "null_resource" "a" {
1274 provisioner "local-exec" {
1275 command = "env"
1276 }
1277 }
1278
1279 `
1280
1281 ctx, api := setupProvisioner(t, nil)
1282 sess := configure(ctx, t, api, &proto.Config{})
1283
1284 resp := sendInitAndGetResp(t, sess, testutil.CreateTar(t, map[string]string{"main.tf": echoResource}))
1285 require.Empty(t, resp.Error)
1286
1287 err := sendPlan(sess, proto.WorkspaceTransition_START)
1288 require.NoError(t, err)
1289
1290 _, _ = readProvisionLog(t, sess)
1291
1292 err = sendApply(sess, proto.WorkspaceTransition_START)
1293 require.NoError(t, err)
1294
1295 log, applyComplete := readProvisionLog(t, sess)
1296 require.Contains(t, log, passedValue)
1297 require.NotContains(t, log, secretValue)
1298 require.Contains(t, log, "CODER_")
1299 require.Contains(t, log, "AWS_SDK_UA_APP_ID=APN_1.1/pc_cdfmjwn8i6u8l9fwz8h82e4w3$")
1300
1301 apply := applyComplete.Type.(*proto.Response_Apply)
1302 require.NotEmpty(t, apply.Apply.State, "state exists")
1303}
1304
1305func TestProvision_MalformedModules(t *testing.T) {
1306 t.Parallel()

Callers

nothing calls this directly

Calls 11

CreateTarFunction · 0.92
setupProvisionerFunction · 0.85
configureFunction · 0.85
sendInitAndGetRespFunction · 0.85
sendPlanFunction · 0.85
readProvisionLogFunction · 0.85
sendApplyFunction · 0.85
SetenvMethod · 0.80
NotEmptyMethod · 0.80
EmptyMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected