This file is indexed.

/usr/share/gocode/src/github.com/coreos/go-oidc/oauth2/error_test.go is in golang-github-coreos-go-oidc-dev 0.0~git20151022.0.e9c0807-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
package oauth2

import (
	"fmt"
	"reflect"
	"testing"
)

func TestUnmarshalError(t *testing.T) {
	tests := []struct {
		b []byte
		e *Error
		o bool
	}{
		{
			b: []byte("{ \"error\": \"invalid_client\", \"state\": \"foo\" }"),
			e: &Error{Type: ErrorInvalidClient, State: "foo"},
			o: true,
		},
		{
			b: []byte("{ \"error\": \"invalid_grant\", \"state\": \"bar\" }"),
			e: &Error{Type: ErrorInvalidGrant, State: "bar"},
			o: true,
		},
		{
			b: []byte("{ \"error\": \"invalid_request\", \"state\": \"\" }"),
			e: &Error{Type: ErrorInvalidRequest, State: ""},
			o: true,
		},
		{
			b: []byte("{ \"error\": \"server_error\", \"state\": \"elroy\" }"),
			e: &Error{Type: ErrorServerError, State: "elroy"},
			o: true,
		},
		{
			b: []byte("{ \"error\": \"unsupported_grant_type\", \"state\": \"\" }"),
			e: &Error{Type: ErrorUnsupportedGrantType, State: ""},
			o: true,
		},
		{
			b: []byte("{ \"error\": \"unsupported_response_type\", \"state\": \"\" }"),
			e: &Error{Type: ErrorUnsupportedResponseType, State: ""},
			o: true,
		},
		// Should fail json unmarshal
		{
			b: nil,
			e: nil,
			o: false,
		},
		{
			b: []byte("random string"),
			e: nil,
			o: false,
		},
	}

	for i, tt := range tests {
		err := unmarshalError(tt.b)
		oerr, ok := err.(*Error)

		if ok != tt.o {
			t.Errorf("%v != %v, %v", ok, tt.o, oerr)
			t.Errorf("case %d: want=%+v, got=%+v", i, tt.e, oerr)
		}

		if ok && !reflect.DeepEqual(tt.e, oerr) {
			t.Errorf("case %d: want=%+v, got=%+v", i, tt.e, oerr)
		}

		if !ok && tt.e != nil {
			want := fmt.Sprintf("unrecognized error: %s", string(tt.b))
			got := tt.e.Error()
			if want != got {
				t.Errorf("case %d: want=%+v, got=%+v", i, want, got)
			}
		}
	}
}