TUN-3890: Code coverage for cloudflared in CI

Also changed the socks test code so that it binds to localhost, so that
we don't get popups saying "would you like to allow socks.test to use
the network"
This commit is contained in:
Adam Chalmers 2021-02-08 15:31:51 -06:00
parent a4f185fd28
commit d8bee0b4d9
4 changed files with 10 additions and 3 deletions

1
.gitignore vendored
View File

@ -18,3 +18,4 @@ cloudflared-x86-64*
.DS_Store
*-session.log
ssh_server_tests/.env
.cover

View File

@ -88,7 +88,13 @@ container:
.PHONY: test
test: vet
ifndef CI
go test -v -mod=vendor -race $(VERSION_FLAGS) ./...
else
@mkdir -p .cover
go test -v -mod=vendor -race $(VERSION_FLAGS) -coverprofile=".cover/c.out" ./...
go tool cover -html ".cover/c.out" -o .cover/all.html
endif
.PHONY: test-ssh-server
test-ssh-server:

View File

@ -27,7 +27,7 @@ func TestCreateTLSListenerOnlyHostSuccess(t *testing.T) {
}
func TestCreateTLSListenerOnlyPortSuccess(t *testing.T) {
listener, err := CreateTLSListener(":8888")
listener, err := CreateTLSListener("localhost:8888")
if err != nil {
t.Fatal(err)
}

View File

@ -42,7 +42,7 @@ func startTestServer(t *testing.T, httpHandler func(w http.ResponseWriter, r *ht
// create a socks server
requestHandler := NewRequestHandler(NewNetDialer())
socksServer := NewConnectionHandler(requestHandler)
listener, err := net.Listen("tcp", ":8086")
listener, err := net.Listen("tcp", "localhost:8086")
assert.NoError(t, err)
go func() {
@ -58,7 +58,7 @@ func startTestServer(t *testing.T, httpHandler func(w http.ResponseWriter, r *ht
mux.HandleFunc("/", httpHandler)
// start the servers
go http.ListenAndServe(":8085", mux)
go http.ListenAndServe("localhost:8085", mux)
}
func respondWithJSON(w http.ResponseWriter, v interface{}, status int) {