MCPcopy
hub / github.com/minio/minio-go / TestIsAmazonEndpoint

Function TestIsAmazonEndpoint

pkg/s3utils/utils_test.go:209–250  ·  view source on GitHub ↗

Tests validate Amazon endpoint validator.

(t *testing.T)

Source from the content-addressed store, hash-verified

207
208// Tests validate Amazon endpoint validator.
209func TestIsAmazonEndpoint(t *testing.T) {
210 testCases := []struct {
211 url string
212 // Expected result.
213 result bool
214 }{
215 {"https://192.168.1.1", false},
216 {"192.168.1.1", false},
217 {"http://storage.googleapis.com", false},
218 {"https://storage.googleapis.com", false},
219 {"storage.googleapis.com", false},
220 {"s3.amazonaws.com", false},
221 {"https://amazons3.amazonaws.com", false},
222 {"-192.168.1.1", false},
223 {"260.192.1.1", false},
224 {"https://s3-.amazonaws.com", false},
225 {"https://s3..amazonaws.com", false},
226 {"https://s3.dualstack.us-west-1.amazonaws.com.cn", false},
227 {"https://s3..us-west-1.amazonaws.com.cn", false},
228 // valid inputs.
229 {"https://s3.amazonaws.com", true},
230 {"https://s3-external-1.amazonaws.com", true},
231 {"https://s3.cn-north-1.amazonaws.com.cn", true},
232 {"https://s3-us-west-1.amazonaws.com", true},
233 {"https://s3.us-west-1.amazonaws.com", true},
234 {"https://s3.dualstack.us-west-1.amazonaws.com", true},
235 {"https://bucket.vpce-1a2b3c4d-5e6f.s3.us-east-1.vpce.amazonaws.com", true},
236 {"https://accesspoint.vpce-1a2b3c4d-5e6f.s3.us-east-1.vpce.amazonaws.com", true},
237 {"https://s3express-usw2-az1.us-west-2.amazonaws.com", true},
238 }
239
240 for i, testCase := range testCases {
241 u, err := url.Parse(testCase.url)
242 if err != nil {
243 t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err)
244 }
245 result := IsAmazonEndpoint(*u)
246 if testCase.result != result {
247 t.Errorf("Test %d: Expected isAmazonEndpoint to be '%v' for input \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.url, result)
248 }
249 }
250}
251
252// Tests validate Google Cloud end point validator.
253func TestIsGoogleEndpoint(t *testing.T) {

Callers

nothing calls this directly

Calls 1

IsAmazonEndpointFunction · 0.85

Tested by

no test coverage detected