This file is indexed.

/usr/share/gocode/src/github.com/go-chef/chef/sandbox_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
package chef

import (
	"crypto/md5"
	"crypto/rand"
	"fmt"
	"net/http"
	_ "reflect"
	"testing"
	. "github.com/smartystreets/goconvey/convey"
)

// generate random data for sandbox
func random_data(size int) (b []byte) {
	b = make([]byte, size)
	rand.Read(b)
	return
}

//	mux.HandleFunc("/sandboxes/f1c560ccb472448e9cfb31ff98134247", func(w http.ResponseWriter, r *http.Request) { })
func TestSandboxesPost(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/sandboxes", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, `{
			"sandbox_id": "f1c560ccb472448e9cfb31ff98134247",
			"uri": "http://trendy.local:4545/sandboxes/f1c560ccb472448e9cfb31ff98134247",
			"Checksums": {
					"4bd9946774fff1fb53745c645e447c9d20a14cac410b9eea037299247e70aa1e": {
							"url": "http://trendy.local:4545/file_store/4bd9946774fff1fb53745c645e447c9d20a14cac410b9eea037299247e70aa1e",
							"needs_upload": true
					},
					"548c6928e3f5a800a0e9cc146647a31a2353c42950a611cfca646819cdaa54fa": {
							"url": "http://trendy.local:4545/file_store/548c6928e3f5a800a0e9cc146647a31a2353c42950a611cfca646819cdaa54fa",
							"needs_upload": true
			}}}`)
	})

	// create junk files and sums
	files := make(map[string][]byte)
	// slice of strings for holding our hashes
	sums := make([]string, 10)
	for i := 0; i <= 10; i++ {
		data := random_data(1024)
		hashstr := fmt.Sprintf("%x", md5.Sum(data))
		files[hashstr] = data
		sums = append(sums, hashstr)
	}

	// post the new sums/files to the sandbox
	_, err := client.Sandboxes.Post(sums)
	if err != nil {
		t.Errorf("Snadbox Post error making request: ", err)
	}
}

func TestSandboxesPut(t *testing.T) {
	setup()
	defer teardown()

	mux.HandleFunc("/sandboxes/f1c560ccb472448e9cfb31ff98134247", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, `{
			"guid": "123",
			"name": "123",
			"CreateionTime": "2014-08-23 18:13:37",
			"is_completed": true,
			"uri": "https://127.0.0.1/sandboxes/f1c560ccb472448e9cfb31ff98134247",
	  	"checksums": [
				"3124216defe5849089a577ffefb0bb05",
				"e06ddfa07ca97c80c368d08e189b928a",
				"eb65444f8adeb11c56cf0df201a07cb4"
			]
		}`)
	})

	sandbox, err := client.Sandboxes.Put("f1c560ccb472448e9cfb31ff98134247")
	if err != nil {
		t.Errorf("Snadbox Put error making request: ", err)
	}

	expected := Sandbox{
		ID:        "123",
		Name:      "123",
		Completed: true,
		Checksums: []string{
			"3124216defe5849089a577ffefb0bb05",
			"e06ddfa07ca97c80c368d08e189b928a",
			"eb65444f8adeb11c56cf0df201a07cb4",
		},
	}

	Convey("Sandbox Equality", t, func() {
		So(sandbox, ShouldResemble, expected)
	})
}