summaryrefslogtreecommitdiff
path: root/pkg/vpn/bonafide/bonafide_test.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-01-27 23:29:05 -0600
committerkali kaneko (leap communications) <kali@leap.se>2020-08-20 20:27:40 +0200
commitefdeba8e994669ccd21c50d2b7491905b47a217e (patch)
tree3decd5d0f4364e0b9bcfcf4e7506df4359c8210b /pkg/vpn/bonafide/bonafide_test.go
parentc236dfcfdd60ea700e5f50ed2568398cd161dd4c (diff)
[test] sip integration test
Diffstat (limited to 'pkg/vpn/bonafide/bonafide_test.go')
-rw-r--r--pkg/vpn/bonafide/bonafide_test.go30
1 files changed, 25 insertions, 5 deletions
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},