k8s.io/registry.k8s.io@v0.3.1/pkg/net/cidrs/testdatacommon_test.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package cidrs 18 19 import ( 20 "net/netip" 21 ) 22 23 // common test data 24 var testCIDRS = map[string][]netip.Prefix{ 25 "eu-west-3": { 26 netip.MustParsePrefix("35.180.0.0/16"), 27 netip.MustParsePrefix("52.93.127.17/32"), 28 netip.MustParsePrefix("52.93.127.172/31"), 29 }, 30 "us-east-1": { 31 netip.MustParsePrefix("52.93.127.173/32"), 32 }, 33 "us-west-2": { 34 netip.MustParsePrefix("2600:1f01:4874::/47"), 35 netip.MustParsePrefix("52.94.76.0/22"), 36 }, 37 "ap-northeast-1": { 38 netip.MustParsePrefix("52.93.127.174/32"), 39 netip.MustParsePrefix("52.93.127.175/32"), 40 netip.MustParsePrefix("52.93.127.176/32"), 41 netip.MustParsePrefix("52.93.127.177/32"), 42 netip.MustParsePrefix("52.93.127.178/32"), 43 netip.MustParsePrefix("52.93.127.179/32"), 44 }, 45 "ap-southeast-3": { 46 netip.MustParsePrefix("2400:6500:0:9::2/128"), 47 }, 48 } 49 50 // common test cases 51 var testCases = []struct { 52 Addr netip.Addr 53 ExpectedRegion string 54 }{ 55 {Addr: netip.MustParseAddr("35.180.1.1"), ExpectedRegion: "eu-west-3"}, 56 {Addr: netip.MustParseAddr("35.250.1.1"), ExpectedRegion: ""}, 57 {Addr: netip.MustParseAddr("35.0.1.1"), ExpectedRegion: ""}, 58 {Addr: netip.MustParseAddr("52.94.76.1"), ExpectedRegion: "us-west-2"}, 59 {Addr: netip.MustParseAddr("52.94.77.1"), ExpectedRegion: "us-west-2"}, 60 {Addr: netip.MustParseAddr("52.93.127.172"), ExpectedRegion: "eu-west-3"}, 61 // ipv6 62 {Addr: netip.MustParseAddr("2400:6500:0:9::2"), ExpectedRegion: "ap-southeast-3"}, 63 {Addr: netip.MustParseAddr("2400:6500:0:9::1"), ExpectedRegion: ""}, 64 {Addr: netip.MustParseAddr("2400:6500:0:9::3"), ExpectedRegion: ""}, 65 {Addr: netip.MustParseAddr("2600:1f01:4874::47"), ExpectedRegion: "us-west-2"}, 66 }