(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func 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 | } |
nothing calls this directly
no test coverage detected