This file is indexed.

/usr/share/gocode/src/github.com/coreos/go-oidc/jose/jws_test.go is in golang-github-coreos-go-oidc-dev 0.0~git20160926.0.16c5ecc-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
package jose

import (
	"strings"
	"testing"
)

type testCase struct{ t string }

var validInput []testCase

var invalidInput []testCase

func init() {
	validInput = []testCase{
		{
			"eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
		},
	}

	invalidInput = []testCase{
		// empty
		{
			"",
		},
		// undecodeable
		{
			"aaa.bbb.ccc",
		},
		// missing parts
		{
			"aaa",
		},
		// missing parts
		{
			"aaa.bbb",
		},
		// too many parts
		{
			"aaa.bbb.ccc.ddd",
		},
		// invalid header
		// EncodeHeader(map[string]string{"foo": "bar"})
		{
			"eyJmb28iOiJiYXIifQ.bbb.ccc",
		},
	}
}

func TestParseJWS(t *testing.T) {
	for i, tt := range validInput {
		jws, err := ParseJWS(tt.t)
		if err != nil {
			t.Errorf("test: %d. expected: valid, actual: invalid", i)
		}

		expectedHeader := strings.Split(tt.t, ".")[0]
		if jws.RawHeader != expectedHeader {
			t.Errorf("test: %d. expected: %s, actual: %s", i, expectedHeader, jws.RawHeader)
		}

		expectedPayload := strings.Split(tt.t, ".")[1]
		if jws.RawPayload != expectedPayload {
			t.Errorf("test: %d. expected: %s, actual: %s", i, expectedPayload, jws.RawPayload)
		}
	}

	for i, tt := range invalidInput {
		_, err := ParseJWS(tt.t)
		if err == nil {
			t.Errorf("test: %d. expected: invalid, actual: valid", i)
		}
	}
}