github.com/gravitational/teleport/api@v0.0.0-20240507183017-3110591cbafc/utils/azure/fuzz_test.go (about) 1 /* 2 Copyright 2022 Gravitational, Inc. 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 azure 18 19 import ( 20 "testing" 21 22 "github.com/stretchr/testify/require" 23 ) 24 25 func FuzzParseDatabaseEndpoint(f *testing.F) { 26 f.Add("") 27 f.Add("foo") 28 f.Add(":1234") 29 f.Add("foo:1234") 30 f.Add("name.mysql.database.azure.com:1234") 31 32 f.Fuzz(func(t *testing.T, endpoint string) { 33 require.NotPanics(t, func() { 34 ParseDatabaseEndpoint(endpoint) 35 }) 36 }) 37 } 38 39 func FuzzParseCacheForRedisEndpoint(f *testing.F) { 40 f.Add("") 41 f.Add("foo") 42 f.Add("name.redis.cache.windows.net") 43 f.Add("name.redis.cache.windows.net:1234") 44 f.Add("name.region.redisenterprise.cache.azure.net") 45 46 f.Fuzz(func(t *testing.T, endpoint string) { 47 require.NotPanics(t, func() { 48 ParseCacheForRedisEndpoint(endpoint) 49 }) 50 }) 51 } 52 53 func FuzzNormalizeLocation(f *testing.F) { 54 f.Add("") 55 f.Add("foo") 56 f.Add("northcentralusstage") 57 f.Add("North Central US (Stage)") 58 f.Add("(US) North Central US (Stage)") 59 60 f.Fuzz(func(t *testing.T, location string) { 61 require.NotPanics(t, func() { 62 NormalizeLocation(location) 63 }) 64 }) 65 } 66 67 func FuzzParseMSSQLEndpoint(f *testing.F) { 68 f.Add("") 69 f.Add("foo") 70 f.Add(":1234") 71 f.Add("foo:1234") 72 f.Add("name.database.windows.net:1234") 73 f.Add(".database.windows.net:1234") 74 75 f.Fuzz(func(t *testing.T, endpoint string) { 76 require.NotPanics(t, func() { 77 ParseMSSQLEndpoint(endpoint) 78 }) 79 }) 80 }