File: principal_test.go

package info (click to toggle)
golang-github-go-chef-chef 0.0.1%2Bgit20161023.60.deb8c38-1.2~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 372 kB
  • sloc: sh: 14; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (3)
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
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, `{
		"name": "client_node",
		"type": "client",
		"public_key": "-----BEGIN PUBLIC KEY-----No, not really-----END PUBLIC KEY-----"
}`)
	})

	p, err := client.Principals.Get("client_node")
	if err != nil {
		t.Errorf("GET principal error making request: ", err)
		return
	}

	if p.Name != "client_node" {
		t.Errorf("Unexpected principal name: ", p.Name)
	}
	if p.Type != "client" {
		t.Errorf("Unexpected principal type: ", p.Type)
	}
	if p.PublicKey != "-----BEGIN PUBLIC KEY-----No, not really-----END PUBLIC KEY-----" {
		t.Errorf("Unexpected principal public key: ", p.PublicKey)
	}
}