mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 15:39:58 +00:00
AUTH-2135: Adds support for IPv6 and tests
This commit is contained in:
29
sshserver/preamble_test.go
Normal file
29
sshserver/preamble_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package sshserver
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHasPort(t *testing.T) {
|
||||
type testCase struct {
|
||||
input string
|
||||
expectedOutput string
|
||||
}
|
||||
|
||||
tests := []testCase{
|
||||
{"localhost", "localhost:22"},
|
||||
{"other.addr:22", "other.addr:22"},
|
||||
{"[2001:db8::1]:8080", "[2001:db8::1]:8080"},
|
||||
{"[::1]", "[::1]:22"},
|
||||
{"2001:0db8:3c4d:0015:0000:0000:1a2f:1234", "[2001:0db8:3c4d:0015:0000:0000:1a2f:1234]:22"},
|
||||
{"::1", "[::1]:22"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
out, err := canonicalizeDest(test.input)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, test.expectedOutput, out)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user