From efdeba8e994669ccd21c50d2b7491905b47a217e Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Mon, 27 Jan 2020 23:29:05 -0600 Subject: [test] sip integration test --- pkg/vpn/bonafide/bonafide_test.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'pkg/vpn/bonafide/bonafide_test.go') diff --git a/pkg/vpn/bonafide/bonafide_test.go b/pkg/vpn/bonafide/bonafide_test.go index 8fb7f72..0e463e0 100644 --- a/pkg/vpn/bonafide/bonafide_test.go +++ b/pkg/vpn/bonafide/bonafide_test.go @@ -27,9 +27,10 @@ import ( ) const ( - certPath = "testdata/cert" - eip1Path = "testdata/eip-service.json" - eipPath = "testdata/eip-service3.json" + certPath = "testdata/cert" + eip1Path = "testdata/eip-service.json" + eipPath = "testdata/eip-service3.json" + eipPathSip = "testdata/eip-service3-sip.json" ) type client struct { @@ -44,9 +45,18 @@ func (c client) Post(url, contentType string, body io.Reader) (resp *http.Respon }, err } -func TestGetCert(t *testing.T) { +func (c client) Do(req *http.Request) (*http.Response, error) { + f, err := os.Open(c.path) + return &http.Response{ + Body: f, + StatusCode: 200, + }, err +} + +func TestAnonGetCert(t *testing.T) { b := Bonafide{client: client{certPath}} - cert, err := b.GetCertPem() + b.auth = &AnonymousAuthentication{&b} + cert, err := b.GetPemCertificate() if err != nil { t.Fatal("getCert returned an error: ", err) } @@ -182,6 +192,8 @@ func TestObfs4Gateways(t *testing.T) { } } +/* TODO -- failClient instead? */ + type fallClient struct { path string } @@ -198,6 +210,14 @@ func (c fallClient) Post(url, contentType string, body io.Reader) (resp *http.Re }, err } +func (c fallClient) Do(req *http.Request) (*http.Response, error) { + f, err := os.Open(c.path) + return &http.Response{ + Body: f, + StatusCode: 401, + }, err +} + func TestEipServiceV1Fallback(t *testing.T) { b := Bonafide{ client: fallClient{eip1Path}, -- cgit v1.2.3