Skip to content

Commit

Permalink
chore(test): add test for auth headers
Browse files Browse the repository at this point in the history
  • Loading branch information
terinjokes committed May 6, 2016
1 parent 5b18411 commit 44261e5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cloudflare_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package cloudflare

import (
"fmt"
"net/http"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/assert"
)

var (
Expand All @@ -29,3 +33,28 @@ func setup() {
func teardown() {
server.Close()
}

func TestClient_Auth(t *testing.T) {
setup()
defer teardown()

mux.HandleFunc("/ips", func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "GET", r.Method, "Expected method 'GET', got %s", r.Method)
assert.Equal(t, "[email protected]", r.Header.Get("X-Auth-Email"))
assert.Equal(t, "deadbeef", r.Header.Get("X-Auth-Token"))
w.Header().Set("Content-Type", "application/json")
fmt.Fprintf(w, `{
"success": true,
"errors": [],
"messages": [],
"response": {
"ipv4_cidrs": ["199.27.128.0/21"],
"ipv6_cidrs": ["199.27.128.0/21"]
}
}`)
})

_, err := IPs()

assert.NoError(t, err)
}

0 comments on commit 44261e5

Please sign in to comment.