[#1351] cli: Fix connection scheme loss during endpoint parsing

In previous implementation NeoFS CLI app used `network.Address.HostAddr`
as a server URI, which caused scheme loss since host address doesn't
contain it.

Rename `HostAddr` to `URIAddr` and make it to return URI address with
`grpcs` scheme if TLS is enabled. Make `TLSEnabled` unexported since it
was used to provide default `tls.Config` only (it is used by default in
SDK).

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-05-04 15:34:26 +03:00 committed by LeL
parent 3a44010180
commit cd545f0160
11 changed files with 39 additions and 53 deletions

View file

@ -50,12 +50,13 @@ func TestAddress_HostAddrString(t *testing.T) {
}{
{buildMultiaddr("/dns4/neofs.bigcorp.com/tcp/8080", t), "neofs.bigcorp.com:8080"},
{buildMultiaddr("/ip4/172.16.14.1/tcp/8080", t), "172.16.14.1:8080"},
{buildMultiaddr("/ip4/192.168.0.1/tcp/8888/tls", t), "grpcs://192.168.0.1:8888"},
}
for _, testcase := range testcases {
addr := Address{testcase.ma}
got := addr.HostAddr()
got := addr.URIAddr()
require.Equal(t, testcase.exp, got)
}
@ -68,7 +69,7 @@ func TestAddress_HostAddrString(t *testing.T) {
for _, testcase := range testcases {
addr := Address{testcase}
require.Panics(t, func() { addr.HostAddr() })
require.Panics(t, func() { addr.URIAddr() })
}
})
}