Exemple #1
0
    def test_mixedCtor(self):
        testACLs = [{
            "acl": SynoACL.Permissions(),
            "level": 0
        }, {
            "acl": SynoACL.Permissions.fromString("rwx----------"),
            "level": 1
        }, {
            "acl": SynoACL.Permissions.fromString("rwxpdD-------"),
            "level": 1
        }]
        testDirectACLs = list(
            map(lambda entry: entry["acl"],
                filter(lambda entry: entry["level"] == 0, testACLs)))

        allACLs = list(map(lambda entry: entry["acl"], testACLs))
        levels = list(map(lambda entry: entry["level"], testACLs))
        acls = SynoACLSet(allACLs, levels)

        directACLs = acls.getDirect()
        expectedDirectACLCount = sum(1 if entry["level"] == 0 else 0
                                     for entry in testACLs)
        self.assertEqual(len(directACLs), expectedDirectACLCount)
        for i in range(len(directACLs)):
            self.assertEqual(directACLs[i], testDirectACLs[i])

        allACLs = acls.getAll()
        self.assertEqual(len(allACLs), len(allACLs))
        for i in range(len(allACLs)):
            entry = allACLs[i]
            self.assertEqual(entry["acl"], testACLs[i]["acl"])
            self.assertEqual(entry["level"], testACLs[i]["level"])
Exemple #2
0
 def test_get(self):
     acls = SynoACLTool.get(self.testDir)
     expectedACLs = SynoACLSet([
         SynoACL.fromString("user:guest:allow:rwxpd--------:fd--"),
         SynoACL.fromString("group:administrators:allow:rwxpdDaARWc--:fd--")
     ], [0, 1])
     self.assertAclsEqual(acls, expectedACLs)
Exemple #3
0
    def test_onlyDirectCtor(self):
        testACLs = [
            SynoACL.Permissions(),
            SynoACL.Permissions.fromString("rwx----------"),
            SynoACL.Permissions.fromString("rwxpdD-------")
        ]
        acls = SynoACLSet(testACLs)

        directACLs = acls.getDirect()
        self.assertEqual(len(directACLs), len(testACLs))
        for i in range(len(directACLs)):
            self.assertEqual(directACLs[i], testACLs[i])

        allACLs = acls.getAll()
        self.assertEqual(len(allACLs), len(allACLs))
        for i in range(len(allACLs)):
            entry = allACLs[i]
            self.assertEqual(entry["acl"], testACLs[i])
            self.assertEqual(entry["level"], 0)
Exemple #4
0
    def test_onlyDirectCtor(self):
        testACLs = [
            SynoACL.Permissions(),
            SynoACL.Permissions.fromString("rwx----------"),
            SynoACL.Permissions.fromString("rwxpdD-------")
        ]
        acls = SynoACLSet(testACLs)

        directACLs = acls.getDirect()
        self.assertEqual(len(directACLs), len(testACLs))
        for i in range(len(directACLs)):
            self.assertEqual(directACLs[i], testACLs[i])

        allACLs = acls.getAll()
        self.assertEqual(len(allACLs), len(allACLs))
        for i in range(len(allACLs)):
            entry = allACLs[i]
            self.assertEqual(entry["acl"], testACLs[i])
            self.assertEqual(entry["level"], 0)
Exemple #5
0
    def test_mixedCtor(self):
        testACLs = [
            { "acl": SynoACL.Permissions(), "level": 0 },
            { "acl": SynoACL.Permissions.fromString("rwx----------"), "level": 1 },
            { "acl": SynoACL.Permissions.fromString("rwxpdD-------"), "level": 1 }
        ]
        testDirectACLs = list(map(lambda entry: entry["acl"], filter(lambda entry: entry["level"] == 0, testACLs)))

        allACLs = list(map(lambda entry: entry["acl"], testACLs))
        levels = list(map(lambda entry: entry["level"], testACLs))
        acls = SynoACLSet(allACLs, levels)

        directACLs = acls.getDirect()
        expectedDirectACLCount = sum(1 if entry["level"] == 0 else 0 for entry in testACLs)
        self.assertEqual(len(directACLs), expectedDirectACLCount)
        for i in range(len(directACLs)):
            self.assertEqual(directACLs[i], testDirectACLs[i])

        allACLs = acls.getAll()
        self.assertEqual(len(allACLs), len(allACLs))
        for i in range(len(allACLs)):
            entry = allACLs[i]
            self.assertEqual(entry["acl"], testACLs[i]["acl"])
            self.assertEqual(entry["level"], testACLs[i]["level"])
Exemple #6
0
    def test_emptyCtor(self):
        acls = SynoACLSet([])

        self.assertEqual(len(acls.getDirect()), 0)
        self.assertEqual(len(acls.getAll()), 0)
Exemple #7
0
    def test_emptyCtor(self):
        acls = SynoACLSet([])

        self.assertEqual(len(acls.getDirect()), 0)
        self.assertEqual(len(acls.getAll()), 0)