Skip to content

Commit

Permalink
fixed cross-platform issues with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoSax committed May 14, 2020
1 parent b1c3fd1 commit 5b6f04f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
13 changes: 13 additions & 0 deletions stateDir/obfs4_bridgeline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# obfs4 torrc client bridge line
#
# This file is an automatically generated bridge line based on
# the current obfs4proxy configuration. EDITING IT WILL HAVE
# NO EFFECT.
#
# Before distributing this Bridge, edit the placeholder fields
# to contain the actual values:
# <IP ADDRESS> - The public IP Address of your obfs4 bridge.
# <PORT> - The TCP/IP port of your obfs4 bridge.
# <FINGERPRINT> - The bridge's fingerprint.

Bridge obfs4 <IP ADDRESS>:<PORT> <FINGERPRINT> cert=qYf00WHbvLdcgYPMUxyO5iJpILS+4We85ZrKycthAH1Hz3QDZyzrpMheT6byXzgKHMTrWQ iat-mode=0
1 change: 1 addition & 0 deletions stateDir/obfs4_state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"node-id":"a987f4d161dbbcb75c8183cc531c8ee6226920b4","private-key":"902e2a7080dcc544be33ff17191624e141a43fe2d25f7bc41aedd5f93986d16f","public-key":"bee167bce59acac9cb61007d47cf7403672ceba4c85e4fa6f25f380a1cc4eb59","drbg-seed":"1ce7d0a16948b52df13377a874fcf58fbb4afc3cf662c6a4","iat-mode":0}
10 changes: 8 additions & 2 deletions transports/Optimizer/v2/Optimizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net"
"net/url"
"os"
"os/user"
"path"
"strings"
"testing"
Expand Down Expand Up @@ -258,8 +259,13 @@ func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) {
}
}

func getObfs4CertString() (*string, error){
fPath := path.Join("/Users/bluesaxorcist/stateDir", "obfs4_bridgeline.txt")
func getObfs4CertString() (*string, error) {
usr, userError := user.Current()
if userError != nil {
return nil, userError
}
home := usr.HomeDir
fPath := path.Join(home, "shapeshifter-transports/stateDir", "obfs4_bridgeline.txt")
bytes, fileError := ioutil.ReadFile(fPath)
if fileError != nil {
return nil, fileError
Expand Down
8 changes: 4 additions & 4 deletions transports/Optimizer/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize
go 1.12

require (
github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.16
github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.16
github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.16
github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.16
github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.17
github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.17
github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.17
github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.17
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
)
21 changes: 19 additions & 2 deletions transports/obfs4/v2/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@ package obfs4

import (
"io/ioutil"
"os"
"os/user"
"path"
"strings"
)

//RunLocalObfs4Server runs the server side in the background for the test
func RunLocalObfs4Server(data string) bool {
//create a server
serverConfig, confError := NewObfs4Server("/Users/bluesaxorcist/stateDir")
usr, userError := user.Current()
if userError != nil {
return false
}
home := usr.HomeDir
fPath := path.Join(home, "shapeshifter-transports/stateDir")
directoryErr := os.Mkdir(fPath, 0775)
if directoryErr != nil {
return false
}
serverConfig, confError := NewObfs4Server(fPath)
if confError != nil {
return false
}
Expand Down Expand Up @@ -50,7 +62,12 @@ func RunLocalObfs4Server(data string) bool {

//RunObfs4Client runs the client side in the background for the test
func RunObfs4Client() (*Transport, error) {
fPath := path.Join("/Users/bluesaxorcist/stateDir", "obfs4_bridgeline.txt")
usr, userError := user.Current()
if userError != nil {
return nil, userError
}
home := usr.HomeDir
fPath := path.Join(home, "shapeshifter-transports/stateDir", "obfs4_bridgeline.txt")
bytes, fileError := ioutil.ReadFile(fPath)
if fileError != nil {
return nil, fileError
Expand Down

0 comments on commit 5b6f04f

Please sign in to comment.