cli: Fix resource name parsing #1177

Merged
dstepanov-yadro merged 1 commit from aarifullin/frostfs-node:fix/aperule_parser into master 2024-06-14 10:38:31 +00:00
2 changed files with 11 additions and 2 deletions

View file

@ -279,7 +279,7 @@ func parseResource(lexeme string, isObj bool) (string, error) {
if isObj {
if lexeme == "*" {
return nativeschema.ResourceFormatAllObjects, nil
} else if lexeme == "/*" {
} else if lexeme == "/*" || lexeme == "root/*" {
return nativeschema.ResourceFormatRootObjects, nil
} else if strings.HasPrefix(lexeme, "/") {
lexeme = lexeme[1:]

View file

@ -26,7 +26,7 @@ func TestParseAPERule(t *testing.T) {
},
},
{
name: "Valid rule for all objects in root namespace",
name: "Valid rule for all objects in implicit root namespace",
rule: "allow Object.Put /*",
expectRule: policyengine.Rule{
Status: policyengine.Allow,
@ -34,6 +34,15 @@ func TestParseAPERule(t *testing.T) {
Resources: policyengine.Resources{Names: []string{nativeschema.ResourceFormatRootObjects}},
},
},
{
name: "Valid rule for all objects in explicit root namespace",
rule: "allow Object.Put root/*",
expectRule: policyengine.Rule{
Status: policyengine.Allow,
Actions: policyengine.Actions{Names: []string{nativeschema.MethodPutObject}},
Resources: policyengine.Resources{Names: []string{nativeschema.ResourceFormatRootObjects}},
},
},
{
name: "Valid rule for all objects in root namespace and container",
rule: "allow Object.Put /cid/*",