diff --git a/python/pyarrow/tests/test_dataset.py b/python/pyarrow/tests/test_dataset.py index 276cd2e78db37..ab181590914d3 100644 --- a/python/pyarrow/tests/test_dataset.py +++ b/python/pyarrow/tests/test_dataset.py @@ -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)), @@ -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, diff --git a/python/pyarrow/tests/test_fs.py b/python/pyarrow/tests/test_fs.py index 1c639412cd1ab..99d82c3cbf023 100644 --- a/python/pyarrow/tests/test_fs.py +++ b/python/pyarrow/tests/test_fs.py @@ -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' diff --git a/python/pyarrow/tests/util.py b/python/pyarrow/tests/util.py index c8ad7687904c6..84215d30ef064 100644 --- a/python/pyarrow/tests/util.py +++ b/python/pyarrow/tests/util.py @@ -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 @@ -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')