|
1 | 1 | from . import S3_CONN_INFO
|
2 |
| -import time |
3 | 2 | from minio import Minio
|
4 |
| -from minio.objectlockconfig import ObjectLockConfig |
5 |
| -from minio.commonconfig import COMPLIANCE, ENABLED, GOVERNANCE |
| 3 | +import minio |
| 4 | +import json |
6 | 5 | import urllib3
|
7 | 6 | import certifi
|
8 | 7 | from nose.tools import assert_true, raises
|
9 |
| - |
10 | 8 | from .schema_external import schema, SimpleRemote
|
11 | 9 | from datajoint.errors import DataJointError
|
12 | 10 |
|
@@ -59,27 +57,63 @@ def test_connection_secure():
|
59 | 57 | @raises(DataJointError)
|
60 | 58 | def test_remove_object_exception():
|
61 | 59 | #https://github.com/datajoint/datajoint-python/issues/952
|
62 |
| - |
63 |
| - # Initialize httpClient with relevant timeout. |
64 |
| - http_client = urllib3.PoolManager( |
65 |
| - timeout=30, cert_reqs='CERT_REQUIRED', |
66 |
| - ca_certs=certifi.where(), |
67 |
| - retries=urllib3.Retry(total=3, backoff_factor=0.2, |
68 |
| - status_forcelist=[ |
69 |
| - 500, 502, |
70 |
| - 503, 504])) |
71 |
| - |
72 | 60 | # Initialize minioClient with an endpoint and access/secret keys.
|
73 | 61 | minio_client = Minio(
|
74 |
| - S3_CONN_INFO['endpoint'], |
75 |
| - access_key=S3_CONN_INFO['access_key'], |
76 |
| - secret_key=S3_CONN_INFO['secret_key'], |
77 |
| - secure=True, |
78 |
| - http_client=http_client) |
| 62 | + 'minio:9000', |
| 63 | + access_key= 'jeffjeff', |
| 64 | + secret_key= 'jeffjeff', |
| 65 | + secure=False) |
| 66 | + |
| 67 | + minio_admin = minio.MinioAdmin(target = 'myminio') |
| 68 | + minio_admin.user_add(access_key = 'jeffjeff', secret_key = 'jeffjeff') |
79 | 69 |
|
| 70 | + testpolicy = { |
| 71 | + "Version": "2012-10-17", |
| 72 | + "Statement": [ |
| 73 | + { |
| 74 | + "Action": [ |
| 75 | + "s3:GetBucketLocation", |
| 76 | + "s3:ListBucket", |
| 77 | + "s3:ListBucketMultipartUploads", |
| 78 | + "s3:ListAllMyBuckets" |
| 79 | + ], |
| 80 | + "Effect": "Allow", |
| 81 | + "Resource": [ |
| 82 | + "arn:aws:s3:::datajoint.test", |
| 83 | + "arn:aws:s3:::datajoint.migrate" |
| 84 | + ], |
| 85 | + "Sid": "" |
| 86 | + }, |
| 87 | + { |
| 88 | + "Action": [ |
| 89 | + "s3:GetObject", |
| 90 | + "s3:ListMultipartUploadParts" |
| 91 | + ], |
| 92 | + "Effect": "Allow", |
| 93 | + "Resource": [ |
| 94 | + "arn:aws:s3:::datajoint.test/*", |
| 95 | + "arn:aws:s3:::datajoint.migrate/*" |
| 96 | + ], |
| 97 | + "Sid": "" |
| 98 | + } |
| 99 | + ] |
| 100 | +} |
| 101 | + with open('/tmp/policy.json', 'w') as f: |
| 102 | + f.write(json.dumps(testpolicy)) |
| 103 | + minio_admin.policy_add(policy_name = 'test', policy_file = '/tmp/policy.json') |
| 104 | + minio_admin.policy_set(policy_name = 'test', user = 'jeffjeff') |
80 | 105 |
|
81 |
| - schema.external['share'].s3.bucket = '' |
82 |
| - schema.external['share'].s3.remove_object('test') |
| 106 | + |
| 107 | + test = [1,[1,2,3]] |
| 108 | + SimpleRemote.insert1(test) |
| 109 | + SimpleRemote.delete() |
| 110 | + |
| 111 | + schema.external['share'].s3.client = minio_client |
| 112 | + # This method returns a list of errors |
| 113 | + error_list = schema.external['share'].delete(delete_external_files = True, errors_as_string = False) |
| 114 | + raise error_list[0][2] |
| 115 | + # schema.external['share'].s3.secret_key = '' |
| 116 | + # schema.external['share'].s3.remove_object('test') |
83 | 117 |
|
84 | 118 |
|
85 | 119 |
|
|
0 commit comments