| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package auth | 5 package auth |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net" | 9 "net" |
| 10 "testing" | 10 "testing" |
| 11 | 11 |
| 12 . "github.com/luci/luci-go/common/testing/assertions" | 12 . "github.com/luci/luci-go/common/testing/assertions" |
| 13 . "github.com/smartystreets/goconvey/convey" | 13 . "github.com/smartystreets/goconvey/convey" |
| 14 ) | 14 ) |
| 15 | 15 |
| 16 func TestParseRemoteIP(t *testing.T) { | 16 func TestParseRemoteIP(t *testing.T) { |
| 17 t.Parallel() |
| 18 |
| 17 Convey(`Test suites`, t, func() { | 19 Convey(`Test suites`, t, func() { |
| 18 for _, tc := range []struct { | 20 for _, tc := range []struct { |
| 19 v string | 21 v string |
| 20 exp string | 22 exp string |
| 21 err string | 23 err string |
| 22 }{ | 24 }{ |
| 23 {"", net.IPv6loopback.String(), ""}, | 25 {"", net.IPv6loopback.String(), ""}, |
| 24 {"1.2.3.4", "1.2.3.4", ""}, | 26 {"1.2.3.4", "1.2.3.4", ""}, |
| 25 {"1.2.3.4:1337", "1.2.3.4", ""}, | 27 {"1.2.3.4:1337", "1.2.3.4", ""}, |
| 26 {"1::1", "1::1", ""}, | 28 {"1::1", "1::1", ""}, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 }) | 43 }) |
| 42 } else { | 44 } else { |
| 43 Convey(fmt.Sprintf(`Fails to parse %q with %q.`,
tc.v, tc.err), func() { | 45 Convey(fmt.Sprintf(`Fails to parse %q with %q.`,
tc.v, tc.err), func() { |
| 44 _, err := parseRemoteIP(tc.v) | 46 _, err := parseRemoteIP(tc.v) |
| 45 So(err, ShouldErrLike, tc.err) | 47 So(err, ShouldErrLike, tc.err) |
| 46 }) | 48 }) |
| 47 } | 49 } |
| 48 } | 50 } |
| 49 }) | 51 }) |
| 50 } | 52 } |
| OLD | NEW |