forked from TrueCloudLab/frostfs-node
WIP: Morph: Add unit tests #2
5 changed files with 6 additions and 8 deletions
|
@ -47,7 +47,7 @@ func (a Address) URIAddr() string {
|
|||
panic(fmt.Errorf("could not get host addr: %w", err))
|
||||
}
|
||||
|
||||
if !a.isTLSEnabled() {
|
||||
if !a.IsTLSEnabled() {
|
||||
return host
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ func (x AddressGroup) Len() int {
|
|||
// Less returns true if i-th address in AddressGroup supports TLS
|
||||
// and j-th one doesn't.
|
||||
func (x AddressGroup) Less(i, j int) bool {
|
||||
return x[i].isTLSEnabled() && !x[j].isTLSEnabled()
|
||||
return x[i].IsTLSEnabled() && !x[j].IsTLSEnabled()
|
||||
}
|
||||
|
||||
// Swap swaps i-th and j-th addresses in AddressGroup.
|
||||
|
|
|
@ -11,8 +11,8 @@ const (
|
|||
// tls var is used for (un)wrapping other multiaddrs around TLS multiaddr.
|
||||
var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName)
|
||||
|
||||
// isTLSEnabled searches for wrapped TLS protocol in multiaddr.
|
||||
func (a Address) isTLSEnabled() bool {
|
||||
// IsTLSEnabled searches for wrapped TLS protocol in multiaddr.
|
||||
func (a Address) IsTLSEnabled() bool {
|
||||
for _, protoc := range a.ma.Protocols() {
|
||||
if protoc.Code == multiaddr.P_TLS {
|
||||
return true
|
||||
|
|
|
@ -24,6 +24,6 @@ func TestAddress_TLSEnabled(t *testing.T) {
|
|||
err := addr.FromString(test.input)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, test.wantTLS, addr.isTLSEnabled(), test.input)
|
||||
require.Equal(t, test.wantTLS, addr.IsTLSEnabled(), test.input)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -100,8 +99,7 @@ func dialTreeService(ctx context.Context, netmapAddr string) (*grpc.ClientConn,
|
|||
),
|
||||
}
|
||||
|
||||
// FIXME(@fyrchik): ugly hack #1322
|
||||
if !strings.HasPrefix(netAddr.URIAddr(), "grpcs:") {
|
||||
if netAddr.IsTLSEnabled() {
|
||||
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue