@@ -56,7 +56,8 @@ def test_connection_secure():
56
56
@staticmethod
57
57
@raises (DataJointError )
58
58
def test_remove_object_exception ():
59
- #https://github.com/datajoint/datajoint-python/issues/952
59
+ # https://github.com/datajoint/datajoint-python/issues/952
60
+
60
61
# Initialize minioClient with an endpoint and access/secret keys.
61
62
minio_client = Minio (
62
63
'minio:9000' ,
@@ -65,8 +66,11 @@ def test_remove_object_exception():
65
66
secure = False )
66
67
67
68
minio_admin = minio .MinioAdmin (target = 'myminio' )
69
+
70
+ # Create new user
68
71
minio_admin .user_add (access_key = 'jeffjeff' , secret_key = 'jeffjeff' )
69
72
73
+ # json for test policy for permissionless user
70
74
testpolicy = {
71
75
"Version" : "2012-10-17" ,
72
76
"Statement" : [
@@ -98,22 +102,33 @@ def test_remove_object_exception():
98
102
}
99
103
]
100
104
}
105
+
106
+ # Write test json to tmp directory so we can use it to create a new user policy
101
107
with open ('/tmp/policy.json' , 'w' ) as f :
102
108
f .write (json .dumps (testpolicy ))
109
+
110
+ # Add the policy and apply it to the user
103
111
minio_admin .policy_add (policy_name = 'test' , policy_file = '/tmp/policy.json' )
104
112
minio_admin .policy_set (policy_name = 'test' , user = 'jeffjeff' )
105
113
106
-
114
+ # Insert some test data and remove it so that the external table is populated
107
115
test = [1 ,[1 ,2 ,3 ]]
108
116
SimpleRemote .insert1 (test )
109
117
SimpleRemote .delete ()
110
-
118
+
119
+ # Save the old external table minio client
120
+ old_client = schema .external ['share' ].s3 .client
121
+
122
+ # Apply our new minio client to the external table that has permissions restrictions
111
123
schema .external ['share' ].s3 .client = minio_client
124
+
112
125
# This method returns a list of errors
113
126
error_list = schema .external ['share' ].delete (delete_external_files = True , errors_as_string = False )
114
- raise error_list [0 ][2 ]
115
-
116
-
117
127
118
-
128
+ # Teardown
129
+ minio_admin .user_remove (access_key = 'jeffjeff' )
130
+ minio_admin .policy_remove ('test' )
131
+ schema .external ['share' ].s3 .client = old_client
119
132
133
+ # Raise the error we want
134
+ raise error_list [0 ][2 ]
0 commit comments