Skip to content

Commit d9ec183

Browse files
TUN-4873: Disable unix domain socket test for windows unit tests
1 parent ed024d0 commit d9ec183

File tree

2 files changed

+55
-41
lines changed

2 files changed

+55
-41
lines changed

origin/proxy_posix_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// +build !windows
2+
3+
package origin
4+
5+
import (
6+
"io/ioutil"
7+
"net"
8+
"net/http"
9+
"net/http/httptest"
10+
"os"
11+
"testing"
12+
13+
"github.com/stretchr/testify/require"
14+
15+
"github.com/cloudflare/cloudflared/config"
16+
)
17+
18+
func TestUnixSocketOrigin(t *testing.T) {
19+
file, err := ioutil.TempFile("", "unix.sock")
20+
require.NoError(t, err)
21+
os.Remove(file.Name()) // remove the file since binding the socket expects to create it
22+
23+
l, err := net.Listen("unix", file.Name())
24+
require.NoError(t, err)
25+
defer l.Close()
26+
defer os.Remove(file.Name())
27+
28+
api := &httptest.Server{
29+
Listener: l,
30+
Config: &http.Server{Handler: mockAPI{}},
31+
}
32+
api.Start()
33+
defer api.Close()
34+
35+
unvalidatedIngress := []config.UnvalidatedIngressRule{
36+
{
37+
Hostname: "unix.example.com",
38+
Service: "unix:" + file.Name(),
39+
},
40+
{
41+
Hostname: "*",
42+
Service: "http_status:404",
43+
},
44+
}
45+
46+
tests := []MultipleIngressTest{
47+
{
48+
url: "http://unix.example.com",
49+
expectedStatus: http.StatusCreated,
50+
expectedBody: []byte("Created"),
51+
},
52+
}
53+
54+
runIngressTestScenarios(t, unvalidatedIngress, tests)
55+
}

origin/proxy_test.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import (
66
"flag"
77
"fmt"
88
"io"
9-
"io/ioutil"
109
"net"
1110
"net/http"
1211
"net/http/httptest"
13-
"os"
1412
"sync"
1513
"testing"
1614
"time"
@@ -656,45 +654,6 @@ func TestConnections(t *testing.T) {
656654
}
657655
}
658656

659-
func TestUnixSocketOrigin(t *testing.T) {
660-
file, err := ioutil.TempFile("", "unix.sock")
661-
require.NoError(t, err)
662-
os.Remove(file.Name()) // remove the file since binding the socket expects to create it
663-
664-
l, err := net.Listen("unix", file.Name())
665-
require.NoError(t, err)
666-
defer l.Close()
667-
defer os.Remove(file.Name())
668-
669-
api := &httptest.Server{
670-
Listener: l,
671-
Config: &http.Server{Handler: mockAPI{}},
672-
}
673-
api.Start()
674-
defer api.Close()
675-
676-
unvalidatedIngress := []config.UnvalidatedIngressRule{
677-
{
678-
Hostname: "unix.example.com",
679-
Service: "unix:" + file.Name(),
680-
},
681-
{
682-
Hostname: "*",
683-
Service: "http_status:404",
684-
},
685-
}
686-
687-
tests := []MultipleIngressTest{
688-
{
689-
url: "http://unix.example.com",
690-
expectedStatus: http.StatusCreated,
691-
expectedBody: []byte("Created"),
692-
},
693-
}
694-
695-
runIngressTestScenarios(t, unvalidatedIngress, tests)
696-
}
697-
698657
type requestBody struct {
699658
pw *io.PipeWriter
700659
pr *io.PipeReader

0 commit comments

Comments
 (0)