MCPcopy Create free account
hub / github.com/ory/fosite / TestNewAuthorizeRequest

Function TestNewAuthorizeRequest

authorize_request_handler_test.go:28–562  ·  view source on GitHub ↗

Should pass - https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#Terminology The OAuth 2.0 specification allows for registration of space-separated response_type parameter values. If a Response Type contains one of more space characters (%20), it is compared as a space-delimited lis

(t *testing.T)

Source from the content-addressed store, hash-verified

26// If a Response Type contains one of more space characters (%20), it is compared as a space-delimited list of
27// values in which the order of values does not matter.
28func TestNewAuthorizeRequest(t *testing.T) {
29 var store *MockStorage
30
31 redir, _ := url.Parse("https://foo.bar/cb")
32 specialCharRedir, _ := url.Parse("web+application://callback")
33 for k, c := range []struct {
34 desc string
35 conf *Fosite
36 r *http.Request
37 query url.Values
38 expectedError error
39 mock func()
40 expect *AuthorizeRequest
41 }{
42 /* empty request */
43 {
44 desc: "empty request fails",
45 conf: &Fosite{Store: store, Config: &Config{ScopeStrategy: ExactScopeStrategy, AudienceMatchingStrategy: DefaultAudienceMatchingStrategy}},
46 r: &http.Request{},
47 expectedError: ErrInvalidClient,
48 mock: func() {
49 store.EXPECT().GetClient(gomock.Any(), gomock.Any()).Return(nil, errors.New("foo"))
50 },
51 },
52 /* invalid redirect uri */
53 {
54 desc: "invalid redirect uri fails",
55 conf: &Fosite{Store: store, Config: &Config{ScopeStrategy: ExactScopeStrategy, AudienceMatchingStrategy: DefaultAudienceMatchingStrategy}},
56 query: url.Values{"redirect_uri": []string{"invalid"}},
57 expectedError: ErrInvalidClient,
58 mock: func() {
59 store.EXPECT().GetClient(gomock.Any(), gomock.Any()).Return(nil, errors.New("foo"))
60 },
61 },
62 /* invalid client */
63 {
64 desc: "invalid client fails",
65 conf: &Fosite{Store: store, Config: &Config{ScopeStrategy: ExactScopeStrategy, AudienceMatchingStrategy: DefaultAudienceMatchingStrategy}},
66 query: url.Values{"redirect_uri": []string{"https://foo.bar/cb"}},
67 expectedError: ErrInvalidClient,
68 mock: func() {
69 store.EXPECT().GetClient(gomock.Any(), gomock.Any()).Return(nil, errors.New("foo"))
70 },
71 },
72 /* redirect client mismatch */
73 {
74 desc: "client and request redirects mismatch",
75 conf: &Fosite{Store: store, Config: &Config{ScopeStrategy: ExactScopeStrategy, AudienceMatchingStrategy: DefaultAudienceMatchingStrategy}},
76 query: url.Values{
77 "client_id": []string{"1234"},
78 },
79 expectedError: ErrInvalidRequest,
80 mock: func() {
81 store.EXPECT().GetClient(gomock.Any(), "1234").Return(&DefaultClient{RedirectURIs: []string{"invalid"}, Scopes: []string{}}, nil)
82 },
83 },
84 /* redirect client mismatch */
85 {

Callers

nothing calls this directly

Calls 8

EXPECTMethod · 0.95
NewMockStorageFunction · 0.85
AssertObjectKeysEqualFunction · 0.85
GetClientMethod · 0.65
NewAuthorizeRequestMethod · 0.65
GetMethod · 0.65
GetRequestedAtMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…