diff --git a/src/bank/teller/teller_integration_test.go b/src/bank/teller/teller_integration_test.go new file mode 100644 index 0000000..f2a0359 --- /dev/null +++ b/src/bank/teller/teller_integration_test.go @@ -0,0 +1,45 @@ +package teller_test + +import ( + "crypto/tls" + "io" + "net/http" + "testing" + "time" +) + +func TestIntegration(t *testing.T) { + //curl --cert certificate.pem --cert-key private_key.pem --auth test_token_bfu2cyvq3il6o: https://api.teller.io/accounts + cert, err := tls.LoadX509KeyPair("./certificate.pem", "./private_key.pem") + if err != nil { + t.Fatal(err) + } + + c := &http.Client{ + Timeout: time.Second, + Transport: &http.Transport{ + DisableKeepAlives: true, + TLSClientConfig: &tls.Config{Certificates: []tls.Certificate{cert}}, + }, + } + //curl --cert certificate.pem --cert-key private_key.pem --auth test_token_bfu2cyvq3il6o: https://api.teller.io/accounts + + req, err := http.NewRequest(http.MethodGet, "https://api.teller.io/accounts", nil) + if err != nil { + t.Fatal(err) + } + req.SetBasicAuth("test_token_bfu2cyvq3il6o", "") + + resp, err := c.Do(req) + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + + body, _ := io.ReadAll(resp.Body) + if code := resp.StatusCode; code >= 300 { + t.Fatalf("(%d) %s", code, body) + } + + t.Logf("(%d) %s", resp.StatusCode, body) +}