This repository has been archived by the owner on Aug 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_qacls_push.py
64 lines (53 loc) · 2.52 KB
/
test_qacls_push.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
__author__ = 'mbott'
import unittest
import sys
from copy import deepcopy
import qacls_config
import qacls_push
import qumulo.rest.fs as fs
class TestQaclsPush(unittest.TestCase):
def test_process_ace_root_directory(self):
"""The ACL applied to the root directory should not appear inherited"""
ACE = deepcopy(qacls_config.ACE_EVERYONE_RW)
result = qacls_push.process_ace(ACE, is_directory=True, is_root=True)
self.assertEqual(result['flags'], qacls_config.INHERIT_ALL)
def test_process_ace_directory(self):
"""The ACL applied to all non-root dirs should appear inherited"""
ACE = deepcopy(qacls_config.ACE_EVERYONE_RW)
result = qacls_push.process_ace(ACE, is_directory=True, is_root=False)
self.assertEqual(result['flags'], qacls_config.INHERIT_ALL_INHERITED)
def test_process_ace_file(self):
"""The ACL applied to files should just show inherited, since you can't
inherit from files"""
ACE = deepcopy(qacls_config.ACE_EVERYONE_RW)
result = qacls_push.process_ace(ACE, is_file=True)
self.assertEqual(result['flags'], qacls_config.INHERITED)
def test_process_directory_without_login(self):
"""process_directory() should work if our bearer token is borked"""
sys.argv = ['./qacls_push.py', '/', '-a', 'ACE_NFSNOBODY_RW']
Q = qacls_push.QaclsCommand()
print Q.credentials.bearer_token
print Q.start_path
Q.credentials.bearer_token = 'borked'
Q.process_directory(Q.start_path)
def test_process_directory_contents_without_login(self):
# TODO: Fix this test (and others) to create/destroy test trees
sys.argv = ['./qacls_push.py', '/', '-a', 'ACE_NFSNOBODY_RW']
#test_file_names = ['a', 'b', 'c', 'd']
Q = qacls_push.QaclsCommand()
# fs.create_directory(Q.connection, Q.credentials, 'test_dir', '/')
# for foo in test_file_names:
# fs.create_file(Q.connection, Q.credentials, foo, '/test_dir/')
response = fs.read_entire_directory(Q.connection,
Q.credentials,
page_size=5000,
path='/test_dir')
print response
print Q.credentials.bearer_token
print Q.start_path
r_list = []
for r in response:
r_list.append(r)
print r_list
Q.credentials.bearer_token = 'borked'
Q.process_directory_contents(r.data['files'], '/test_dir/')