(t *testing.T)
| 20 | ) |
| 21 | |
| 22 | func TestNewRevocationRequest(t *testing.T) { |
| 23 | ctrl := gomock.NewController(t) |
| 24 | store := internal.NewMockStorage(ctrl) |
| 25 | clientManager := internal.NewMockClientManager(ctrl) |
| 26 | handler := internal.NewMockRevocationHandler(ctrl) |
| 27 | hasher := internal.NewMockHasher(ctrl) |
| 28 | t.Cleanup(ctrl.Finish) |
| 29 | |
| 30 | client := &DefaultClient{} |
| 31 | config := &Config{ClientSecretsHasher: hasher} |
| 32 | fosite := &Fosite{Store: store, Config: config} |
| 33 | for k, c := range []struct { |
| 34 | header http.Header |
| 35 | form url.Values |
| 36 | mock func() |
| 37 | method string |
| 38 | expectErr error |
| 39 | expect *AccessRequest |
| 40 | handlers RevocationHandlers |
| 41 | }{ |
| 42 | { |
| 43 | header: http.Header{}, |
| 44 | expectErr: ErrInvalidRequest, |
| 45 | method: "GET", |
| 46 | mock: func() {}, |
| 47 | }, |
| 48 | { |
| 49 | header: http.Header{}, |
| 50 | expectErr: ErrInvalidRequest, |
| 51 | method: "POST", |
| 52 | mock: func() {}, |
| 53 | }, |
| 54 | { |
| 55 | header: http.Header{}, |
| 56 | method: "POST", |
| 57 | form: url.Values{ |
| 58 | "token": {"foo"}, |
| 59 | }, |
| 60 | mock: func() {}, |
| 61 | expectErr: ErrInvalidRequest, |
| 62 | }, |
| 63 | { |
| 64 | header: http.Header{ |
| 65 | "Authorization": {basicAuth("foo", "bar")}, |
| 66 | }, |
| 67 | method: "POST", |
| 68 | form: url.Values{ |
| 69 | "token": {"foo"}, |
| 70 | }, |
| 71 | expectErr: ErrInvalidClient, |
| 72 | mock: func() { |
| 73 | store.EXPECT().FositeClientManager().Return(clientManager).Times(1) |
| 74 | clientManager.EXPECT().GetClient(gomock.Any(), gomock.Eq("foo")).Return(nil, errors.New("")) |
| 75 | }, |
| 76 | }, |
| 77 | { |
| 78 | header: http.Header{ |
| 79 | "Authorization": {basicAuth("foo", "bar")}, |
nothing calls this directly
no test coverage detected