|
3 | 3 | from beacon_api.utils.db_load import parse_arguments, init_beacon_db, main |
4 | 4 | from beacon_api.conf.config import init_db_pool |
5 | 5 | from beacon_api.api.query import access_resolution |
6 | | -from beacon_api.utils.validate import token_scheme_check |
| 6 | +from beacon_api.utils.validate import token_scheme_check, verify_aud_claim |
7 | 7 | from beacon_api.permissions.ga4gh import get_ga4gh_controlled, get_ga4gh_bona_fide |
8 | 8 | from .test_app import PARAMS |
9 | 9 | from testfixtures import TempDirectory |
| 10 | +from test.support import EnvironmentVarGuard |
10 | 11 |
|
11 | 12 |
|
12 | 13 | def mock_token(bona_fide, permissions, auth): |
@@ -106,6 +107,16 @@ def test_main_db(self, mock_init): |
106 | 107 | main() |
107 | 108 | mock_init.assert_called() |
108 | 109 |
|
| 110 | + def test_aud_claim(self): |
| 111 | + """Test aud claim function.""" |
| 112 | + env = EnvironmentVarGuard() |
| 113 | + env.set('JWT_AUD', "aud1,aud2") |
| 114 | + result = verify_aud_claim() |
| 115 | + # Because it is false we expect it not to be parsed |
| 116 | + expected = (False, []) |
| 117 | + self.assertEqual(result, expected) |
| 118 | + env.unset('JWT_AUD') |
| 119 | + |
109 | 120 | def test_token_scheme_check_bad(self): |
110 | 121 | """Test token scheme no token.""" |
111 | 122 | # This might never happen, yet lets prepare for it |
|
0 commit comments