2021-06-18 10:11:57 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
2021-06-18 10:11:57 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
type testCase struct {
|
|
|
|
input string
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVerifyMultiAddress_Order(t *testing.T) {
|
|
|
|
testCases := []testCase{
|
|
|
|
{
|
|
|
|
input: "/ip4/1.2.3.4/tcp/80",
|
|
|
|
err: nil,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "/ip6/1.2.3.4/tcp/80",
|
|
|
|
err: nil,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "/dns4/1.2.3.4/tcp/80",
|
|
|
|
err: nil,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "/dns4/1.2.3.4/tcp/80/tls",
|
|
|
|
err: nil,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "/tls/dns4/1.2.3.4/tcp/80",
|
|
|
|
err: errUnsupportedNetworkProtocol,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "/dns4/1.2.3.4/tls/tcp/80",
|
|
|
|
err: errUnsupportedTransportProtocol,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
input: "/dns4/1.2.3.4/tcp/80/wss",
|
|
|
|
err: errUnsupportedPresentationProtocol,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
ni := constructNodeInfo(test.input)
|
|
|
|
|
|
|
|
if test.err != nil {
|
|
|
|
require.EqualError(t, test.err, VerifyMultiAddress(ni).Error())
|
|
|
|
} else {
|
|
|
|
require.NoError(t, VerifyMultiAddress(ni))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:18:26 +00:00
|
|
|
func constructNodeInfo(address string) (ni netmap.NodeInfo) {
|
|
|
|
ni.SetNetworkEndpoints(address)
|
2021-06-18 10:11:57 +00:00
|
|
|
return ni
|
|
|
|
}
|