2019-05-14 18:07:29 +00:00
|
|
|
package dump
|
2018-12-20 15:39:48 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2023-05-28 09:35:55 +00:00
|
|
|
|
|
|
|
rtest "github.com/restic/restic/internal/test"
|
2018-12-20 15:39:48 +00:00
|
|
|
)
|
|
|
|
|
2023-05-28 09:35:55 +00:00
|
|
|
func TestFormatLinuxACL(t *testing.T) {
|
|
|
|
for _, c := range []struct {
|
|
|
|
in, out, err string
|
2018-12-20 15:39:48 +00:00
|
|
|
}{
|
|
|
|
{
|
2023-05-28 09:35:55 +00:00
|
|
|
in: "\x02\x00\x00\x00\x01\x00\x06\x00\xff\xff\xff\xff\x02\x00" +
|
|
|
|
"\x04\x00\x03\x00\x00\x00\x02\x00\x04\x00\xe9\x03\x00\x00" +
|
|
|
|
"\x04\x00\x02\x00\xff\xff\xff\xff\b\x00\x01\x00'\x00\x00\x00" +
|
|
|
|
"\x10\x00\a\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff",
|
|
|
|
out: "user::rw-\nuser:3:r--\nuser:1001:r--\ngroup::-w-\n" +
|
|
|
|
"group:39:--x\nmask::rwx\nother::r--\n",
|
2020-10-24 16:26:30 +00:00
|
|
|
},
|
2018-12-20 15:39:48 +00:00
|
|
|
{
|
2023-05-28 09:35:55 +00:00
|
|
|
in: "\x02\x00\x00\x00\x00\x00\x06\x00\xff\xff\xff\xff\x02\x00" +
|
|
|
|
"\x04\x00\x03\x00\x00\x00\x02\x00\x04\x00\xe9\x03\x00\x00" +
|
|
|
|
"\x04\x00\x06\x00\xff\xff\xff\xff\b\x00\x05\x00'\x00\x00\x00" +
|
|
|
|
"\x10\x00\a\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff",
|
|
|
|
err: "unknown tag",
|
2018-12-20 15:39:48 +00:00
|
|
|
},
|
|
|
|
{
|
2023-05-28 09:35:55 +00:00
|
|
|
in: "\x01\x00\x00\x00\x01\x00\x06\x00\xff\xff\xff\xff\x02\x00" +
|
|
|
|
"\x04\x00\x03\x00\x00\x00\x02\x00\x04\x00\xe9\x03\x00\x00" +
|
|
|
|
"\x04\x00\x06\x00\xff\xff\xff\xff\b\x00\x05\x00'\x00\x00\x00" +
|
|
|
|
"\x10\x00\a\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff",
|
|
|
|
err: "unsupported ACL format version",
|
2018-12-20 15:39:48 +00:00
|
|
|
},
|
2023-05-28 09:35:55 +00:00
|
|
|
{in: "\x02\x00", err: "wrong length"},
|
|
|
|
{in: "", err: "wrong length"},
|
|
|
|
} {
|
|
|
|
out, err := formatLinuxACL([]byte(c.in))
|
|
|
|
if c.err == "" {
|
|
|
|
rtest.Equals(t, c.out, out)
|
|
|
|
} else {
|
|
|
|
rtest.Assert(t, err != nil, "wanted %q but got nil", c.err)
|
|
|
|
rtest.Equals(t, c.err, err.Error())
|
|
|
|
}
|
2018-12-20 15:39:48 +00:00
|
|
|
}
|
|
|
|
}
|