Tests validate Google Cloud end point validator.
(t *testing.T)
| 251 | |
| 252 | // Tests validate Google Cloud end point validator. |
| 253 | func TestIsGoogleEndpoint(t *testing.T) { |
| 254 | testCases := []struct { |
| 255 | url string |
| 256 | // Expected result. |
| 257 | result bool |
| 258 | }{ |
| 259 | {"192.168.1.1", false}, |
| 260 | {"https://192.168.1.1", false}, |
| 261 | {"s3.amazonaws.com", false}, |
| 262 | {"http://s3.amazonaws.com", false}, |
| 263 | {"https://s3.amazonaws.com", false}, |
| 264 | {"https://s3.cn-north-1.amazonaws.com.cn", false}, |
| 265 | {"-192.168.1.1", false}, |
| 266 | {"260.192.1.1", false}, |
| 267 | // valid inputs. |
| 268 | {"http://storage.googleapis.com", true}, |
| 269 | {"https://storage.googleapis.com", true}, |
| 270 | {"http://storage.googleapis.com:80", true}, |
| 271 | {"https://storage.googleapis.com:443", true}, |
| 272 | } |
| 273 | |
| 274 | for i, testCase := range testCases { |
| 275 | u, err := url.Parse(testCase.url) |
| 276 | if err != nil { |
| 277 | t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err) |
| 278 | } |
| 279 | result := IsGoogleEndpoint(*u) |
| 280 | if testCase.result != result { |
| 281 | t.Errorf("Test %d: Expected isGoogleEndpoint to be '%v' for input \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.url, result) |
| 282 | } |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | func TestPercentEncodeSlash(t *testing.T) { |
| 287 | testCases := []struct { |
nothing calls this directly
no test coverage detected