Merge branch 'test_fix' of openprivacy/libricochet-go into master
This commit is contained in:
commit
6c0d17667b
|
@ -5,10 +5,10 @@ import (
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/channels"
|
"git.openprivacy.ca/openprivacy/libricochet-go/channels"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/channels/v3/outbound"
|
"git.openprivacy.ca/openprivacy/libricochet-go/channels/v3/outbound"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/identity"
|
"git.openprivacy.ca/openprivacy/libricochet-go/identity"
|
||||||
|
"git.openprivacy.ca/openprivacy/libricochet-go/utils"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/wire/auth/3edh"
|
"git.openprivacy.ca/openprivacy/libricochet-go/wire/auth/3edh"
|
||||||
"git.openprivacy.ca/openprivacy/libricochet-go/wire/control"
|
"git.openprivacy.ca/openprivacy/libricochet-go/wire/control"
|
||||||
"golang.org/x/crypto/ed25519"
|
"golang.org/x/crypto/ed25519"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -17,11 +17,13 @@ func TestServer3DHAuthChannel(t *testing.T) {
|
||||||
|
|
||||||
cc := new(channels.Channel)
|
cc := new(channels.Channel)
|
||||||
cc.ID = 1
|
cc.ID = 1
|
||||||
cc.CloseChannel = func() {}
|
closed := false
|
||||||
|
cc.CloseChannel = func() {closed=true}
|
||||||
clientChannel := new(outbound.Client3DHAuthChannel)
|
clientChannel := new(outbound.Client3DHAuthChannel)
|
||||||
pub, priv, _ := ed25519.GenerateKey(rand.Reader)
|
pub, priv, _ := ed25519.GenerateKey(rand.Reader)
|
||||||
cid := identity.InitializeV3("", &priv, &pub)
|
cid := identity.InitializeV3("", &priv, &pub)
|
||||||
clientChannel.ClientIdentity = cid
|
clientChannel.ClientIdentity = cid
|
||||||
|
|
||||||
ocb, _ := clientChannel.OpenOutbound(cc)
|
ocb, _ := clientChannel.OpenOutbound(cc)
|
||||||
|
|
||||||
packet := new(Protocol_Data_Control.Packet)
|
packet := new(Protocol_Data_Control.Packet)
|
||||||
|
@ -31,7 +33,8 @@ func TestServer3DHAuthChannel(t *testing.T) {
|
||||||
pub, priv, _ = ed25519.GenerateKey(rand.Reader)
|
pub, priv, _ = ed25519.GenerateKey(rand.Reader)
|
||||||
sid := identity.InitializeV3("", &priv, &pub)
|
sid := identity.InitializeV3("", &priv, &pub)
|
||||||
s3dhchannel.ServerIdentity = sid
|
s3dhchannel.ServerIdentity = sid
|
||||||
cr, _ := s3dhchannel.OpenInbound(cc, packet.GetOpenChannel())
|
clientChannel.ServerHostname = utils.GetTorV3Hostname(pub)
|
||||||
|
cr, _ := s3dhchannel.OpenInbound(cc, packet.GetOpenChannel())
|
||||||
|
|
||||||
proto.Unmarshal(cr, packet)
|
proto.Unmarshal(cr, packet)
|
||||||
if packet.GetChannelResult() != nil {
|
if packet.GetChannelResult() != nil {
|
||||||
|
@ -39,14 +42,19 @@ func TestServer3DHAuthChannel(t *testing.T) {
|
||||||
authPacket := new(Protocol_Data_Auth_TripleEDH.Packet)
|
authPacket := new(Protocol_Data_Auth_TripleEDH.Packet)
|
||||||
var lastMessage []byte
|
var lastMessage []byte
|
||||||
cc.SendMessage = func(message []byte) {
|
cc.SendMessage = func(message []byte) {
|
||||||
|
t.Logf("Received: %x", message)
|
||||||
proto.Unmarshal(message, authPacket)
|
proto.Unmarshal(message, authPacket)
|
||||||
lastMessage = message
|
lastMessage = message
|
||||||
}
|
}
|
||||||
clientChannel.OpenOutboundResult(nil, packet.GetChannelResult())
|
clientChannel.OpenOutboundResult(nil, packet.GetChannelResult())
|
||||||
// TODO: broken test or implementation. please fix
|
|
||||||
/*if authPacket.Proof == nil {
|
if closed == true {
|
||||||
|
t.Fatalf("Should not have closed channel!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if authPacket.Proof == nil {
|
||||||
t.Errorf("Was expected a Proof Packet, instead %v", authPacket)
|
t.Errorf("Was expected a Proof Packet, instead %v", authPacket)
|
||||||
}*/
|
}
|
||||||
|
|
||||||
s3dhchannel.ServerAuthValid = func(hostname string, publicKey ed25519.PublicKey) (allowed, known bool) {
|
s3dhchannel.ServerAuthValid = func(hostname string, publicKey ed25519.PublicKey) (allowed, known bool) {
|
||||||
if hostname != clientChannel.ClientIdentity.Hostname() {
|
if hostname != clientChannel.ClientIdentity.Hostname() {
|
||||||
|
@ -80,6 +88,7 @@ func TestServer3DHAuthChannelReject(t *testing.T) {
|
||||||
pub, priv, _ = ed25519.GenerateKey(rand.Reader)
|
pub, priv, _ = ed25519.GenerateKey(rand.Reader)
|
||||||
sid := identity.InitializeV3("", &priv, &pub)
|
sid := identity.InitializeV3("", &priv, &pub)
|
||||||
s3dhchannel.ServerIdentity = sid
|
s3dhchannel.ServerIdentity = sid
|
||||||
|
clientChannel.ServerHostname = utils.GetTorV3Hostname(pub)
|
||||||
cr, _ := s3dhchannel.OpenInbound(cc, packet.GetOpenChannel())
|
cr, _ := s3dhchannel.OpenInbound(cc, packet.GetOpenChannel())
|
||||||
|
|
||||||
proto.Unmarshal(cr, packet)
|
proto.Unmarshal(cr, packet)
|
||||||
|
@ -96,12 +105,15 @@ func TestServer3DHAuthChannelReject(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clientChannel.OpenOutboundResult(nil, packet.GetChannelResult())
|
clientChannel.OpenOutboundResult(nil, packet.GetChannelResult())
|
||||||
// TODO: broken test or implementation. please fix
|
|
||||||
/*if authPacket.Proof == nil {
|
if authPacket.Proof == nil {
|
||||||
t.Errorf("Was expected a Proof Packet, instead %v", authPacket)
|
t.Errorf("Was expected a Proof Packet, instead %v", authPacket)
|
||||||
}*/
|
}
|
||||||
|
|
||||||
s3dhchannel.ServerAuthInvalid = func(err error) {
|
s3dhchannel.ServerAuthInvalid = func(err error) {
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Server Auth Should have been invalid!")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cc.DelegateAuthorization = func() {}
|
cc.DelegateAuthorization = func() {}
|
||||||
s3dhchannel.Packet(lastMessage)
|
s3dhchannel.Packet(lastMessage)
|
||||||
|
|
Reference in New Issue