Files
teleport/lib/client/fuzz_test.go
T
rosstimothy 58126ad723 Remove lib/client as a dependency of lib/config (#67257)
Relocates client.ParseLabelSpec to lib/utils/parse. This results in
a net 5MB reduction in the weight of lib/config. This may not
have a correlation in binary size since lib/client is heavily consumed
by other packages.

```bash
$ goda cut './lib/config:all' | rg '^github.com/gravitational/teleport/lib/client\b|^ID'
github.com/gravitational/teleport/lib/client   InDegree=1   Cut.PackageCount=75   Cut.AllFiles.Size=5.3MB   Cut.Go.Lines=129512
```
2026-05-29 15:42:50 +00:00

79 lines
1.9 KiB
Go

/*
* Teleport
* Copyright (C) 2023 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package client
import (
"testing"
"github.com/stretchr/testify/require"
)
func FuzzParseProxyHost(f *testing.F) {
for _, tc := range parseProxyHostTestCases {
f.Add(tc.input)
}
f.Fuzz(func(t *testing.T, proxyHost string) {
require.NotPanics(t, func() {
_, _ = ParseProxyHost(proxyHost)
})
})
}
func FuzzParseSearchKeywords(f *testing.F) {
f.Add("XXXX,YYYY", ',')
f.Add(`XXXX"YYYY`, '"')
f.Add(`"XXXX"`, '"')
f.Add(`XXXX "YYYY" " ZZZZ "`, ' ')
for _, tc := range parseSearchKeywordsTestCases {
f.Add(tc.spec, ',')
}
f.Fuzz(func(t *testing.T, spec string, customDelimiter rune) {
require.NotPanics(t, func() {
_ = ParseSearchKeywords(spec, customDelimiter)
})
})
}
func FuzzParsePortForwardSpec(f *testing.F) {
f.Add("80:XXXX:180")
f.Add("10.0.10.1:443:XXXX:1443")
f.Fuzz(func(t *testing.T, spec string) {
require.NotPanics(t, func() {
_, _ = ParsePortForwardSpec([]string{spec})
})
})
}
func FuzzParseDynamicPortForwardSpec(f *testing.F) {
for _, tc := range dynamicPortForwardParsingTestCases {
if len(tc.spec) == 1 {
f.Add(tc.spec[0])
}
}
f.Fuzz(func(t *testing.T, spec string) {
require.NotPanics(t, func() {
_, _ = ParseDynamicPortForwardSpec([]string{spec})
})
})
}