mirror of https://github.com/cbeuw/Cloak
Fix tests
This commit is contained in:
parent
c1f3408c2c
commit
963dae829d
|
|
@ -14,7 +14,7 @@ func TestMakeAuthenticationPayload(t *testing.T) {
|
|||
seed io.Reader
|
||||
time time.Time
|
||||
expPayload authenticationPayload
|
||||
expSecret []byte
|
||||
expSecret [32]byte
|
||||
}{
|
||||
{
|
||||
&authInfo{
|
||||
|
|
@ -54,7 +54,7 @@ func TestMakeAuthenticationPayload(t *testing.T) {
|
|||
0x3b, 0xb8, 0x8b, 0xfb, 0xb6, 0x40, 0xf0, 0x2c,
|
||||
0x6c, 0x55, 0xb9, 0xfc, 0x5d, 0x34, 0x89, 0x41},
|
||||
},
|
||||
[]byte{
|
||||
[32]byte{
|
||||
0xc7, 0xc6, 0x9b, 0xbe, 0xec, 0xf8, 0x35, 0x55,
|
||||
0x67, 0x20, 0xcd, 0xeb, 0x74, 0x16, 0xc5, 0x60,
|
||||
0xee, 0x9d, 0x63, 0x1a, 0x44, 0xc5, 0x09, 0xf6,
|
||||
|
|
@ -67,7 +67,7 @@ func TestMakeAuthenticationPayload(t *testing.T) {
|
|||
if payload != tc.expPayload {
|
||||
t.Errorf("payload doesn't match:\nexp %v\ngot %v", tc.expPayload, payload)
|
||||
}
|
||||
if !bytes.Equal(sharedSecret, tc.expSecret) {
|
||||
if sharedSecret != tc.expSecret {
|
||||
t.Errorf("secret doesn't match:\nexp %x\ngot %x", tc.expPayload, payload)
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
func TestGenerateObfs(t *testing.T) {
|
||||
sessionKey := make([]byte, 32)
|
||||
rand.Read(sessionKey)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
|
||||
run := func(obfuscator *Obfuscator, ct *testing.T) {
|
||||
obfsBuf := make([]byte, 512)
|
||||
|
|
@ -84,12 +84,6 @@ func TestGenerateObfs(t *testing.T) {
|
|||
t.Errorf("unknown encryption mehtod error expected")
|
||||
}
|
||||
})
|
||||
t.Run("bad key length", func(t *testing.T) {
|
||||
_, err := GenerateObfs(0xff, sessionKey[:31], true)
|
||||
if err == nil {
|
||||
t.Errorf("bad key length error expected")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkObfs(b *testing.B) {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ func TestRecvDataFromRemote(t *testing.T) {
|
|||
}
|
||||
obfsBuf := make([]byte, 17000)
|
||||
|
||||
sessionKey := make([]byte, 32)
|
||||
rand.Read(sessionKey)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
t.Run("plain ordered", func(t *testing.T) {
|
||||
obfuscator, _ := GenerateObfs(E_METHOD_PLAIN, sessionKey, true)
|
||||
seshConfigOrdered.Obfuscator = obfuscator
|
||||
|
|
@ -153,11 +153,12 @@ func TestRecvDataFromRemote_Closing_InOrder(t *testing.T) {
|
|||
rand.Read(testPayload)
|
||||
obfsBuf := make([]byte, 17000)
|
||||
|
||||
sessionKey := make([]byte, 32)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
|
||||
obfuscator, _ := GenerateObfs(E_METHOD_PLAIN, sessionKey, true)
|
||||
seshConfigOrdered.Obfuscator = obfuscator
|
||||
|
||||
rand.Read(sessionKey)
|
||||
sesh := MakeSession(0, seshConfigOrdered)
|
||||
|
||||
f1 := &Frame{
|
||||
|
|
@ -283,11 +284,12 @@ func TestRecvDataFromRemote_Closing_OutOfOrder(t *testing.T) {
|
|||
rand.Read(testPayload)
|
||||
obfsBuf := make([]byte, 17000)
|
||||
|
||||
sessionKey := make([]byte, 32)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
|
||||
obfuscator, _ := GenerateObfs(E_METHOD_PLAIN, sessionKey, true)
|
||||
seshConfigOrdered.Obfuscator = obfuscator
|
||||
|
||||
rand.Read(sessionKey)
|
||||
sesh := MakeSession(0, seshConfigOrdered)
|
||||
|
||||
// receive stream 1 closing first
|
||||
|
|
@ -341,10 +343,11 @@ func TestRecvDataFromRemote_Closing_OutOfOrder(t *testing.T) {
|
|||
func TestParallel(t *testing.T) {
|
||||
rand.Seed(0)
|
||||
|
||||
sessionKey := make([]byte, 32)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
|
||||
obfuscator, _ := GenerateObfs(E_METHOD_PLAIN, sessionKey, true)
|
||||
seshConfigOrdered.Obfuscator = obfuscator
|
||||
rand.Read(sessionKey)
|
||||
sesh := MakeSession(0, seshConfigOrdered)
|
||||
|
||||
numStreams := 10
|
||||
|
|
@ -410,8 +413,8 @@ func BenchmarkRecvDataFromRemote_Ordered(b *testing.B) {
|
|||
}
|
||||
obfsBuf := make([]byte, 17000)
|
||||
|
||||
sessionKey := make([]byte, 32)
|
||||
rand.Read(sessionKey)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
|
||||
b.Run("plain", func(b *testing.B) {
|
||||
obfuscator, _ := GenerateObfs(E_METHOD_PLAIN, sessionKey, true)
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
func setupSesh(unordered bool) *Session {
|
||||
sessionKey := make([]byte, 32)
|
||||
rand.Read(sessionKey)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
obfuscator, _ := GenerateObfs(0x00, sessionKey, true)
|
||||
|
||||
seshConfig := &SessionConfig{
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import (
|
|||
)
|
||||
|
||||
func getSeshConfig(unordered bool) *mux.SessionConfig {
|
||||
sessionKey := make([]byte, 32)
|
||||
rand.Read(sessionKey)
|
||||
var sessionKey [32]byte
|
||||
rand.Read(sessionKey[:])
|
||||
obfuscator, _ := mux.GenerateObfs(0x00, sessionKey, true)
|
||||
|
||||
seshConfig := &mux.SessionConfig{
|
||||
|
|
|
|||
Loading…
Reference in New Issue