forked from TrueCloudLab/frostfs-s3-gw
parent
b2bf81cec7
commit
42ed6a16ea
7 changed files with 560 additions and 52 deletions
|
@ -1,7 +1,9 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -43,3 +45,44 @@ func TestCheckBucketName(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCustomJSONMarshal(t *testing.T) {
|
||||
data := []byte(`
|
||||
{ "expiration": "2015-12-30T12:00:00.000Z",
|
||||
"conditions": [
|
||||
["content-length-range", 1048576, 10485760],
|
||||
{"bucket": "bucketName"},
|
||||
["starts-with", "$key", "user/user1/"]
|
||||
]
|
||||
}`)
|
||||
|
||||
parsedTime, err := time.Parse(time.RFC3339, "2015-12-30T12:00:00.000Z")
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedPolicy := &postPolicy{
|
||||
Expiration: parsedTime,
|
||||
Conditions: []*policyCondition{
|
||||
{
|
||||
Matching: "content-length-range",
|
||||
Key: "1048576",
|
||||
Value: "10485760",
|
||||
},
|
||||
{
|
||||
Matching: "eq",
|
||||
Key: "bucket",
|
||||
Value: "bucketName",
|
||||
},
|
||||
{
|
||||
Matching: "starts-with",
|
||||
Key: "key",
|
||||
Value: "user/user1/",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
policy := &postPolicy{}
|
||||
err = json.Unmarshal(data, policy)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, expectedPolicy, policy)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue