Skip to content

Commit

Permalink
Finally (?) fix mc issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Sep 25, 2024
1 parent d2b0151 commit bd7f1fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4914,13 +4914,15 @@ def test_write_dataset_s3_put_only(s3_server):

# write dataset with s3 filesystem
host, port, _, _ = s3_server['connection']

_configure_s3_limited_user(s3_server, _minio_put_only_policy,
'test_dataset_limited_user', 'limited123')
fs = S3FileSystem(
access_key='limited',
access_key='test_dataset_limited_user',
secret_key='limited123',
endpoint_override='{}:{}'.format(host, port),
scheme='http'
)
_configure_s3_limited_user(s3_server, _minio_put_only_policy)

table = pa.table([
pa.array(range(20)), pa.array(random.random() for _ in range(20)),
Expand Down Expand Up @@ -4970,7 +4972,7 @@ def test_write_dataset_s3_put_only(s3_server):
scheme='http',
allow_bucket_creation=True,
)
with pytest.raises(OSError, match="Access Denied"):
with pytest.raises(OSError, match="(Access Denied|ACCESS_DENIED)"):
ds.write_dataset(
table, "non-existing-bucket", filesystem=fs,
format="feather", create_dir=True,
Expand Down
5 changes: 3 additions & 2 deletions python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,12 @@ def skip_azure(fs, reason):
@pytest.mark.s3
def test_s3fs_limited_permissions_create_bucket(s3_server):
from pyarrow.fs import S3FileSystem
_configure_s3_limited_user(s3_server, _minio_limited_policy)
_configure_s3_limited_user(s3_server, _minio_limited_policy,
'test_fs_limited_user', 'limited123')
host, port, _, _ = s3_server['connection']

fs = S3FileSystem(
access_key='limited',
access_key='test_fs_limited_user',
secret_key='limited123',
endpoint_override='{}:{}'.format(host, port),
scheme='http'
Expand Down
6 changes: 3 additions & 3 deletions python/pyarrow/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def _run_mc_command(mcdir, *args):
raise ChildProcessError("Could not run mc")


def _configure_s3_limited_user(s3_server, policy):
def _configure_s3_limited_user(s3_server, policy, username, password):
"""
Attempts to use the mc command to configure the minio server
with a special user limited:limited123 which does not have
Expand Down Expand Up @@ -409,11 +409,11 @@ def _configure_s3_limited_user(s3_server, policy):
_wait_for_minio_startup(mcdir, address, access_key, secret_key)
# Create a limited user with a specific policy ...
_run_mc_command(mcdir, 'admin', 'user', 'add',
'myminio/', 'limited', 'limited123')
'myminio/', username, password)
_run_mc_command(mcdir, 'admin', 'policy', 'create',
'myminio/', 'no-create-buckets', policy_path)
_run_mc_command(mcdir, 'admin', 'policy', 'attach',
'myminio/', 'no-create-buckets', '--user', 'limited')
'myminio/', 'no-create-buckets', '--user', username)
# ... and a sample bucket for that user to write to
_run_mc_command(mcdir, 'mb', 'myminio/existing-bucket',
'--ignore-existing')
Expand Down

0 comments on commit bd7f1fa

Please sign in to comment.