MCPcopy
hub / github.com/ory/hydra / TestNewRevocationRequest

Function TestNewRevocationRequest

fosite/revoke_handler_test.go:22–211  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func 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")},

Callers

nothing calls this directly

Calls 15

EXPECTMethod · 0.95
EXPECTMethod · 0.95
EXPECTMethod · 0.95
EXPECTMethod · 0.95
NewRevocationRequestMethod · 0.95
NewMockStorageFunction · 0.92
NewMockClientManagerFunction · 0.92
NewMockRevocationHandlerFunction · 0.92
NewMockHasherFunction · 0.92
basicAuthFunction · 0.85
NewContextFunction · 0.70
FositeClientManagerMethod · 0.65

Tested by

no test coverage detected