11#! /usr/bin/env bats
22
3- # tags: object-storage
3+ # paths: commands/ object-storage/*
44
5- BATS_LIBS_PATH=" ${LIBS_PATH:- ../ libs} " # fallback to relative path if not set
6- load " ${BATS_LIBS_PATH} /bats-assert/load"
7- load " ${BATS_LIBS_PATH} /bats-support/load"
85load ' ../setup.bats'
96
107
@@ -35,45 +32,45 @@ teardown_file() {
3532# --- validation ---
3633
3734@test " object-storage bucket cors get: missing --name flag returns error" {
38- run ionosctl object-storage bucket cors get 2>&1
35+ run ionosctl object-storage bucket cors get
3936 assert_failure
40- assert_output -p " requires at least 1 option"
37+ assert_stderr -p " requires at least 1 option"
4138}
4239
4340@test " object-storage bucket cors put: missing --name flag returns error" {
44- run ionosctl object-storage bucket cors put 2>&1
41+ run ionosctl object-storage bucket cors put
4542 assert_failure
4643}
4744
4845@test " object-storage bucket cors put: missing --json-properties returns error" {
49- run ionosctl object-storage bucket cors put --name some-bucket 2>&1
46+ run ionosctl object-storage bucket cors put --name some-bucket
5047 assert_failure
51- assert_output -p " requires at least 2 options"
48+ assert_stderr -p " requires at least 2 options"
5249}
5350
5451@test " object-storage bucket cors delete: missing --name flag returns error" {
55- run ionosctl object-storage bucket cors delete 2>&1
52+ run ionosctl object-storage bucket cors delete
5653 assert_failure
57- assert_output -p " requires at least 1 option"
54+ assert_stderr -p " requires at least 1 option"
5855}
5956
6057@test " object-storage bucket cors get: missing S3 credentials returns error" {
6158 run env -u IONOS_S3_ACCESS_KEY -u IONOS_S3_SECRET_KEY \
62- ionosctl object-storage bucket cors get --name some-bucket 2>&1
59+ ionosctl object-storage bucket cors get --name some-bucket
6360 assert_failure
64- assert_output -p " object storage credentials not found"
61+ assert_stderr -p " object storage credentials not found"
6562}
6663
6764@test " object-storage bucket cors put: --json-properties-example prints example JSON" {
68- run ionosctl object-storage bucket cors put --json-properties-example 2> /dev/null
65+ run ionosctl object-storage bucket cors put --json-properties-example
6966 assert_success
7067 assert_output -p " CORSRules"
7168 assert_output -p " AllowedOrigins"
7269 assert_output -p " AllowedMethods"
7370}
7471
7572@test " object-storage bucket cors put: nonexistent file returns error" {
76- run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " /tmp/nonexistent-cors-file.json" 2>&1
73+ run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " /tmp/nonexistent-cors-file.json"
7774 assert_failure
7875}
7976
@@ -84,27 +81,27 @@ teardown_file() {
8481 cat > " $tmpfile " << EOF
8582{"CORSRules":[{"AllowedOrigins":["http://www.example.com"],"AllowedMethods":["GET","PUT","POST"],"AllowedHeaders":["*"],"ExposeHeaders":["x-amz-request-id"],"MaxAgeSeconds":3600}]}
8683EOF
87- run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " $tmpfile " 2> /dev/null
84+ run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " $tmpfile "
8885 rm -f " $tmpfile "
8986 assert_success
9087 assert_output -p " applied successfully"
9188}
9289
9390@test " object-storage bucket cors get: retrieve CORS configuration" {
94- run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME " 2> /dev/null
91+ run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME "
9592 assert_success
9693 assert_output -p " http://www.example.com"
9794 assert_output -p " GET"
9895}
9996
10097@test " object-storage bucket cors delete: remove CORS configuration" {
101- run ionosctl object-storage bucket cors delete --name " $TEST_BUCKET_NAME " -f 2> /dev/null
98+ run ionosctl object-storage bucket cors delete --name " $TEST_BUCKET_NAME " -f
10299 assert_success
103100 assert_output -p " deleted successfully"
104101}
105102
106103@test " object-storage bucket cors get: after delete returns error" {
107- run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME " 2>&1
104+ run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME "
108105 assert_failure
109106}
110107
@@ -115,21 +112,21 @@ EOF
115112 cat > " $tmpfile " << EOF
116113{"CORSRules":[{"AllowedOrigins":["http://example.com"],"AllowedMethods":["GET"],"AllowedHeaders":["Authorization"]},{"AllowedOrigins":["http://other.com"],"AllowedMethods":["POST","DELETE"],"AllowedHeaders":["*"],"MaxAgeSeconds":600}]}
117114EOF
118- run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " $tmpfile " 2> /dev/null
115+ run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " $tmpfile "
119116 rm -f " $tmpfile "
120117 assert_success
121118 assert_output -p " applied successfully"
122119}
123120
124121@test " object-storage bucket cors get: multiple rules display" {
125- run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME " 2> /dev/null
122+ run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME "
126123 assert_success
127124 assert_output -p " http://example.com"
128125 assert_output -p " http://other.com"
129126}
130127
131128@test " object-storage bucket cors delete: cleanup multiple rules" {
132- run ionosctl object-storage bucket cors delete --name " $TEST_BUCKET_NAME " -f 2> /dev/null
129+ run ionosctl object-storage bucket cors delete --name " $TEST_BUCKET_NAME " -f
133130 assert_success
134131}
135132
@@ -151,20 +148,20 @@ EOF
151148 ]
152149}
153150CORS
154- run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " $tmpfile " 2> /dev/null
151+ run ionosctl object-storage bucket cors put --name " $TEST_BUCKET_NAME " --json-properties " $tmpfile "
155152 rm -f " $tmpfile "
156153 assert_success
157154 assert_output -p " applied successfully"
158155}
159156
160157@test " object-storage bucket cors get: file-based config applied correctly" {
161- run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME " 2> /dev/null
158+ run ionosctl object-storage bucket cors get --name " $TEST_BUCKET_NAME "
162159 assert_success
163160 assert_output -p " https://app.example.com"
164161 assert_output -p " Content-Type"
165162}
166163
167164@test " object-storage bucket cors delete: cleanup file-based config" {
168- run ionosctl object-storage bucket cors delete --name " $TEST_BUCKET_NAME " -f 2> /dev/null
165+ run ionosctl object-storage bucket cors delete --name " $TEST_BUCKET_NAME " -f
169166 assert_success
170167}
0 commit comments