test(aa-log): update tests to the last changes.

This commit is contained in:
Alexandre Pujol 2024-09-27 12:20:48 +01:00
parent e1f665aec1
commit a8c18f9b94
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
4 changed files with 50 additions and 41 deletions

View file

@ -118,14 +118,20 @@ func (r *File) String() string {
}
func (r *File) Validate() error {
if r.Path == "" && r.Target == "" && len(r.Access) == 0 {
return nil // rule: `file` or `owner file`
}
if !isAARE(r.Path) {
return fmt.Errorf("'%s' is not a valid AARE", r.Path)
}
if len(r.Access) == 0 {
return fmt.Errorf("missing file access")
}
for _, v := range r.Access {
if v == "" {
continue
}
if !slices.Contains(requirements[r.Kind()]["access"], v) ||
if !slices.Contains(requirements[r.Kind()]["access"], v) &&
!slices.Contains(requirements[r.Kind()]["transition"], v) {
return fmt.Errorf("invalid mode '%s'", v)
}