This file is indexed.

/usr/share/gocode/src/github.com/emicklei/go-restful/options_filter_test.go is in golang-github-emicklei-go-restful-dev 1.2-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
package restful

import (
	"net/http"
	"net/http/httptest"
	"testing"
)

// go test -v -test.run TestOptionsFilter ...restful
func TestOptionsFilter(t *testing.T) {
	tearDown()
	ws := new(WebService)
	ws.Route(ws.GET("/candy/{kind}").To(dummy))
	ws.Route(ws.DELETE("/candy/{kind}").To(dummy))
	ws.Route(ws.POST("/candies").To(dummy))
	Add(ws)
	Filter(OPTIONSFilter())

	httpRequest, _ := http.NewRequest("OPTIONS", "http://here.io/candy/gum", nil)
	httpWriter := httptest.NewRecorder()
	DefaultContainer.dispatch(httpWriter, httpRequest)
	actual := httpWriter.Header().Get(HEADER_Allow)
	if "GET,DELETE" != actual {
		t.Fatal("expected: GET,DELETE but got:" + actual)
	}

	httpRequest, _ = http.NewRequest("OPTIONS", "http://here.io/candies", nil)
	httpWriter = httptest.NewRecorder()
	DefaultContainer.dispatch(httpWriter, httpRequest)
	actual = httpWriter.Header().Get(HEADER_Allow)
	if "POST" != actual {
		t.Fatal("expected: POST but got:" + actual)
	}
}