From c85470c34150fcfb88af50bc9d25fcf83f60caf7 Mon Sep 17 00:00:00 2001 From: Allan Roger Reid Date: Tue, 15 Sep 2026 16:05:13 +0000 Subject: [PATCH 1/6] Run unit tests in localeTest task The localeTest task is registered with tasks.register('localeTest', Test) but sets neither testClassesDirs nor classpath, so Gradle reports NO-SOURCE and the de-DE run executes no tests. Point the task at the test source set so it runs the same unit tests as the test task under locale de-DE. --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index ea462d43e..62cd5ee1c 100644 --- a/build.gradle +++ b/build.gradle @@ -101,6 +101,10 @@ subprojects { tasks.register('localeTest', Test) { description = 'Runs tests with locale de-DE' + // A Test task registered this way has no test classes of its own; without these two + // lines it reports NO-SOURCE and runs nothing. + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath systemProperty 'user.language', 'de' systemProperty 'user.country', 'DE' } From be7efdc803ed9fd3f7558163b54a2502a0c33e5f Mon Sep 17 00:00:00 2001 From: Allan Roger Reid Date: Tue, 15 Sep 2026 16:05:14 +0000 Subject: [PATCH 2/6] Read bucket quota from size field in getBucketQuota Current AIStor returns the bucket quota limit as "size" and no longer sends the deprecated "quota" key, so getBucketQuota threw "quota not found in response" on every call. Read "size" and fall back to "quota" when size is missing or zero, the same rule the server applies when it parses a quota. Add MinioAdminClientTest covering size, legacy quota, zero, missing and non-integral responses. --- .../java/io/minio/admin/MinioAdminClient.java | 10 +- .../io/minio/admin/MinioAdminClientTest.java | 92 +++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java diff --git a/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java b/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java index 6e3c3ec50..e42446ac0 100644 --- a/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java +++ b/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java @@ -471,7 +471,15 @@ public long getBucketQuota(String bucketName) throws MinioException { .getTypeFactory() .constructMapType(HashMap.class, String.class, JsonNode.class); Map quotaEntity = OBJECT_MAPPER.readValue(response.body().bytes(), mapType); - JsonNode quota = quotaEntity.get("quota"); + // Servers built with madmin-go v4 send the limit only as "size"; madmin-go v3 servers send + // both "size" and the deprecated "quota". Take the first non-zero of the two, the same rule + // the server applies when it parses a quota. + JsonNode quota = quotaEntity.get("size"); + JsonNode legacyQuota = quotaEntity.get("quota"); + if (quota == null + || (legacyQuota != null && quota.isIntegralNumber() && quota.longValue() == 0)) { + quota = legacyQuota; + } if (quota == null) throw new MinioException("quota not found in response"); // JsonNode.asLong() coerces anything non-numeric to zero, making a malformed response // indistinguishable from a cleared quota; reject such values instead. diff --git a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java new file mode 100644 index 000000000..a3d01bd5d --- /dev/null +++ b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java @@ -0,0 +1,92 @@ +/* + * MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2026 MinIO, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.minio.admin; + +import io.minio.errors.MinioException; +import java.io.IOException; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.Assert; +import org.junit.Test; + +public class MinioAdminClientTest { + private static long getBucketQuota(String responseBody) + throws IOException, InterruptedException, MinioException { + MockWebServer server = new MockWebServer(); + try { + server.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody)); + server.start(); + MinioAdminClient client = + MinioAdminClient.builder() + .endpoint(server.url("")) + .credentials("minio", "minio123") + .build(); + long quota = client.getBucketQuota("my-bucket"); + Assert.assertEquals( + "/minio/admin/v3/get-bucket-quota?bucket=my-bucket", server.takeRequest().getPath()); + return quota; + } finally { + server.shutdown(); + } + } + + @Test + public void testGetBucketQuotaSize() throws IOException, InterruptedException, MinioException { + Assert.assertEquals( + 1048576L, + getBucketQuota("{\"size\":1048576,\"rate\":0,\"requests\":0,\"quotatype\":\"hard\"}")); + } + + @Test + public void testGetBucketQuotaLegacyQuotaWithZeroSize() + throws IOException, InterruptedException, MinioException { + Assert.assertEquals( + 2048L, + getBucketQuota( + "{\"quota\":2048,\"size\":0,\"rate\":0,\"requests\":0,\"quotatype\":\"hard\"}")); + } + + @Test + public void testGetBucketQuotaLegacyQuotaOnly() + throws IOException, InterruptedException, MinioException { + Assert.assertEquals(2048L, getBucketQuota("{\"quota\":2048,\"quotatype\":\"hard\"}")); + } + + @Test + public void testGetBucketQuotaPrefersNonZeroSize() + throws IOException, InterruptedException, MinioException { + Assert.assertEquals( + 4096L, getBucketQuota("{\"quota\":2048,\"size\":4096,\"quotatype\":\"hard\"}")); + } + + @Test + public void testGetBucketQuotaZeroSize() + throws IOException, InterruptedException, MinioException { + Assert.assertEquals(0L, getBucketQuota("{\"size\":0,\"rate\":0,\"requests\":0}")); + } + + @Test(expected = MinioException.class) + public void testGetBucketQuotaMissing() throws IOException, InterruptedException, MinioException { + getBucketQuota("{\"quotatype\":\"hard\"}"); + } + + @Test(expected = MinioException.class) + public void testGetBucketQuotaNonIntegral() + throws IOException, InterruptedException, MinioException { + getBucketQuota("{\"size\":\"1048576\",\"quotatype\":\"hard\"}"); + } +} From c07ed92b1a549afd94bd2cdf307f4424ffc78418 Mon Sep 17 00:00:00 2001 From: Allan Roger Reid Date: Wed, 16 Sep 2026 00:07:31 +0000 Subject: [PATCH 3/6] Show full test failures from every Test task localeTest now runs the unit tests and, in ./gradlew build, runs before test. A failure there printed only the exception class and file:line, because the testLogging settings applied to the test task alone. Apply the same testLogging settings to every Test task. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 62cd5ee1c..9878e0fb8 100644 --- a/build.gradle +++ b/build.gradle @@ -89,7 +89,7 @@ subprojects { } } - test { + tasks.withType(Test).configureEach { // Show stacktrace on test failure than opening in web browser. testLogging { exceptionFormat = 'full' From 30cfe7a824da359c9b4235a7a7ab78b97c5313f4 Mon Sep 17 00:00:00 2001 From: Allan Roger Reid Date: Wed, 16 Sep 2026 00:07:32 +0000 Subject: [PATCH 4/6] Cover bucket quota response shapes and add a live round trip Pin the integral check in getBucketQuota's size fallback with a test for a non-integral size next to a legacy quota. Describe the response shapes in the comment: servers built with madmin-go v4 send only size; servers built with an earlier madmin-go send quota, and also size once madmin-go added that field, left at 0 when the quota was set through quota. Add a set/get/clear bucket quota round trip to the admin functional tests, so CI's live AIStor run catches the next change to that response. --- .../java/io/minio/admin/MinioAdminClient.java | 6 ++-- .../io/minio/admin/MinioAdminClientTest.java | 9 +++++- functional/TestMinioAdminClient.java | 28 +++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java b/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java index e42446ac0..7929d975d 100644 --- a/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java +++ b/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java @@ -471,9 +471,9 @@ public long getBucketQuota(String bucketName) throws MinioException { .getTypeFactory() .constructMapType(HashMap.class, String.class, JsonNode.class); Map quotaEntity = OBJECT_MAPPER.readValue(response.body().bytes(), mapType); - // Servers built with madmin-go v4 send the limit only as "size"; madmin-go v3 servers send - // both "size" and the deprecated "quota". Take the first non-zero of the two, the same rule - // the server applies when it parses a quota. + // Servers built with madmin-go v4 send the limit only as "size". Servers built with an + // earlier madmin-go send "quota", plus "size" once madmin-go added it, left at 0 when the + // quota was set through "quota". Take the first non-zero of the two. JsonNode quota = quotaEntity.get("size"); JsonNode legacyQuota = quotaEntity.get("quota"); if (quota == null diff --git a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java index a3d01bd5d..759ade39a 100644 --- a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java +++ b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java @@ -1,5 +1,6 @@ /* - * MinIO Java SDK for Amazon S3 Compatible Cloud Storage, (C) 2026 MinIO, Inc. + * MinIO Java SDK for Amazon S3 Compatible Cloud Storage, + * (C) 2026 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,4 +90,10 @@ public void testGetBucketQuotaNonIntegral() throws IOException, InterruptedException, MinioException { getBucketQuota("{\"size\":\"1048576\",\"quotatype\":\"hard\"}"); } + + @Test(expected = MinioException.class) + public void testGetBucketQuotaNonIntegralSizeWithLegacyQuota() + throws IOException, InterruptedException, MinioException { + getBucketQuota("{\"size\":\"1048576\",\"quota\":2048,\"quotatype\":\"hard\"}"); + } } diff --git a/functional/TestMinioAdminClient.java b/functional/TestMinioAdminClient.java index 04208fcda..9a0008f71 100644 --- a/functional/TestMinioAdminClient.java +++ b/functional/TestMinioAdminClient.java @@ -15,7 +15,11 @@ * limitations under the License. */ +import io.minio.MakeBucketArgs; +import io.minio.MinioClient; +import io.minio.RemoveBucketArgs; import io.minio.admin.MinioAdminClient; +import io.minio.admin.QuotaUnit; import io.minio.admin.Status; import io.minio.admin.UserInfo; import java.util.Map; @@ -141,6 +145,29 @@ public void deleteUser() throws Exception { } } + public void setGetClearBucketQuota() throws Exception { + String methodName = "setBucketQuota()/getBucketQuota()/clearBucketQuota()"; + if (!MINT_ENV) System.out.println(methodName); + long startTime = System.currentTimeMillis(); + + String bucketName = getRandomName(); + MinioClient s3Client = + MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build(); + try { + s3Client.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); + try { + client.setBucketQuota(bucketName, 1, QuotaUnit.MB); + Assertions.assertEquals(QuotaUnit.MB.toBytes(1), client.getBucketQuota(bucketName)); + client.clearBucketQuota(bucketName); + Assertions.assertEquals(0L, client.getBucketQuota(bucketName)); + } finally { + s3Client.removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build()); + } + } catch (Exception e) { + handleException(methodName, null, startTime, e); + } + } + public void runAdminTests() throws Exception { addUser(); addCannedPolicy(); @@ -150,5 +177,6 @@ public void runAdminTests() throws Exception { listCannedPolicies(); deleteUser(); removeCannedPolicy(); + setGetClearBucketQuota(); } } From e47827ecd75e83cb1547c7da41757def445bb08b Mon Sep 17 00:00:00 2001 From: Allan Roger Reid Date: Wed, 16 Sep 2026 10:02:18 +0000 Subject: [PATCH 5/6] Read and write bucket quota as size only MinioAdminClient follows the current server API and is not backward compatible by design. The BucketQuota type in madmin-go v4 has no quota field, so getBucketQuota now reads only size and setBucketQuota sends size. Drop the legacy quota fallback and its tests. A size that is missing, not an integer, or outside the long range is still rejected. Add tests for a fractional and an out-of-range size, and for the key that setBucketQuota and clearBucketQuota send. --- .../java/io/minio/admin/MinioAdminClient.java | 10 +-- .../io/minio/admin/MinioAdminClientTest.java | 87 ++++++++++++------- 2 files changed, 58 insertions(+), 39 deletions(-) diff --git a/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java b/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java index 7929d975d..31bcec824 100644 --- a/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java +++ b/adminapi/src/main/java/io/minio/admin/MinioAdminClient.java @@ -440,7 +440,7 @@ public void setBucketQuota(@Nonnull String bucketName, long size, @Nonnull Quota throws MinioException { Map quotaEntity = new HashMap<>(); if (size > 0) quotaEntity.put("quotatype", "hard"); - quotaEntity.put("quota", unit.toBytes(size)); + quotaEntity.put("size", unit.toBytes(size)); try (Response response = execute( Http.Method.PUT, @@ -471,15 +471,7 @@ public long getBucketQuota(String bucketName) throws MinioException { .getTypeFactory() .constructMapType(HashMap.class, String.class, JsonNode.class); Map quotaEntity = OBJECT_MAPPER.readValue(response.body().bytes(), mapType); - // Servers built with madmin-go v4 send the limit only as "size". Servers built with an - // earlier madmin-go send "quota", plus "size" once madmin-go added it, left at 0 when the - // quota was set through "quota". Take the first non-zero of the two. JsonNode quota = quotaEntity.get("size"); - JsonNode legacyQuota = quotaEntity.get("quota"); - if (quota == null - || (legacyQuota != null && quota.isIntegralNumber() && quota.longValue() == 0)) { - quota = legacyQuota; - } if (quota == null) throw new MinioException("quota not found in response"); // JsonNode.asLong() coerces anything non-numeric to zero, making a malformed response // indistinguishable from a cleared quota; reject such values instead. diff --git a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java index 759ade39a..5ab357744 100644 --- a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java +++ b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java @@ -17,26 +17,35 @@ package io.minio.admin; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import io.minio.errors.MinioException; import java.io.IOException; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; import org.junit.Assert; import org.junit.Test; public class MinioAdminClientTest { + private interface QuotaCall { + void run(MinioAdminClient client) throws MinioException; + } + + private static MinioAdminClient client(MockWebServer server) { + return MinioAdminClient.builder() + .endpoint(server.url("")) + .credentials("minio", "minio123") + .build(); + } + private static long getBucketQuota(String responseBody) throws IOException, InterruptedException, MinioException { MockWebServer server = new MockWebServer(); try { server.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody)); server.start(); - MinioAdminClient client = - MinioAdminClient.builder() - .endpoint(server.url("")) - .credentials("minio", "minio123") - .build(); - long quota = client.getBucketQuota("my-bucket"); + long quota = client(server).getBucketQuota("my-bucket"); Assert.assertEquals( "/minio/admin/v3/get-bucket-quota?bucket=my-bucket", server.takeRequest().getPath()); return quota; @@ -45,33 +54,27 @@ private static long getBucketQuota(String responseBody) } } - @Test - public void testGetBucketQuotaSize() throws IOException, InterruptedException, MinioException { - Assert.assertEquals( - 1048576L, - getBucketQuota("{\"size\":1048576,\"rate\":0,\"requests\":0,\"quotatype\":\"hard\"}")); - } - - @Test - public void testGetBucketQuotaLegacyQuotaWithZeroSize() - throws IOException, InterruptedException, MinioException { - Assert.assertEquals( - 2048L, - getBucketQuota( - "{\"quota\":2048,\"size\":0,\"rate\":0,\"requests\":0,\"quotatype\":\"hard\"}")); - } - - @Test - public void testGetBucketQuotaLegacyQuotaOnly() + private static JsonNode sentQuota(QuotaCall call) throws IOException, InterruptedException, MinioException { - Assert.assertEquals(2048L, getBucketQuota("{\"quota\":2048,\"quotatype\":\"hard\"}")); + MockWebServer server = new MockWebServer(); + try { + server.enqueue(new MockResponse().setResponseCode(200)); + server.start(); + call.run(client(server)); + RecordedRequest request = server.takeRequest(); + Assert.assertEquals("PUT", request.getMethod()); + Assert.assertEquals("/minio/admin/v3/set-bucket-quota?bucket=my-bucket", request.getPath()); + return new ObjectMapper().readTree(request.getBody().readUtf8()); + } finally { + server.shutdown(); + } } @Test - public void testGetBucketQuotaPrefersNonZeroSize() - throws IOException, InterruptedException, MinioException { + public void testGetBucketQuotaSize() throws IOException, InterruptedException, MinioException { Assert.assertEquals( - 4096L, getBucketQuota("{\"quota\":2048,\"size\":4096,\"quotatype\":\"hard\"}")); + 1048576L, + getBucketQuota("{\"size\":1048576,\"rate\":0,\"requests\":0,\"quotatype\":\"hard\"}")); } @Test @@ -92,8 +95,32 @@ public void testGetBucketQuotaNonIntegral() } @Test(expected = MinioException.class) - public void testGetBucketQuotaNonIntegralSizeWithLegacyQuota() + public void testGetBucketQuotaFractional() + throws IOException, InterruptedException, MinioException { + getBucketQuota("{\"size\":1.5,\"quotatype\":\"hard\"}"); + } + + @Test(expected = MinioException.class) + public void testGetBucketQuotaOutOfRange() + throws IOException, InterruptedException, MinioException { + getBucketQuota("{\"size\":18446744073709551616,\"quotatype\":\"hard\"}"); + } + + @Test + public void testSetBucketQuotaSendsSize() + throws IOException, InterruptedException, MinioException { + JsonNode sent = sentQuota(client -> client.setBucketQuota("my-bucket", 1, QuotaUnit.MB)); + Assert.assertEquals(1048576L, sent.get("size").longValue()); + Assert.assertEquals("hard", sent.get("quotatype").textValue()); + Assert.assertFalse(sent.has("quota")); + } + + @Test + public void testClearBucketQuotaSendsZeroSize() throws IOException, InterruptedException, MinioException { - getBucketQuota("{\"size\":\"1048576\",\"quota\":2048,\"quotatype\":\"hard\"}"); + JsonNode sent = sentQuota(client -> client.clearBucketQuota("my-bucket")); + Assert.assertEquals(0L, sent.get("size").longValue()); + Assert.assertFalse(sent.has("quotatype")); + Assert.assertFalse(sent.has("quota")); } } From ff76418a33fe6636876f68ab7996c2d153fda400 Mon Sep 17 00:00:00 2001 From: Allan Roger Reid Date: Thu, 17 Sep 2026 12:35:24 +0000 Subject: [PATCH 6/6] Remove the quota unit and functional tests The maintainers sync MinioAdminClient with the server on demand, so tests that pin the server's quota response shape would break whenever the server changes it. Remove MinioAdminClientTest and restore functional/TestMinioAdminClient.java to its master version. --- .../io/minio/admin/MinioAdminClientTest.java | 126 ------------------ functional/TestMinioAdminClient.java | 28 ---- 2 files changed, 154 deletions(-) delete mode 100644 adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java diff --git a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java b/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java deleted file mode 100644 index 5ab357744..000000000 --- a/adminapi/src/test/java/io/minio/admin/MinioAdminClientTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * MinIO Java SDK for Amazon S3 Compatible Cloud Storage, - * (C) 2026 MinIO, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.minio.admin; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.minio.errors.MinioException; -import java.io.IOException; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Assert; -import org.junit.Test; - -public class MinioAdminClientTest { - private interface QuotaCall { - void run(MinioAdminClient client) throws MinioException; - } - - private static MinioAdminClient client(MockWebServer server) { - return MinioAdminClient.builder() - .endpoint(server.url("")) - .credentials("minio", "minio123") - .build(); - } - - private static long getBucketQuota(String responseBody) - throws IOException, InterruptedException, MinioException { - MockWebServer server = new MockWebServer(); - try { - server.enqueue(new MockResponse().setResponseCode(200).setBody(responseBody)); - server.start(); - long quota = client(server).getBucketQuota("my-bucket"); - Assert.assertEquals( - "/minio/admin/v3/get-bucket-quota?bucket=my-bucket", server.takeRequest().getPath()); - return quota; - } finally { - server.shutdown(); - } - } - - private static JsonNode sentQuota(QuotaCall call) - throws IOException, InterruptedException, MinioException { - MockWebServer server = new MockWebServer(); - try { - server.enqueue(new MockResponse().setResponseCode(200)); - server.start(); - call.run(client(server)); - RecordedRequest request = server.takeRequest(); - Assert.assertEquals("PUT", request.getMethod()); - Assert.assertEquals("/minio/admin/v3/set-bucket-quota?bucket=my-bucket", request.getPath()); - return new ObjectMapper().readTree(request.getBody().readUtf8()); - } finally { - server.shutdown(); - } - } - - @Test - public void testGetBucketQuotaSize() throws IOException, InterruptedException, MinioException { - Assert.assertEquals( - 1048576L, - getBucketQuota("{\"size\":1048576,\"rate\":0,\"requests\":0,\"quotatype\":\"hard\"}")); - } - - @Test - public void testGetBucketQuotaZeroSize() - throws IOException, InterruptedException, MinioException { - Assert.assertEquals(0L, getBucketQuota("{\"size\":0,\"rate\":0,\"requests\":0}")); - } - - @Test(expected = MinioException.class) - public void testGetBucketQuotaMissing() throws IOException, InterruptedException, MinioException { - getBucketQuota("{\"quotatype\":\"hard\"}"); - } - - @Test(expected = MinioException.class) - public void testGetBucketQuotaNonIntegral() - throws IOException, InterruptedException, MinioException { - getBucketQuota("{\"size\":\"1048576\",\"quotatype\":\"hard\"}"); - } - - @Test(expected = MinioException.class) - public void testGetBucketQuotaFractional() - throws IOException, InterruptedException, MinioException { - getBucketQuota("{\"size\":1.5,\"quotatype\":\"hard\"}"); - } - - @Test(expected = MinioException.class) - public void testGetBucketQuotaOutOfRange() - throws IOException, InterruptedException, MinioException { - getBucketQuota("{\"size\":18446744073709551616,\"quotatype\":\"hard\"}"); - } - - @Test - public void testSetBucketQuotaSendsSize() - throws IOException, InterruptedException, MinioException { - JsonNode sent = sentQuota(client -> client.setBucketQuota("my-bucket", 1, QuotaUnit.MB)); - Assert.assertEquals(1048576L, sent.get("size").longValue()); - Assert.assertEquals("hard", sent.get("quotatype").textValue()); - Assert.assertFalse(sent.has("quota")); - } - - @Test - public void testClearBucketQuotaSendsZeroSize() - throws IOException, InterruptedException, MinioException { - JsonNode sent = sentQuota(client -> client.clearBucketQuota("my-bucket")); - Assert.assertEquals(0L, sent.get("size").longValue()); - Assert.assertFalse(sent.has("quotatype")); - Assert.assertFalse(sent.has("quota")); - } -} diff --git a/functional/TestMinioAdminClient.java b/functional/TestMinioAdminClient.java index 9a0008f71..04208fcda 100644 --- a/functional/TestMinioAdminClient.java +++ b/functional/TestMinioAdminClient.java @@ -15,11 +15,7 @@ * limitations under the License. */ -import io.minio.MakeBucketArgs; -import io.minio.MinioClient; -import io.minio.RemoveBucketArgs; import io.minio.admin.MinioAdminClient; -import io.minio.admin.QuotaUnit; import io.minio.admin.Status; import io.minio.admin.UserInfo; import java.util.Map; @@ -145,29 +141,6 @@ public void deleteUser() throws Exception { } } - public void setGetClearBucketQuota() throws Exception { - String methodName = "setBucketQuota()/getBucketQuota()/clearBucketQuota()"; - if (!MINT_ENV) System.out.println(methodName); - long startTime = System.currentTimeMillis(); - - String bucketName = getRandomName(); - MinioClient s3Client = - MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build(); - try { - s3Client.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build()); - try { - client.setBucketQuota(bucketName, 1, QuotaUnit.MB); - Assertions.assertEquals(QuotaUnit.MB.toBytes(1), client.getBucketQuota(bucketName)); - client.clearBucketQuota(bucketName); - Assertions.assertEquals(0L, client.getBucketQuota(bucketName)); - } finally { - s3Client.removeBucket(RemoveBucketArgs.builder().bucket(bucketName).build()); - } - } catch (Exception e) { - handleException(methodName, null, startTime, e); - } - } - public void runAdminTests() throws Exception { addUser(); addCannedPolicy(); @@ -177,6 +150,5 @@ public void runAdminTests() throws Exception { listCannedPolicies(); deleteUser(); removeCannedPolicy(); - setGetClearBucketQuota(); } }