|
4 | 4 | import pytest
|
5 | 5 | import requests
|
6 | 6 | from connexion.exceptions import (OAuthProblem, OAuthResponseProblem,
|
7 |
| - OAuthScopeProblem) |
| 7 | + OAuthScopeProblem, BadRequestProblem, |
| 8 | + ConnexionException) |
8 | 9 |
|
9 | 10 |
|
10 | 11 | def test_get_tokeninfo_url(monkeypatch, security_handler_factory):
|
@@ -220,3 +221,20 @@ def test_verify_security_oauthproblem(security_handler_factory):
|
220 | 221 | secured_func(request)
|
221 | 222 |
|
222 | 223 | assert str(exc_info.value) == '401 Unauthorized: No authorization token provided'
|
| 224 | + |
| 225 | +@pytest.mark.parametrize( |
| 226 | + 'errors, most_specific', |
| 227 | + [ |
| 228 | + ([OAuthProblem()], OAuthProblem), |
| 229 | + ([OAuthProblem(), OAuthScopeProblem([], [])], OAuthScopeProblem), |
| 230 | + ([OAuthProblem(), OAuthScopeProblem([], []), BadRequestProblem], OAuthScopeProblem), |
| 231 | + ([OAuthProblem(), OAuthScopeProblem([], []), BadRequestProblem, ConnexionException], OAuthScopeProblem), |
| 232 | + ([BadRequestProblem(), ConnexionException()], BadRequestProblem), |
| 233 | + ([ConnexionException()], ConnexionException), |
| 234 | + ] |
| 235 | +) |
| 236 | +def test_raise_most_specific(errors, most_specific, security_handler_factory): |
| 237 | + """Tests whether most specific exception is raised from a list.""" |
| 238 | + |
| 239 | + with pytest.raises(most_specific): |
| 240 | + security_handler_factory._raise_most_specific(errors) |
0 commit comments