HEPCloud / decisionengine_modules

Apache License 2.0
2 stars 19 forks source link

fix test_refresh_entry_token unit test #474

Closed vitodb closed 11 months ago

vitodb commented 11 months ago

Unit test test_refresh_entry_token is failing with log details

in this collapsible section. ``` =================================== FAILURES =================================== ___________________________ test_refresh_entry_token ___________________________ [gw3] linux -- Python 3.9.16 /usr/bin/python3 def test_refresh_entry_token(): with tempfile.TemporaryDirectory() as work_dir: os.mkdir(os.path.join(work_dir, "passwords.d")) with open(os.path.join(work_dir, "passwords.d", "FRONTEND"), "wb") as fd: fd.write(token_util.derive_master_key(b"TEST")) create_and_sign_token = token_util.create_and_sign_token with mock.patch.object(token_util, "create_and_sign_token") as create_token: create_token.side_effect = lambda *args, **kwargs: create_and_sign_token( *args, **kwargs, issuer="fermicloud000.fnal.gov:0000" ) gfe = glide_frontend_element.get_gfe_obj("CMS", "CMS", FRONTEND_CFG, structlog.getLogger("test")) token = gfe.refresh_entry_token("test_entry", work_dir) > assert token E AssertionError: assert '' create_and_sign_token = create_token = fd = <_io.BufferedWriter name='/tmp/tmpho8alque/passwords.d/FRONTEND'> gfe = token = '' work_dir = '/tmp/tmpho8alque' src/decisionengine_modules/tests/glideinwms/test_glide_frontend_element.py:147: AssertionError ------------------------------ Captured log call ------------------------------- DEBUG test:glide_frontend_element.py:1302 {"event": "creating token /tmp/tmpho8alque/tokens.d/test_entry.idtoken", "level": "debug", "logger": "test", "timestamp": "2023-09-28 18:29:25"} DEBUG test:glide_frontend_element.py:1303 {"event": "pwd_flie= /tmp/tmpho8alque/passwords.d/FRONTEND", "level": "debug", "logger": "test", "timestamp": "2023-09-28 18:29:25"} DEBUG test:glide_frontend_element.py:1304 {"event": "scope= condor:/READ condor:/ADVERTISE_STARTD condor:/ADVERTISE_MASTER", "level": "debug", "logger": "test", "timestamp": "2023-09-28 18:29:25"} DEBUG test:glide_frontend_element.py:1305 {"event": "duration= 86400", "level": "debug", "logger": "test", "timestamp": "2023-09-28 18:29:25"} DEBUG test:glide_frontend_element.py:1306 {"event": "identity= test_entry@a73be4f57536", "level": "debug", "logger": "test", "timestamp": "2023-09-28 18:29:25"} WARNING test:glide_frontend_element.py:1320 {"event": "failed to create /tmp/tmpho8alque/tokens.d/test_entry.idtoken: module 'jwt' has no attribute 'encode'", "level": "warning", "logger": "test", "timestamp": "2023-09-28 18:29:25"} WARNING test:glide_frontend_element.py:1322 {"event": "", "level": "warning", "logger": "test", "timestamp": "2023-09-28 18:29:25"} WARNING test:glide_frontend_element.py:1322 {"event": "module 'jwt' has no attribute 'encode'", "level": "warning", "logger": "test", "timestamp": "2023-09-28 18:29:25"} WARNING test:glide_frontend_element.py:1322 {"event": "", "level": "warning", "logger": "test", "timestamp": "2023-09-28 18:29:25"} ```

where it is highlighted the missing encode attribute for jwt module. Indeed this attribute is available in the PyJWT implementation of jwt. Checking in pypi.org, jwt has not been updated in about 2 years, so it doesn't seem to be actively maintained, while PyJWT got updates about two months ago.

Running unit test interactively the test_refresh_entry_token test is OK.

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (e917838) 47.23% compared to head (deb03fe) 47.23%. Report is 6 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #474 +/- ## ======================================= Coverage 47.23% 47.23% ======================================= Files 54 54 Lines 2907 2907 Branches 498 498 ======================================= Hits 1373 1373 Misses 1433 1433 Partials 101 101 ``` | [Flag](https://app.codecov.io/gh/HEPCloud/decisionengine_modules/pull/474/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HEPCloud) | Coverage Δ | | |---|---|---| | [python-3.8](https://app.codecov.io/gh/HEPCloud/decisionengine_modules/pull/474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HEPCloud) | `47.23% <ø> (ø)` | | | [python-3.9](https://app.codecov.io/gh/HEPCloud/decisionengine_modules/pull/474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HEPCloud) | `47.23% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HEPCloud#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/HEPCloud/decisionengine_modules/pull/474?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HEPCloud) | Coverage Δ | | |---|---|---| | [setup.py](https://app.codecov.io/gh/HEPCloud/decisionengine_modules/pull/474?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HEPCloud#diff-c2V0dXAucHk=) | `0.00% <ø> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.