-
Notifications
You must be signed in to change notification settings - Fork 58
Add test for re-created bucket and bucket policy #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -373,6 +373,12 @@ function initSetup(S3Client $s3Client, $objects) { | |
| $stream->close(); | ||
| } | ||
| } | ||
|
|
||
| // Create an empty bucket for bucket policy + delete tests | ||
| $result = $s3Client->createBucket(['Bucket' => $GLOBALS['emptyBucket']]); | ||
| if (getStatusCode($result) != HTTP_OK) | ||
| throw new Exception("createBucket API failed for " . $bucket); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
@@ -756,6 +762,63 @@ function testBucketPolicy($s3Client, $bucket) { | |
|
|
||
| if ($result['Policy'] != $downloadPolicy) | ||
| throw new Exception('bucket policy we got is not we set'); | ||
|
|
||
| // Delete the bucket, make the bucket (again) and check if policy is none | ||
| // Ref: https://github.com/minio/minio/issues/4714 | ||
| $result = $s3Client->deleteBucket(['Bucket' => $bucket]); | ||
| if (getstatuscode($result) != HTTP_NOCONTENT) | ||
| throw new Exception('deleteBucket API failed for ' . | ||
| $bucket); | ||
|
|
||
| $result = $s3Client->createBucket(['Bucket' => $bucket]); | ||
| if (getstatuscode($result) != HTTP_OK) | ||
| throw new Exception('createBucket API failed for ' . | ||
| $bucket); | ||
|
|
||
| $params = [ | ||
| '404' => ['Bucket' => $bucket] | ||
| ]; | ||
| runExceptionalTests($s3Client, 'getBucketPolicy', 'getStatusCode', $params); | ||
|
|
||
| try { | ||
| $MINT_DATA_DIR = $GLOBALS['MINT_DATA_DIR']; | ||
| // Create an object to test anonymous GET object | ||
| $object = 'test-anon'; | ||
| if (!file_exists($MINT_DATA_DIR . '/' . FILE_10KB)) | ||
| throw new Exception('File not found ' . $MINT_DATA_DIR . '/' . FILE_10KB); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @krisis, I ran your changes on docker minio/mint:latest image and the tests fail for completeMultipartUpload.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @poornas, which version of minio server did you run mint on? I tried it locally with minio commit id
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @krisis, ran this against play server, it is on Version : 2017-06-24T23:30:00Z.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @poornas minio/minio#4642 is fixed in version 2017-07-24T18-27-35Z. This explains why you are seeing the exception. |
||
|
|
||
| $stream = Psr7\stream_for(fopen($MINT_DATA_DIR . '/' . FILE_10KB, 'r')); | ||
| $result = $s3Client->putObject([ | ||
| 'Bucket' => $bucket, | ||
| 'Key' => $object, | ||
| 'Body' => $stream, | ||
| ]); | ||
| if (getstatuscode($result) != HTTP_OK) | ||
| throw new Exception('createBucket API failed for ' . | ||
| $bucket); | ||
|
|
||
| $anonConfig = new ClientConfig("", "", $GLOBALS['endpoint'], $GLOBALS['secure']); | ||
| $anonymousClient = new S3Client([ | ||
| 'credentials' => false, | ||
| 'endpoint' => $anonConfig->endpoint, | ||
| 'use_path_style_endpoint' => true, | ||
| 'region' => 'us-east-1', | ||
| 'version' => '2006-03-01' | ||
| ]); | ||
| runExceptionalTests($anonymousClient, 'getObject', 'getStatusCode', [ | ||
| '403' => [ | ||
| 'Bucket' => $bucket, | ||
| 'Key' => $object, | ||
| ] | ||
| ]); | ||
|
|
||
| } finally { | ||
| // close data file | ||
| if (!is_null($stream)) | ||
| $stream->close(); | ||
| $s3Client->deleteObject(['Bucket' => $bucket, 'Key' => $object]); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -774,8 +837,10 @@ function cleanupSetup($s3Client, $objects) { | |
| $s3Client->deleteObject(['Bucket' => $bucket, 'Key' => $object]); | ||
| } | ||
|
|
||
| // Delete the buckets | ||
| foreach (array_keys($objects) as $bucket) { | ||
| // Delete the buckets incl. emptyBucket | ||
| $allBuckets = array_keys($objects); | ||
| array_push($allBuckets, $GLOBALS['emptyBucket']); | ||
| foreach ($allBuckets as $bucket) { | ||
| // Delete the bucket | ||
| $s3Client->deleteBucket(['Bucket' => $bucket]); | ||
|
|
||
|
|
@@ -811,10 +876,10 @@ function runTestFunction($myfunc, ...$args) { | |
| } | ||
|
|
||
| // Get client configuration from environment variables | ||
| $access_key = getenv("ACCESS_KEY"); | ||
| $secret_key = getenv("SECRET_KEY"); | ||
| $endpoint = getenv("SERVER_ENDPOINT"); | ||
| $secure = getenv("ENABLE_HTTPS"); | ||
| $GLOBALS['access_key'] = getenv("ACCESS_KEY"); | ||
| $GLOBALS['secret_key'] = getenv("SECRET_KEY"); | ||
| $GLOBALS['endpoint'] = getenv("SERVER_ENDPOINT"); | ||
| $GLOBALS['secure'] = getenv("ENABLE_HTTPS"); | ||
|
|
||
| /** | ||
| * @global string $GLOBALS['MINT_DATA_DIR'] | ||
|
|
@@ -825,8 +890,8 @@ function runTestFunction($myfunc, ...$args) { | |
|
|
||
|
|
||
| // Create config object | ||
| $config = new ClientConfig($access_key, $secret_key, $endpoint, $secure); | ||
|
|
||
| $config = new ClientConfig($GLOBALS['access_key'], $GLOBALS['secret_key'], | ||
| $GLOBALS['endpoint'], $GLOBALS['secure']); | ||
|
|
||
| // Create a S3Client | ||
| $s3Client = new S3Client([ | ||
|
|
@@ -837,6 +902,8 @@ function runTestFunction($myfunc, ...$args) { | |
| 'version' => '2006-03-01' | ||
| ]); | ||
|
|
||
| // Used by initSetup | ||
| $emptyBucket = randomName(); | ||
| $objects = [ | ||
| randomName() => 'obj1', | ||
| randomName() => 'obj2', | ||
|
|
@@ -858,7 +925,7 @@ function runTestFunction($myfunc, ...$args) { | |
| runTestFunction('testMultipartUpload', $s3Client, $firstBucket, $firstObject); | ||
| runTestFunction('testMultipartUploadFailure', $s3Client, $firstBucket, $firstObject); | ||
| runTestFunction('testAbortMultipartUpload', $s3Client, $firstBucket, $firstObject); | ||
| runTestFunction('testBucketPolicy', $s3Client, $firstBucket); | ||
| runTestFunction('testBucketPolicy', $s3Client, $emptyBucket); | ||
| } | ||
| finally { | ||
| cleanupSetup($s3Client, $objects); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we programmatically create some data if MINT_DATA_DIR variable is not specified ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not for these . These are part of mint . It's applicable for our SDK tests.