From 65dd45d688d69219ea5cc8a615ff992351e5fbb4 Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Thu, 26 Sep 2024 12:05:35 +0200 Subject: [PATCH] Add a test of Configure with secrets (#2447) This test is borrowed from https://github.com/pulumi/pulumi-terraform-bridge/pull/2437. These tests would have prevented https://github.com/pulumi/pulumi-terraform-bridge/issues/2439. --- pf/tests/provider_configure_test.go | 90 +++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/pf/tests/provider_configure_test.go b/pf/tests/provider_configure_test.go index 036610680..601e67ee5 100644 --- a/pf/tests/provider_configure_test.go +++ b/pf/tests/provider_configure_test.go @@ -167,3 +167,93 @@ func TestJSONNestedConfigure(t *testing.T) { } }`) } + +func TestJSONNestedConfigureWithSecrets(t *testing.T) { + server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) + require.NoError(t, err) + replay.ReplaySequence(t, server, ` +[ + { + "method": "/pulumirpc.ResourceProvider/Configure", + "request": { + "args": { + "stringConfigProp": { + "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270", + "value": "secret-example" + }, + "mapNestedProp": "{\"k1\":{\"4dabf18193072939515e22adb298388d\":\"1b47061264138c4ac30d75fd1eb44270\",\"value\":1},\"k2\":2}", + "listNestedProps": "[{\"4dabf18193072939515e22adb298388d\":\"1b47061264138c4ac30d75fd1eb44270\",\"value\":true},false]" + } + }, + "response": { + "supportsPreview": true, + "acceptResources": true + } + }, + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:test-stack::basicprogram::testbridge:index/testres:TestConfigRes::r1", + "preview": false + }, + "response": { + "id": "id-1", + "properties": { + "configCopy": "secret-example", + "id": "id-1" + } + } + } +]`) +} + +func TestConfigureWithSecrets(t *testing.T) { + server, err := newProviderServer(t, testprovider.SyntheticTestBridgeProvider()) + require.NoError(t, err) + replay.ReplaySequence(t, server, ` +[ + { + "method": "/pulumirpc.ResourceProvider/Configure", + "request": { + "args": { + "stringConfigProp": { + "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270", + "value": "secret-example" + }, + "mapNestedProp": { + "k1": { + "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270", + "value": 1 + }, + "k2": 2 + }, + "listNestedProps": [ + { + "4dabf18193072939515e22adb298388d": "1b47061264138c4ac30d75fd1eb44270", + "value": true + }, + false + ] + } + }, + "response": { + "supportsPreview": true, + "acceptResources": true + } + }, + { + "method": "/pulumirpc.ResourceProvider/Create", + "request": { + "urn": "urn:pulumi:test-stack::basicprogram::testbridge:index/testres:TestConfigRes::r1", + "preview": false + }, + "response": { + "id": "id-1", + "properties": { + "configCopy": "secret-example", + "id": "id-1" + } + } + } +]`) +}