mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(s3): virtual-hosted style addressing support (#805)
*.s3.localhost.floci.io, *.localhost.localstack.cloud, and
*.s3.localhost.localstack.cloud as virtual-hosted style regardless of
FLOCI_HOSTNAME — fixes 405 when SDK uses endpointOverride("http://localhost:4566")
without forcePathStyle (closes #801)
- EmbeddedDnsServer ships localhost.localstack.cloud and localhost.floci.io
as built-in suffixes so spawned containers resolve these domains to Floci's
IP without extra config
- Compatibility test S3VirtualHostStyleTest covers the full virtual-host path
end-to-end; TestFixtures.s3VirtualHostClient() prefers s3.localhost.floci.io,
falls back to s3.localhost.localstack.cloud, or uses FLOCI_S3_VHOST_ENDPOINT
in Docker
- run-docker-tests.sh and compatibility.yml inject --dns <floci-ip> and
FLOCI_S3_VHOST_ENDPOINT=http://floci:4566 into test containers
- S3 and migrate-from-localstack docs updated with virtual-hosted style details
This commit is contained in:
1 parent
ec9631e8c5
commit
c8c77c9e6e
11 files changed
+462
-15
No files matched your search
+65
-1
@@ -17,7 +17,7 @@ class EmbeddedDnsServerTest {
|
||||
dns = new EmbeddedDnsServer(List.of("localhost.floci.io"));
|
||||
}
|
||||
|
||||
// ── matchesSuffix ─────────────────────────────────────────────────────────
|
||||
// ── matchesSuffix — configured suffix ────────────────────────────────────
|
||||
|
||||
@Test
|
||||
void matchesSuffix_exactMatch() {
|
||||
@@ -49,12 +49,76 @@ class EmbeddedDnsServerTest {
|
||||
assertFalse(dns.matchesSuffix("floci.io"));
|
||||
}
|
||||
|
||||
// bare *.floci.io (without localhost.) must NOT match — only *.localhost.floci.io is registered
|
||||
@Test
|
||||
void matchesSuffix_bareFlociIoSubdomainNoMatch() {
|
||||
assertFalse(dns.matchesSuffix("my-bucket.floci.io"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_bareS3FlociIoNoMatch() {
|
||||
assertFalse(dns.matchesSuffix("s3.floci.io"));
|
||||
}
|
||||
|
||||
// bare *.localstack.cloud (without localhost.) must NOT match either
|
||||
@Test
|
||||
void matchesSuffix_bareLocalstackCloudNoMatch() {
|
||||
assertFalse(dns.matchesSuffix("my-bucket.localstack.cloud"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_nullAndEmpty() {
|
||||
assertFalse(dns.matchesSuffix(null));
|
||||
assertFalse(dns.matchesSuffix(""));
|
||||
}
|
||||
|
||||
// ── matchesSuffix — built-in emulator domains ─────────────────────────────
|
||||
|
||||
@Test
|
||||
void matchesSuffix_localhostFlociIo_exact() {
|
||||
assertTrue(dns.matchesSuffix("localhost.floci.io"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_localhostFlociIo_subdomain() {
|
||||
assertTrue(dns.matchesSuffix("my-bucket.localhost.floci.io"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_s3LocalhostFlociIo() {
|
||||
assertTrue(dns.matchesSuffix("s3.localhost.floci.io"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_bucketS3LocalhostFlociIo() {
|
||||
assertTrue(dns.matchesSuffix("my-bucket.s3.localhost.floci.io"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_localhostLocalstackCloud_exact() {
|
||||
assertTrue(dns.matchesSuffix("localhost.localstack.cloud"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_localhostLocalstackCloud_subdomain() {
|
||||
assertTrue(dns.matchesSuffix("my-bucket.localhost.localstack.cloud"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_s3LocalhostLocalstackCloud() {
|
||||
assertTrue(dns.matchesSuffix("s3.localhost.localstack.cloud"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_bucketS3LocalhostLocalstackCloud() {
|
||||
assertTrue(dns.matchesSuffix("my-bucket.s3.localhost.localstack.cloud"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchesSuffix_bucketS3RegionLocalstackCloud() {
|
||||
assertTrue(dns.matchesSuffix("my-bucket.s3.us-east-1.localhost.localstack.cloud"));
|
||||
}
|
||||
|
||||
// ── readName ──────────────────────────────────────────────────────────────
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,11 +24,26 @@ class S3VirtualHostFilterTest {
|
||||
// K8s-style service hostname with FLOCI_HOSTNAME set
|
||||
"my-bucket.floci.default.svc.cluster.local, floci.default.svc.cluster.local, my-bucket",
|
||||
"my-bucket.floci-svc.namespace.svc, floci-svc.namespace.svc, my-bucket",
|
||||
// localhost is always recognized regardless of baseHostname (fixes virtual-host when FLOCI_HOSTNAME=floci)
|
||||
"my-bucket.localhost, floci, my-bucket",
|
||||
"my-bucket.localhost:4566, floci, my-bucket",
|
||||
// AWS S3 domains (fallback — independent of baseHostname)
|
||||
"my-bucket.s3.amazonaws.com, localhost, my-bucket",
|
||||
"my-bucket.s3.amazonaws.com:443, localhost, my-bucket",
|
||||
"my-bucket.s3.us-east-1.amazonaws.com, localhost, my-bucket",
|
||||
"my-bucket.s3.eu-west-1.amazonaws.com:443, localhost, my-bucket",
|
||||
// LocalStack-compatible domains (*.localhost.localstack.cloud resolves to 127.0.0.1 via public DNS)
|
||||
"my-bucket.s3.localhost.localstack.cloud, localhost, my-bucket",
|
||||
"my-bucket.s3.localhost.localstack.cloud:4566, localhost, my-bucket",
|
||||
"my-bucket.s3.us-east-1.localhost.localstack.cloud, localhost, my-bucket",
|
||||
"my-bucket.localhost.localstack.cloud, localhost, my-bucket",
|
||||
"my-bucket.localhost.localstack.cloud:4566, localhost, my-bucket",
|
||||
// Floci public wildcard DNS (*.s3.localhost.floci.io and *.localhost.floci.io resolve to 127.0.0.1)
|
||||
"my-bucket.s3.localhost.floci.io, localhost, my-bucket",
|
||||
"my-bucket.s3.localhost.floci.io:4566, localhost, my-bucket",
|
||||
"my-bucket.localhost.floci.io, localhost, my-bucket",
|
||||
"my-bucket.localhost.floci.io:4566, localhost, my-bucket",
|
||||
"my-bucket.s3.us-east-1.localhost.floci.io, localhost, my-bucket",
|
||||
})
|
||||
void extractsBucketFromVirtualHostedStyle(String host, String baseHostname, String expectedBucket) {
|
||||
assertEquals(expectedBucket, S3VirtualHostFilter.extractBucket(host, baseHostname));
|
||||
@@ -73,9 +88,17 @@ class S3VirtualHostFilterTest {
|
||||
|
||||
@Test
|
||||
void returnsNullForNullBaseHostname() {
|
||||
// Without a baseHostname, only AWS S3 domains should match
|
||||
assertNull(S3VirtualHostFilter.extractBucket("my-bucket.localhost:4566", null));
|
||||
// path-style bare hostname (no subdomain) — must return null
|
||||
assertNull(S3VirtualHostFilter.extractBucket("localhost:4566", null));
|
||||
// well-known domains match regardless of baseHostname
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.localhost", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.localhost:4566", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.s3.amazonaws.com", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.s3.localhost.localstack.cloud", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.localhost.localstack.cloud", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.s3.localhost.floci.io", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.s3.us-east-1.localhost.floci.io", null));
|
||||
assertEquals("my-bucket", S3VirtualHostFilter.extractBucket("my-bucket.localhost.floci.io", null));
|
||||
}
|
||||
|
||||
// --- Hostname extraction from URL ---
|
||||
|
||||
Reference in new issue
Block a user