@@ -121,6 +121,90 @@ func TestResourceSecretCreate(t *testing.T) {
121121 assert .Equal (t , "foo|||bar" , d .Id ())
122122}
123123
124+ func TestResourceSecretCreate_WriteOnlyValue (t * testing.T ) {
125+ d , err := qa.ResourceFixture {
126+ Fixtures : []qa.HTTPFixture {
127+ {
128+ Method : "POST" ,
129+ Resource : "/api/2.0/secrets/put" ,
130+ ExpectedRequest : workspace.PutSecret {
131+ StringValue : "SparkIsTh3Be$t" ,
132+ Scope : "foo" ,
133+ Key : "bar" ,
134+ },
135+ },
136+ {
137+ Method : "GET" ,
138+ Resource : "/api/2.0/secrets/list?scope=foo" ,
139+ Response : workspace.ListSecretsResponse {
140+ Secrets : []workspace.SecretMetadata {
141+ {
142+ Key : "bar" ,
143+ LastUpdatedTimestamp : 12345678 ,
144+ },
145+ },
146+ },
147+ },
148+ },
149+ Resource : ResourceSecret (),
150+ State : map [string ]any {
151+ "scope" : "foo" ,
152+ "key" : "bar" ,
153+ "string_value_wo" : "SparkIsTh3Be$t" ,
154+ "string_value_wo_version" : 1 ,
155+ },
156+ Create : true ,
157+ }.Apply (t )
158+ assert .NoError (t , err )
159+ assert .Equal (t , "foo|||bar" , d .Id ())
160+ assert .Equal (t , "" , d .Get ("string_value" ))
161+ }
162+
163+ func TestResourceSecretUpdate_WriteOnlyValueVersionChange (t * testing.T ) {
164+ d , err := qa.ResourceFixture {
165+ Fixtures : []qa.HTTPFixture {
166+ {
167+ Method : "POST" ,
168+ Resource : "/api/2.0/secrets/put" ,
169+ ExpectedRequest : workspace.PutSecret {
170+ StringValue : "SparkIsTh3Be$t-v2" ,
171+ Scope : "foo" ,
172+ Key : "bar" ,
173+ },
174+ },
175+ {
176+ Method : "GET" ,
177+ Resource : "/api/2.0/secrets/list?scope=foo" ,
178+ Response : workspace.ListSecretsResponse {
179+ Secrets : []workspace.SecretMetadata {
180+ {
181+ Key : "bar" ,
182+ LastUpdatedTimestamp : 12345679 ,
183+ },
184+ },
185+ },
186+ },
187+ },
188+ Resource : ResourceSecret (),
189+ InstanceState : map [string ]string {
190+ "scope" : "foo" ,
191+ "key" : "bar" ,
192+ "string_value_wo_version" : "1" ,
193+ },
194+ State : map [string ]any {
195+ "scope" : "foo" ,
196+ "key" : "bar" ,
197+ "string_value_wo" : "SparkIsTh3Be$t-v2" ,
198+ "string_value_wo_version" : 2 ,
199+ },
200+ Update : true ,
201+ ID : "foo|||bar" ,
202+ }.Apply (t )
203+ assert .NoError (t , err )
204+ assert .Equal (t , "foo|||bar" , d .Id ())
205+ assert .Equal (t , 12345679 , d .Get ("last_updated_timestamp" ))
206+ }
207+
124208func TestResourceSecretCreate_Error (t * testing.T ) {
125209 d , err := qa.ResourceFixture {
126210 Fixtures : []qa.HTTPFixture {
0 commit comments