Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rainbow/tests/test_checker.py
blob: ab1992041c10924dcaffb2cb8674e52429e78ace (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from util import Checker
from os import chmod, chown, mkdir, system
from stat import S_IFDIR, S_IFREG
from os import R_OK, W_OK, X_OK

system('rm -rf 321 d321')

open('321', 'w').close()
ck = Checker('321', 500, 500)
chown('321', 500, 500)
chmod('321', 0321)
assert not ck.positive(R_OK, S_IFDIR)
assert     ck.negative(R_OK, S_IFDIR)

assert     ck.positive(W_OK | X_OK, S_IFREG)
assert not ck.negative(W_OK | X_OK, S_IFREG)

mkdir('d321')
chown('d321', 500, 500)
chmod('d321', 0321)
ck = Checker('d321', 500, 500)
assert not ck.positive(R_OK, S_IFREG)
assert     ck.negative(R_OK, S_IFREG)

assert     ck.positive(W_OK | X_OK, S_IFDIR)
assert not ck.negative(W_OK | X_OK, S_IFDIR)





open('241', 'w').close()
ck = Checker('241', 100, 500)
chown('241', 500, 500)
chmod('241', 0241)
assert not ck.positive(W_OK, S_IFDIR)
assert     ck.negative(W_OK, S_IFDIR)

assert     ck.positive(R_OK | X_OK, S_IFREG)
assert not ck.negative(R_OK | X_OK, S_IFREG)

mkdir('d241')
chown('d241', 500, 500)
chmod('d241', 0241)
ck = Checker('d241', 100, 500)
assert not ck.positive(W_OK, S_IFREG)
assert     ck.negative(W_OK, S_IFREG)

assert     ck.positive(R_OK | X_OK, S_IFDIR)
assert not ck.negative(R_OK | X_OK, S_IFDIR)