| 1 | package accesscontrolscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 5 | |
| 6 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/" |
| 7 | ) |
| 8 | |
| 9 | func TestACLValidate_WithValidACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TestACLValidate_WithValidACL().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 10 | acl := ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#{ |
| 11 | Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.: []ACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#{ |
| 12 | { |
| 13 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeUserscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeUser., |
| 14 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "rwx", |
| 15 | }, |
| 16 | { |
| 17 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeGroupscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeGroup., |
| 18 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "r-x", |
| 19 | }, |
| 20 | { |
| 21 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeOtherscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeOther., |
| 22 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "---", |
| 23 | }, |
| 24 | }, |
| 25 | } |
| 26 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, acl.Validatescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Validate().(), "Expected ACE to Validate successfully") |
| 27 | } |
| 28 | |
| 29 | func TestACLValidate_WithInvalidACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TestACLValidate_WithInvalidACL().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 30 | acl := ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#{ |
| 31 | Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.: []ACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#{ |
| 32 | { |
| 33 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagType#("wibble"), |
| 34 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "rwx", |
| 35 | }, |
| 36 | { |
| 37 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeGroupscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeGroup., |
| 38 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "r-x", |
| 39 | }, |
| 40 | { |
| 41 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeOtherscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeOther., |
| 42 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "---", |
| 43 | }, |
| 44 | }, |
| 45 | } |
| 46 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Error().(t, acl.Validatescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Validate().(), "Expected ACE to fail to Validate") |
| 47 | } |
| 48 | |
| 49 | func TestACLStringscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TestACLString().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 50 | acl := ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#{ |
| 51 | Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.: []ACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#{ |
| 52 | { |
| 53 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeUserscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeUser., |
| 54 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "rwx", |
| 55 | }, |
| 56 | { |
| 57 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeGroupscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeGroup., |
| 58 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "r-x", |
| 59 | }, |
| 60 | { |
| 61 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeOtherscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeOther., |
| 62 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "---", |
| 63 | }, |
| 64 | }, |
| 65 | } |
| 66 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().(t, "user::rwx,group::r-x,other::---", acl.Stringscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#String().()) |
| 67 | } |
| 68 | |
| 69 | func TestACLParse_WithValidACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TestACLParse_WithValidACL().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 70 | expected := ACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#{ |
| 71 | Entriesscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACL#Entries.: []ACEscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#{ |
| 72 | { |
| 73 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeUserscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeUser., |
| 74 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "rwx", |
| 75 | }, |
| 76 | { |
| 77 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeGroupscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeGroup., |
| 78 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "r-x", |
| 79 | }, |
| 80 | { |
| 81 | TagTypescip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#TagType.: TagTypeOtherscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TagTypeOther., |
| 82 | Permissionsscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ACE#Permissions.: "---", |
| 83 | }, |
| 84 | }, |
| 85 | } |
| 86 | acl, err := ParseACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ParseACL().("user::rwx,group::r-x,other::---") |
| 87 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Nil().(t, err, "Expected ACE to parse successfully") |
| 88 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/Equal().(t, expected, acl) |
| 89 | } |
| 90 | |
| 91 | func TestACLParse_WithInvalidACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/TestACLParse_WithInvalidACL().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 92 | _, err := ParseACLscip-go gomod github.com/tombuildsstuff/giovanni . `github.com/tombuildsstuff/giovanni/storage/accesscontrol`/ParseACL().("user:rwx,group::r-x,other::---") |
| 93 | assertscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.3.0 `github.com/stretchr/testify/assert`/EqualError().(t, err, "ACE string should have either 3 or 4 parts") |
| 94 | } |