MCPcopy
hub / github.com/minio/minio-go / TestPostPolicySetCondition

Function TestPostPolicySetCondition

post-policy_test.go:186–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestPostPolicySetCondition(t *testing.T) {
187 tests := []struct {
188 name string
189 matchType string
190 condition string
191 value string
192 wantErr bool
193 wantResult string
194 }{
195 {
196 name: "valid eq condition",
197 matchType: "eq",
198 condition: "X-Amz-Date",
199 value: "20210324T000000Z",
200 wantResult: `"eq","$X-Amz-Date","20210324T000000Z"`,
201 },
202 {
203 name: "empty value",
204 matchType: "eq",
205 condition: "X-Amz-Date",
206 value: "",
207 wantErr: true,
208 },
209 {
210 name: "invalid condition",
211 matchType: "eq",
212 condition: "Invalid-Condition",
213 value: "somevalue",
214 wantErr: true,
215 },
216 {
217 name: "valid starts-with condition",
218 matchType: "starts-with",
219 condition: "X-Amz-Credential",
220 value: "my-access-key",
221 wantResult: `"starts-with","$X-Amz-Credential","my-access-key"`,
222 },
223 {
224 name: "empty condition",
225 matchType: "eq",
226 condition: "",
227 value: "somevalue",
228 wantErr: true,
229 },
230 {
231 name: "empty matchType",
232 matchType: "",
233 condition: "X-Amz-Date",
234 value: "somevalue",
235 wantErr: true,
236 },
237 }
238 for _, tt := range tests {
239 t.Run(tt.name, func(t *testing.T) {
240 pp := NewPostPolicy()
241
242 err := pp.SetCondition(tt.matchType, tt.condition, tt.value)
243 if (err != nil) != tt.wantErr {

Callers

nothing calls this directly

Calls 4

SetConditionMethod · 0.95
StringMethod · 0.95
NewPostPolicyFunction · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected