opentofu/vendor/github.com/go-chef/chef/acl_test.go
Paul Hinze 6fe2703665 Vendor all dependencies w/ Godep
* Remove `make updatedeps` from Travis build. We'll follow up with more
   specific plans around dependency updating in subsequent PRs.
 * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to
   filter out `/vendor/` from `./...` where appropriate.
 * Temporarily remove `vet` from the `make test` target until we can
   figure out how to get it to not vet `vendor/`. (Initial
   experimentation failed to yield the proper incantation.)

Everything is pinned to current master, with the exception of:

 * Azure/azure-sdk-for-go which is pinned before the breaking change today
 * aws/aws-sdk-go which is pinned to the most recent tag

The documentation still needs to be updated, which we can do in a follow
up PR. The goal here is to unblock release.
2016-01-29 15:08:48 -06:00

103 lines
2.2 KiB
Go

package chef
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestACLService_Get(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/nodes/hostname/_acl", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, `{
"create": {
"actors": [
"hostname",
"pivotal"
],
"groups": [
"clients",
"users",
"admins"
]
},
"read": {
"actors": [
"hostname",
"pivotal"
],
"groups": [
"clients",
"users",
"admins"
]
},
"update": {
"actors": [
"hostname",
"pivotal"
],
"groups": [
"users",
"admins"
]
},
"delete": {
"actors": [
"hostname",
"pivotal"
],
"groups": [
"users",
"admins"
]
},
"grant": {
"actors": [
"hostname",
"pivotal"
],
"groups": [
"admins"
]
}
}
`)
})
acl, err := client.ACLs.Get("nodes", "hostname")
if err != nil {
t.Errorf("ACL.Get returned error: %v", err)
}
want := ACL{
"create": ACLitems{Groups: []string{"clients", "users", "admins"}, Actors: []string{"hostname", "pivotal"}},
"read": ACLitems{Groups: []string{"clients", "users", "admins"}, Actors: []string{"hostname", "pivotal"}},
"update": ACLitems{Groups: []string{"users", "admins"}, Actors: []string{"hostname", "pivotal"}},
"delete": ACLitems{Groups: []string{"users", "admins"}, Actors: []string{"hostname", "pivotal"}},
"grant": ACLitems{Groups: []string{"admins"}, Actors: []string{"hostname", "pivotal"}},
}
if !reflect.DeepEqual(acl, want) {
t.Errorf("ACL.Get returned %+v, want %+v", acl, want)
}
}
func TestACLService_Put(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/nodes/hostname/_acl/create", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, ``)
})
acl := NewACL("create", []string{"pivotal"}, []string{"admins"})
err := client.ACLs.Put("nodes", "hostname", "create", acl)
if err != nil {
t.Errorf("ACL.Put returned error: %v", err)
}
}