simplify further bucket configuration properly (#9650)

This PR is a continuation from #9586, now the
entire parsing logic is fully merged into
bucket metadata sub-system, simplify the
quota API further by reducing the remove
quota handler implementation.
This commit is contained in:
Harshavardhana
2020-05-20 10:18:15 -07:00
committed by GitHub
parent 0cc2ed04f5
commit 6656fa3066
22 changed files with 372 additions and 594 deletions

View File

@@ -27,8 +27,7 @@ import (
)
func TestPolicySysIsAllowed(t *testing.T) {
policySys := NewPolicySys()
policySys.bucketPolicyMap["mybucket"] = &policy.Policy{
p := &policy.Policy{
Version: policy.DefaultVersion,
Statements: []policy.Statement{
policy.NewStatement(
@@ -121,22 +120,21 @@ func TestPolicySysIsAllowed(t *testing.T) {
}
testCases := []struct {
policySys *PolicySys
args policy.Args
expectedResult bool
}{
{policySys, anonGetBucketLocationArgs, true},
{policySys, anonPutObjectActionArgs, true},
{policySys, anonGetObjectActionArgs, false},
{policySys, getBucketLocationArgs, true},
{policySys, putObjectActionArgs, true},
{policySys, getObjectActionArgs, true},
{policySys, yourbucketAnonGetObjectActionArgs, false},
{policySys, yourbucketGetObjectActionArgs, true},
{anonGetBucketLocationArgs, true},
{anonPutObjectActionArgs, true},
{anonGetObjectActionArgs, false},
{getBucketLocationArgs, true},
{putObjectActionArgs, true},
{getObjectActionArgs, true},
{yourbucketAnonGetObjectActionArgs, false},
{yourbucketGetObjectActionArgs, true},
}
for i, testCase := range testCases {
result := testCase.policySys.IsAllowed(testCase.args)
result := p.IsAllowed(testCase.args)
if result != testCase.expectedResult {
t.Fatalf("case %v: expected: %v, got: %v\n", i+1, testCase.expectedResult, result)