MCPcopy Index your code
hub / github.com/cli/cli / Test_HeaderHasMinimumScopes

Function Test_HeaderHasMinimumScopes

pkg/cmd/auth/shared/oauth_scopes_test.go:60–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func Test_HeaderHasMinimumScopes(t *testing.T) {
61 tests := []struct {
62 name string
63 header string
64 wantErr string
65 }{
66 {
67 name: "no scopes",
68 header: "",
69 wantErr: "",
70 },
71 {
72 name: "default scopes",
73 header: "repo, read:org",
74 wantErr: "",
75 },
76 {
77 name: "admin:org satisfies read:org",
78 header: "repo, admin:org",
79 wantErr: "",
80 },
81 {
82 name: "write:org satisfies read:org",
83 header: "repo, write:org",
84 wantErr: "",
85 },
86 {
87 name: "insufficient scope",
88 header: "repo",
89 wantErr: "missing required scope 'read:org'",
90 },
91 {
92 name: "insufficient scopes",
93 header: "gist",
94 wantErr: "missing required scopes 'repo', 'read:org'",
95 },
96 }
97 for _, tt := range tests {
98 t.Run(tt.name, func(t *testing.T) {
99
100 err := HeaderHasMinimumScopes(tt.header)
101 if tt.wantErr != "" {
102 assert.EqualError(t, err, tt.wantErr)
103 } else {
104 assert.NoError(t, err)
105 }
106 })
107 }
108}

Callers

nothing calls this directly

Calls 2

HeaderHasMinimumScopesFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected