forked from chef/go-chef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
principal_test.go
44 lines (38 loc) · 895 Bytes
/
principal_test.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package chef
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestPrincipalsGet(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/principals/client_node", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, `{
"principals": [{
"name": "client_node",
"type": "client",
"authz_id": "afe1234",
"org_member": true,
"public_key": "-----BEGIN PUBLIC KEY"
}]}`)
})
p, err := client.Principals.Get("client_node")
if err != nil {
t.Errorf("GET principal error %+v making request: ", err)
return
}
pWant := Principal{}
client := Principals{
Name: "client_node",
Type: "client",
PublicKey: "-----BEGIN PUBLIC KEY",
AuthzId: "afe1234",
OrgMember: true,
}
pWant.Principals = append(pWant.Principals, client)
if !reflect.DeepEqual(p, pWant) {
t.Errorf("Unexpected principal values got: %+v wanted: %+v", p, pWant)
}
}