@@ -29,6 +29,9 @@ var testConfigVarsMin = config.Variables{
2929 "objectstorage_bucket_name" : config .StringVariable (fmt .Sprintf ("tf-acc-test-%s" , acctest .RandStringFromCharSet (20 , acctest .CharSetAlpha ))),
3030 "objectstorage_credentials_group_name" : config .StringVariable (fmt .Sprintf ("tf-acc-test-%s" , acctest .RandStringFromCharSet (20 , acctest .CharSetAlpha ))),
3131 "expiration_timestamp" : config .StringVariable (fmt .Sprintf ("%d-01-02T03:04:05Z" , time .Now ().Year ()+ 1 )),
32+
33+ "objectstorage_bucket_name_with_lock" : config .StringVariable (fmt .Sprintf ("tf-acc-test-%s" , acctest .RandStringFromCharSet (20 , acctest .CharSetAlpha ))),
34+ "object_lock" : config .BoolVariable (true ),
3235}
3336
3437func TestAccObjectStorageResourceMin (t * testing.T ) {
@@ -46,6 +49,7 @@ func TestAccObjectStorageResourceMin(t *testing.T) {
4649 resource .TestCheckResourceAttr ("stackit_objectstorage_bucket.bucket" , "name" , testutil .ConvertConfigVariable (testConfigVarsMin ["objectstorage_bucket_name" ])),
4750 resource .TestCheckResourceAttrSet ("stackit_objectstorage_bucket.bucket" , "url_path_style" ),
4851 resource .TestCheckResourceAttrSet ("stackit_objectstorage_bucket.bucket" , "url_virtual_hosted_style" ),
52+ resource .TestCheckResourceAttr ("stackit_objectstorage_bucket.bucket" , "object_lock" , "false" ),
4953
5054 // Credentials group data
5155 resource .TestCheckResourceAttr ("stackit_objectstorage_credentials_group.credentials_group" , "project_id" , testutil .ConvertConfigVariable (testConfigVarsMin ["project_id" ])),
@@ -85,6 +89,13 @@ func TestAccObjectStorageResourceMin(t *testing.T) {
8589 // compliance lock
8690 resource .TestCheckResourceAttr ("stackit_objectstorage_compliance_lock.compliance_lock" , "project_id" , testutil .ConvertConfigVariable (testConfigVarsMin ["project_id" ])),
8791 resource .TestCheckResourceAttrSet ("stackit_objectstorage_compliance_lock.compliance_lock" , "max_retention_days" ),
92+
93+ // object storage with object lock enabled
94+ resource .TestCheckResourceAttr ("stackit_objectstorage_bucket.bucket_object_lock" , "project_id" , testutil .ConvertConfigVariable (testConfigVarsMin ["project_id" ])),
95+ resource .TestCheckResourceAttr ("stackit_objectstorage_bucket.bucket_object_lock" , "name" , testutil .ConvertConfigVariable (testConfigVarsMin ["objectstorage_bucket_name_with_lock" ])),
96+ resource .TestCheckResourceAttrSet ("stackit_objectstorage_bucket.bucket_object_lock" , "url_path_style" ),
97+ resource .TestCheckResourceAttrSet ("stackit_objectstorage_bucket.bucket_object_lock" , "url_virtual_hosted_style" ),
98+ resource .TestCheckResourceAttr ("stackit_objectstorage_bucket.bucket_object_lock" , "object_lock" , testutil .ConvertConfigVariable (testConfigVarsMin ["object_lock" ])),
8899 ),
89100 },
90101 // Data source
@@ -116,6 +127,10 @@ func TestAccObjectStorageResourceMin(t *testing.T) {
116127 }
117128 data "stackit_objectstorage_compliance_lock" "compliance_lock" {
118129 project_id = stackit_objectstorage_compliance_lock.compliance_lock.project_id
130+ }
131+ data "stackit_objectstorage_bucket" "bucket_object_lock" {
132+ project_id = stackit_objectstorage_bucket.bucket_object_lock.project_id
133+ name = stackit_objectstorage_bucket.bucket_object_lock.name
119134 }` ,
120135 testutil .ObjectStorageProviderConfig ()+ resourceMinConfig ,
121136 ),
@@ -134,6 +149,10 @@ func TestAccObjectStorageResourceMin(t *testing.T) {
134149 "stackit_objectstorage_bucket.bucket" , "url_virtual_hosted_style" ,
135150 "data.stackit_objectstorage_bucket.bucket" , "url_virtual_hosted_style" ,
136151 ),
152+ resource .TestCheckResourceAttrPair (
153+ "stackit_objectstorage_bucket.bucket" , "object_lock" ,
154+ "data.stackit_objectstorage_bucket.bucket" , "object_lock" ,
155+ ),
137156
138157 // Credentials group data
139158 resource .TestCheckResourceAttr ("data.stackit_objectstorage_credentials_group.credentials_group" , "project_id" , testutil .ConvertConfigVariable (testConfigVarsMin ["project_id" ])),
@@ -197,6 +216,25 @@ func TestAccObjectStorageResourceMin(t *testing.T) {
197216 // Compliance lock
198217 resource .TestCheckResourceAttr ("data.stackit_objectstorage_compliance_lock.compliance_lock" , "project_id" , testutil .ConvertConfigVariable (testConfigVarsMin ["project_id" ])),
199218 resource .TestCheckResourceAttrSet ("data.stackit_objectstorage_compliance_lock.compliance_lock" , "max_retention_days" ),
219+
220+ // Bucket data with object lock
221+ resource .TestCheckResourceAttr ("data.stackit_objectstorage_bucket.bucket_object_lock" , "project_id" , testutil .ConvertConfigVariable (testConfigVarsMin ["project_id" ])),
222+ resource .TestCheckResourceAttrPair (
223+ "stackit_objectstorage_bucket.bucket_object_lock" , "name" ,
224+ "data.stackit_objectstorage_bucket.bucket_object_lock" , "name" ,
225+ ),
226+ resource .TestCheckResourceAttrPair (
227+ "stackit_objectstorage_bucket.bucket_object_lock" , "url_path_style" ,
228+ "data.stackit_objectstorage_bucket.bucket_object_lock" , "url_path_style" ,
229+ ),
230+ resource .TestCheckResourceAttrPair (
231+ "stackit_objectstorage_bucket.bucket_object_lock" , "url_virtual_hosted_style" ,
232+ "data.stackit_objectstorage_bucket.bucket_object_lock" , "url_virtual_hosted_style" ,
233+ ),
234+ resource .TestCheckResourceAttrPair (
235+ "stackit_objectstorage_bucket.bucket_object_lock" , "object_lock" ,
236+ "data.stackit_objectstorage_bucket.bucket_object_lock" , "object_lock" ,
237+ ),
200238 ),
201239 },
202240 // Import
0 commit comments