summaryrefslogtreecommitdiffstats
path: root/client/go/zts/zts_test.go
blob: f1bd9c1ba75b3a27cbfe96b4c533eee80d2f819e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package zts

import (
	"crypto/tls"
	"testing"

	"github.com/vespa-engine/vespa/client/go/mock"
)

func TestAccessToken(t *testing.T) {
	httpClient := mock.HTTPClient{}
	client, err := NewClient("http://example.com", &httpClient)
	if err != nil {
		t.Fatal(err)
	}
	httpClient.NextResponse(200, `{"access_token": "foo bar"}`)
	token, err := client.AccessToken("vespa.vespa", tls.Certificate{})
	if err != nil {
		t.Fatal(err)
	}
	want := "foo bar"
	if token != want {
		t.Errorf("got %q, want %q", token, want)
	}
}