|
|
@ -393,8 +393,8 @@ func TestPolicyIsValid(t *testing.T) { |
|
|
|
{case6Policy, true}, |
|
|
|
{case6Policy, true}, |
|
|
|
// Duplicate statement success different effects.
|
|
|
|
// Duplicate statement success different effects.
|
|
|
|
{case7Policy, false}, |
|
|
|
{case7Policy, false}, |
|
|
|
// Duplicate statement error.
|
|
|
|
// Duplicate statement success, duplicate statement dropped.
|
|
|
|
{case8Policy, true}, |
|
|
|
{case8Policy, false}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for i, testCase := range testCases { |
|
|
|
for i, testCase := range testCases { |
|
|
@ -991,6 +991,20 @@ func TestPolicyUnmarshalJSON(t *testing.T) { |
|
|
|
] |
|
|
|
] |
|
|
|
}`) |
|
|
|
}`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case10Policy := Policy{ |
|
|
|
|
|
|
|
ID: "MyPolicyForMyBucket1", |
|
|
|
|
|
|
|
Version: DefaultVersion, |
|
|
|
|
|
|
|
Statements: []Statement{ |
|
|
|
|
|
|
|
NewStatement( |
|
|
|
|
|
|
|
Allow, |
|
|
|
|
|
|
|
NewPrincipal("*"), |
|
|
|
|
|
|
|
NewActionSet(PutObjectAction), |
|
|
|
|
|
|
|
NewResourceSet(NewResource("mybucket", "myobject*")), |
|
|
|
|
|
|
|
condition.NewFunctions(), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case11Data := []byte(`{ |
|
|
|
case11Data := []byte(`{ |
|
|
|
"ID": "MyPolicyForMyBucket1", |
|
|
|
"ID": "MyPolicyForMyBucket1", |
|
|
|
"Version": "2012-10-17", |
|
|
|
"Version": "2012-10-17", |
|
|
@ -1046,8 +1060,8 @@ func TestPolicyUnmarshalJSON(t *testing.T) { |
|
|
|
{case8Data, case8Policy, false}, |
|
|
|
{case8Data, case8Policy, false}, |
|
|
|
// Invalid version error.
|
|
|
|
// Invalid version error.
|
|
|
|
{case9Data, Policy{}, true}, |
|
|
|
{case9Data, Policy{}, true}, |
|
|
|
// Duplicate statement error.
|
|
|
|
// Duplicate statement success, duplicate statement removed.
|
|
|
|
{case10Data, Policy{}, true}, |
|
|
|
{case10Data, case10Policy, false}, |
|
|
|
// Duplicate statement success (Effect differs).
|
|
|
|
// Duplicate statement success (Effect differs).
|
|
|
|
{case11Data, case11Policy, false}, |
|
|
|
{case11Data, case11Policy, false}, |
|
|
|
} |
|
|
|
} |
|
|
@ -1058,12 +1072,12 @@ func TestPolicyUnmarshalJSON(t *testing.T) { |
|
|
|
expectErr := (err != nil) |
|
|
|
expectErr := (err != nil) |
|
|
|
|
|
|
|
|
|
|
|
if expectErr != testCase.expectErr { |
|
|
|
if expectErr != testCase.expectErr { |
|
|
|
t.Fatalf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr) |
|
|
|
t.Errorf("case %v: error: expected: %v, got: %v", i+1, testCase.expectErr, expectErr) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !testCase.expectErr { |
|
|
|
if !testCase.expectErr { |
|
|
|
if !reflect.DeepEqual(result, testCase.expectedResult) { |
|
|
|
if !reflect.DeepEqual(result, testCase.expectedResult) { |
|
|
|
t.Fatalf("case %v: result: expected: %v, got: %v", i+1, testCase.expectedResult, result) |
|
|
|
t.Errorf("case %v: result: expected: %v, got: %v", i+1, testCase.expectedResult, result) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|