@@ -48,6 +48,37 @@ func TestParseS3Host(t *testing.T) {
4848 wantVirtual : true ,
4949 wantBucketName : "my-test-bucket-123" ,
5050 },
51+ // nip.io DNS service patterns
52+ {
53+ name : "virtual-hosted with nip.io" ,
54+ host : "my-bucket.s3.127.0.0.1.nip.io" ,
55+ wantVirtual : true ,
56+ wantBucketName : "my-bucket" ,
57+ },
58+ {
59+ name : "virtual-hosted with nip.io and port" ,
60+ host : "my-bucket.s3.127.0.0.1.nip.io:8000" ,
61+ wantVirtual : true ,
62+ wantBucketName : "my-bucket" ,
63+ },
64+ {
65+ name : "virtual-hosted with sslip.io" ,
66+ host : "my-bucket.s3.127.0.0.1.sslip.io" ,
67+ wantVirtual : true ,
68+ wantBucketName : "my-bucket" ,
69+ },
70+ {
71+ name : "path-style with nip.io" ,
72+ host : "s3.127.0.0.1.nip.io" ,
73+ wantVirtual : false ,
74+ wantBucketName : "" ,
75+ },
76+ {
77+ name : "path-style with nip.io and port" ,
78+ host : "s3.127.0.0.1.nip.io:8000" ,
79+ wantVirtual : false ,
80+ wantBucketName : "" ,
81+ },
5182 // Path-style patterns (not virtual-hosted)
5283 {
5384 name : "path-style s3.infraspec.sh" ,
@@ -130,8 +161,11 @@ func TestIsS3VirtualHostedRequest(t *testing.T) {
130161 {"virtual-hosted bucket.s3.domain" , "my-bucket.s3.infraspec.sh" , true },
131162 {"virtual-hosted bucket.s3.localhost" , "my-bucket.s3.localhost" , true },
132163 {"legacy bucket.localhost" , "my-bucket.localhost" , true },
164+ {"virtual-hosted nip.io" , "my-bucket.s3.127.0.0.1.nip.io" , true },
165+ {"virtual-hosted sslip.io" , "my-bucket.s3.127.0.0.1.sslip.io" , true },
133166 {"path-style s3.domain" , "s3.infraspec.sh" , false },
134167 {"path-style s3.localhost" , "s3.localhost" , false },
168+ {"path-style nip.io" , "s3.127.0.0.1.nip.io" , false },
135169 {"empty" , "" , false },
136170 {"localhost" , "localhost" , false },
137171 {"other service" , "dynamodb.infraspec.sh" , false },
@@ -160,6 +194,12 @@ func TestIsS3Request(t *testing.T) {
160194 {"path-style s3.domain" , "s3.infraspec.sh" , true },
161195 {"path-style s3.localhost" , "s3.localhost" , true },
162196 {"path-style with port" , "s3.localhost:8000" , true },
197+ // nip.io DNS service patterns
198+ {"virtual-hosted nip.io" , "my-bucket.s3.127.0.0.1.nip.io" , true },
199+ {"virtual-hosted nip.io with port" , "my-bucket.s3.127.0.0.1.nip.io:8000" , true },
200+ {"virtual-hosted sslip.io" , "my-bucket.s3.127.0.0.1.sslip.io" , true },
201+ {"path-style nip.io" , "s3.127.0.0.1.nip.io" , true },
202+ {"path-style nip.io with port" , "s3.127.0.0.1.nip.io:8000" , true },
163203 // Non-S3 requests
164204 {"empty" , "" , false },
165205 {"plain localhost" , "localhost" , false },
@@ -188,8 +228,12 @@ func TestExtractBucketNameFromHost(t *testing.T) {
188228 {"virtual-hosted bucket.s3.localhost" , "my-bucket.s3.localhost" , "my-bucket" },
189229 {"legacy bucket.localhost" , "my-bucket.localhost" , "my-bucket" },
190230 {"with port" , "my-bucket.s3.localhost:8000" , "my-bucket" },
231+ {"virtual-hosted nip.io" , "my-bucket.s3.127.0.0.1.nip.io" , "my-bucket" },
232+ {"virtual-hosted nip.io with port" , "my-bucket.s3.127.0.0.1.nip.io:8000" , "my-bucket" },
233+ {"virtual-hosted sslip.io" , "my-bucket.s3.127.0.0.1.sslip.io" , "my-bucket" },
191234 {"path-style s3.domain" , "s3.infraspec.sh" , "" },
192235 {"path-style s3.localhost" , "s3.localhost" , "" },
236+ {"path-style nip.io" , "s3.127.0.0.1.nip.io" , "" },
193237 {"empty" , "" , "" },
194238 {"localhost" , "localhost" , "" },
195239 {"other service" , "dynamodb.infraspec.sh" , "" },
0 commit comments