Skip to content

Commit

Permalink
fix: rework permission tests to work around git limitations in permis…
Browse files Browse the repository at this point in the history
…sions storage
  • Loading branch information
omissis committed Oct 26, 2024
1 parent a4fb016 commit 6ea9b1a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions internal/arch/file/expect/have_permissions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Test_HavePermissions(t *testing.T) {
}{
{
desc: "wrong permissions string",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0700.txt")),
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0755.txt")),
permissions: "foobarbaz-",
want: nil,
wantErrs: []error{expect.ErrInvalidPermissions},
Expand All @@ -43,9 +43,9 @@ func Test_HavePermissions(t *testing.T) {
want: nil,
},
{
desc: "permissions of file '0700.txt' match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0700.txt")),
permissions: "-rwx------",
desc: "permissions of file '0755.txt' match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0755.txt")),
permissions: "-rwxr-xr-x",
want: nil,
},
{
Expand All @@ -59,11 +59,11 @@ func Test_HavePermissions(t *testing.T) {
},
},
{
desc: "permissions of file '0700.txt' do not match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0700.txt")),
desc: "permissions of file '0755.txt' do not match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0755.txt")),
permissions: "-rwxrwxrwx",
want: []rule.CoreViolation{
rule.NewCoreViolation("file '0700.txt' does not have permissions matching '-rwxrwxrwx', '-rwx------' found"),
rule.NewCoreViolation("file '0755.txt' does not have permissions matching '-rwxrwxrwx', '-rwxr-xr-x' found"),
},
},
{
Expand All @@ -76,12 +76,12 @@ func Test_HavePermissions(t *testing.T) {
},
},
{
desc: "negated: permissions of file '0700.txt' match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0700.txt")),
permissions: "-rwx------",
desc: "negated: permissions of file '0755.txt' match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0755.txt")),
permissions: "-rwxr-xr-x",
options: []expect.Option{expect.Negated{}},
want: []rule.CoreViolation{
rule.NewCoreViolation("file '0700.txt' does have permissions matching '-rwx------', '-rwx------' found"),
rule.NewCoreViolation("file '0755.txt' does have permissions matching '-rwxr-xr-x', '-rwxr-xr-x' found"),
},
},
{
Expand All @@ -92,9 +92,9 @@ func Test_HavePermissions(t *testing.T) {
want: nil,
},
{
desc: "negated: permissions of file '0700.txt' do not match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0700.txt")),
permissions: "-rwxrwxrwx",
desc: "negated: permissions of file '0755.txt' do not match expected one",
ruleBuilder: file.One(filepath.Join(basePath, "test/permissions/0755.txt")),
permissions: "-rw-r--r--",
options: []expect.Option{expect.Negated{}},
want: nil,
},
Expand Down
1 change: 0 additions & 1 deletion internal/arch/file/expect/test/permissions/0700.txt

This file was deleted.

1 change: 1 addition & 0 deletions internal/arch/file/expect/test/permissions/0755.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0755

0 comments on commit 6ea9b1a

Please sign in to comment.