storj/pkg/transport/transport_test.go
Maximillian von Briesen 553def620a TLS Support (#252)
* begin adding tls

* remove incomplete line in gw/main.go

* identity fixes+:

+ fix `peertls.NewCert` public key issue
+ fix `peertls.verfiyChain` issue
+ fix identity dial option
+ rename `GenerateCA` to `NewCA` and `generateCAWorker` to `newCAWorker` for better consistency/convention

* use pdbclient instead of pointerdb in miniogw

* fix tests

* go fmt

* make review changes

* modify how context.Background() is used

* more context stuff
2018-08-23 22:01:03 -06:00

60 lines
1.2 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package transport
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"storj.io/storj/pkg/provider"
proto "storj.io/storj/protos/overlay"
)
var ctx = context.Background()
func TestDialNode(t *testing.T) {
ca, err := provider.NewCA(ctx, 12, 4)
assert.NoError(t, err)
identity, err := ca.NewIdentity()
assert.NoError(t, err)
oc := Transport{
identity: identity,
}
// node.Address.Address == "" condition test
node := proto.Node{
Id: "DUMMYID1",
Address: &proto.NodeAddress{
Transport: proto.NodeTransport_TCP,
Address: "",
},
}
conn, err := oc.DialNode(ctx, &node)
assert.Error(t, err)
assert.Nil(t, conn)
// node.Address == nil condition test
node = proto.Node{
Id: "DUMMYID2",
Address: nil,
}
conn, err = oc.DialNode(ctx, &node)
assert.Error(t, err)
assert.Nil(t, conn)
// node is valid argument condition test
node = proto.Node{
Id: "DUMMYID3",
Address: &proto.NodeAddress{
Transport: proto.NodeTransport_TCP,
Address: "127.0.0.0:9000",
},
}
conn, err = oc.DialNode(ctx, &node)
assert.NoError(t, err)
assert.NotNil(t, conn)
}