@@ -134,6 +134,52 @@ func TestWrapper_handleAuthorizeRequestFromHolder(t *testing.T) {
134
134
135
135
requireOAuthError (t , err , oauth .ServerError , "failed to authorize client" )
136
136
})
137
+ t .Run ("failed to resolve OpenID configuration" , func (t * testing.T ) {
138
+ ctx := newTestClient (t )
139
+ ctx .policy .EXPECT ().PresentationDefinitions (gomock .Any (), "test" ).Return (pe.WalletOwnerMapping {pe .WalletOwnerOrganization : PresentationDefinition {}}, nil )
140
+ params := defaultParams ()
141
+ ctx .iamClient .EXPECT ().OpenIDConfiguration (context .Background (), holderClientID ).Return (nil , assert .AnError )
142
+
143
+ _ , err := ctx .client .handleAuthorizeRequestFromHolder (context .Background (), verifierSubject , params )
144
+
145
+ requireOAuthError (t , err , oauth .ServerError , "failed to authorize client" )
146
+ })
147
+ t .Run ("no redirect_uri" , func (t * testing.T ) {
148
+ ctx := newTestClient (t )
149
+ params := defaultParams ()
150
+ delete (params , oauth .RedirectURIParam )
151
+
152
+ _ , err := ctx .client .handleAuthorizeRequestFromHolder (context .Background (), verifierSubject , params )
153
+
154
+ requireOAuthError (t , err , oauth .InvalidRequest , "missing redirect_uri parameter" )
155
+ })
156
+ t .Run ("incorrect audience" , func (t * testing.T ) {
157
+ ctx := newTestClient (t )
158
+ params := defaultParams ()
159
+ params [jwt .AudienceKey ] = []string {"other" }
160
+
161
+ _ , err := ctx .client .handleAuthorizeRequestFromHolder (context .Background (), verifierSubject , params )
162
+
163
+ requireOAuthError (t , err , oauth .InvalidRequest , "invalid audience, expected: https://example.com/oauth2/verifier, was: other" )
164
+ })
165
+ t .Run ("missing code challenge parameter" , func (t * testing.T ) {
166
+ ctx := newTestClient (t )
167
+ params := defaultParams ()
168
+ delete (params , oauth .CodeChallengeParam )
169
+
170
+ _ , err := ctx .client .handleAuthorizeRequestFromHolder (context .Background (), verifierSubject , params )
171
+
172
+ requireOAuthError (t , err , oauth .InvalidRequest , "missing code_challenge parameter" )
173
+ })
174
+ t .Run ("invalid code challenge method" , func (t * testing.T ) {
175
+ ctx := newTestClient (t )
176
+ params := defaultParams ()
177
+ params [oauth .CodeChallengeMethodParam ] = "plain"
178
+
179
+ _ , err := ctx .client .handleAuthorizeRequestFromHolder (context .Background (), verifierSubject , params )
180
+
181
+ requireOAuthError (t , err , oauth .InvalidRequest , "invalid value for code_challenge_method parameter, only S256 is supported" )
182
+ })
137
183
}
138
184
139
185
func TestWrapper_handleAuthorizeRequestFromVerifier (t * testing.T ) {
0 commit comments