This file is indexed.

/usr/share/gocode/src/github.com/go-chef/chef/acl_test.go is in golang-github-go-chef-chef-dev 0.0.1+git20161023.60.deb8c38-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
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)
	}
}