This file is indexed.

/usr/share/gocode/src/github.com/abbot/go-http-auth/basic_test.go is in golang-github-abbot-go-http-auth-dev 0.0~git20150714.0.46b9627-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
package auth

import (
	"encoding/base64"
	"net/http"
	"testing"
)

func TestAuthBasic(t *testing.T) {
	secrets := HtpasswdFileProvider("test.htpasswd")
	a := &BasicAuth{Realm: "example.com", Secrets: secrets}
	r := &http.Request{}
	r.Method = "GET"
	if a.CheckAuth(r) != "" {
		t.Fatal("CheckAuth passed on empty headers")
	}
	r.Header = http.Header(make(map[string][]string))
	r.Header.Set("Authorization", "Digest blabla ololo")
	if a.CheckAuth(r) != "" {
		t.Fatal("CheckAuth passed on bad headers")
	}
	r.Header.Set("Authorization", "Basic !@#")
	if a.CheckAuth(r) != "" {
		t.Fatal("CheckAuth passed on bad base64 data")
	}

	data := [][]string{
		{"test", "hello"},
		{"test2", "hello2"},
		{"test16", "topsecret"},
	}
	for _, tc := range data {
		auth := base64.StdEncoding.EncodeToString([]byte(tc[0] + ":" + tc[1]))
		r.Header.Set("Authorization", "Basic "+auth)
		if a.CheckAuth(r) != tc[0] {
			t.Fatalf("CheckAuth failed for user '%s'", tc[0])
		}
	}
}