mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
refactor(core): share one UUID-shape check across services (#8446)
This commit is contained in:
1 parent
f5e08d5e9c
commit
b8c08f1be4
14 files changed
+126
-30
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package io.floci.aws.core.common;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class UuidShapesTest {
|
||||
|
||||
@Test
|
||||
void lowerCaseMatchesBoth() {
|
||||
String value = "0f8fad5b-d9cb-469f-a165-70867728950e";
|
||||
|
||||
assertTrue(UuidShapes.matchesEitherCase(value));
|
||||
assertTrue(UuidShapes.matchesLowerCase(value));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"0F8FAD5B-D9CB-469F-A165-70867728950E",
|
||||
"0f8fad5b-D9CB-469f-a165-70867728950e",
|
||||
})
|
||||
void upperCaseDigitsMatchOnlyTheEitherCaseCheck(String value) {
|
||||
assertTrue(UuidShapes.matchesEitherCase(value));
|
||||
assertFalse(UuidShapes.matchesLowerCase(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
void versionAndVariantAreNotRead() {
|
||||
String value = "00000000-0000-0000-0000-000000000000";
|
||||
|
||||
assertTrue(UuidShapes.matchesEitherCase(value));
|
||||
assertTrue(UuidShapes.matchesLowerCase(value));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"",
|
||||
"not-a-uuid",
|
||||
"0f8fad5bd9cb469fa16570867728950e",
|
||||
"0f8fad5-d9cb-469f-a165-70867728950e",
|
||||
"0f8fad5b-d9cb-469f-a165-70867728950",
|
||||
"0f8fad5b-d9cb-469f-a165-70867728950ef",
|
||||
"0f8fad5b-d9cb-469f-a165-70867728950g",
|
||||
"0f8fad5b_d9cb_469f_a165_70867728950e",
|
||||
" 0f8fad5b-d9cb-469f-a165-70867728950e",
|
||||
"0f8fad5b-d9cb-469f-a165-70867728950e\n",
|
||||
"x0f8fad5b-d9cb-469f-a165-70867728950e",
|
||||
"{0f8fad5b-d9cb-469f-a165-70867728950e}",
|
||||
"1-2-3-4-5",
|
||||
"\uFF10f8fad5b-d9cb-469f-a165-70867728950e",
|
||||
})
|
||||
void anythingElseMatchesNeither(String value) {
|
||||
assertFalse(UuidShapes.matchesEitherCase(value));
|
||||
assertFalse(UuidShapes.matchesLowerCase(value));
|
||||
}
|
||||
|
||||
@Test
|
||||
void nullMatchesNeither() {
|
||||
assertFalse(UuidShapes.matchesEitherCase(null));
|
||||
assertFalse(UuidShapes.matchesLowerCase(null));
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,8 @@ class S3InvalidVersionIdIntegrationTest {
|
||||
|
||||
for (String key : List.of(KEY, "missing")) {
|
||||
String path = "/" + BUCKET + "/" + key;
|
||||
for (String versionId : List.of("bogus", "")) {
|
||||
// Floci mints lower-case ids, so the upper-case spelling of one is not a minted id.
|
||||
for (String versionId : List.of("bogus", "", "0F8FAD5B-D9CB-469F-A165-70867728950E")) {
|
||||
String version = "versionId=" + versionId;
|
||||
refused(given().when().get(path + "?" + version), versionId);
|
||||
refused(given().when().delete(path + "?" + version), versionId);
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -377,6 +378,12 @@ class SesExportJobServiceTest {
|
||||
assertEquals(404, notFound.getHttpStatus());
|
||||
assertEquals("Job ID: <" + unknown + "> not found", notFound.getMessage());
|
||||
|
||||
String upperCase = unknown.toUpperCase(Locale.ROOT);
|
||||
AwsException upperCaseNotFound = assertThrows(AwsException.class,
|
||||
() -> service.getExportJob(REGION, upperCase));
|
||||
assertEquals("NotFoundException", upperCaseNotFound.getErrorCode());
|
||||
assertEquals("Job ID: <" + upperCase + "> not found", upperCaseNotFound.getMessage());
|
||||
|
||||
AwsException malformed = assertThrows(AwsException.class,
|
||||
() -> service.getExportJob(REGION, unknown + "0"));
|
||||
assertEquals("BadRequestException", malformed.getErrorCode());
|
||||
|
||||
Reference in new issue
Block a user