Skip to content

Conversation

@nss10
Copy link
Contributor

@nss10 nss10 commented Dec 12, 2025

Link to JIRA ticket if there is one: PD-77

New Features

Breaking Changes

Bug Fixes

Improvements

  • Replace raw strings in session.execute() with sqlalchemy.text
  • Update deprecated datetime.utcnow() and datetime.utcfromtimestamp() with 3.13 compatible equivalents
  • Replace deprecated request attributes with request.payload
  • Replace deprecated SqlAlchemy's query.get() with Session.get()
  • Eliminate all boto usage in favor of boto3
  • Add a local implementation of strtobool since distutils is no longer available since Python 3.12
  • Add NoAsyncMagicMock since MagicMock returns AsyncMocks even if the source object is partially async
  • Replace assert <mocked_method>.not_called with <mocked_method>.assert_not_called

Dependency updates

  • Update Fence to Python 3.13

Deployment changes

  • Change Docker image to run with gen3 user instead of root

nss10 added 26 commits October 10, 2025 14:54
@coveralls
Copy link

coveralls commented Dec 12, 2025

Pull Request Test Coverage Report for Build 20471262045

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 423 unchanged lines in 17 files lost coverage.
  • Overall coverage increased (+0.02%) to 75.002%

Files with Coverage Reduction New Missed Lines %
blueprints/misc.py 1 88.24%
ea7e1b843f82_optional_client_redirect_uri.py 1 81.82%
resources/audit/client.py 1 77.31%
scripting/google_monitor.py 1 40.17%
a04a70296688_non_unique_client_name.py 2 89.47%
blueprints/oauth2.py 2 76.03%
blueprints/login/ras.py 6 75.47%
blueprints/data/blueprint.py 13 86.9%
resources/ga4gh/passports.py 15 89.13%
9b3a5a7145d7_authlib_update_1_2_1.py 18 60.22%
Totals Coverage Status
Change from base Build 20076693184: 0.02%
Covered Lines: 8440
Relevant Lines: 11253

💛 - Coveralls

@github-actions
Copy link

Failed to Prepare CI environment

Please find the Github Action logs here

@github-actions
Copy link

filepath passed failed skipped SUBTOTAL
tests/test_oauth2.py 15 0 0 15
tests/test_centralized_auth.py 16 0 0 16
tests/test_audit_service.py 3 0 3 6
tests/test_data_upload.py 8 0 1 9
tests/test_presigned_url.py 7 0 0 7
tests/test_dbgap.py 2 2 1 5
tests/test_drs_endpoint.py 4 0 0 4
tests/test_user_token.py 5 0 0 5
tests/test_register_user.py 2 0 0 2
tests/test_client_credentials.py 1 0 0 1
tests/test_oidc_client.py 1 1 0 2
tests/test_google_data_access.py 1 0 0 1
tests/test_ras_authn.py 0 0 3 3
TOTAL 65 3 8 76

Please find the detailed integration test report here

Please find the Github Action logs here

@github-actions
Copy link

filepath passed failed skipped SUBTOTAL
tests/test_oauth2.py 15 0 0 15
tests/test_centralized_auth.py 16 0 0 16
tests/test_audit_service.py 3 0 3 6
tests/test_data_upload.py 8 0 1 9
tests/test_presigned_url.py 7 0 0 7
tests/test_dbgap.py 2 2 1 5
tests/test_drs_endpoint.py 4 0 0 4
tests/test_user_token.py 5 0 0 5
tests/test_register_user.py 2 0 0 2
tests/test_oidc_client.py 2 0 0 2
tests/test_google_data_access.py 1 0 0 1
tests/test_client_credentials.py 1 0 0 1
tests/test_ras_authn.py 0 0 3 3
TOTAL 66 2 8 76

Please find the detailed integration test report here

Please find the Github Action logs here

patchers.append(patcher)

# create a fresh local app
from flask import Flask
Copy link
Contributor Author

@nss10 nss10 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did not throw an error in older versions of fence due to the order in which tests ran.

headers = {"Authorization": "Bearer " + encoded_creds_jwt.jwt}
response = client.delete("/data/{}".format(did), headers=headers)
assert response.status_code == 204
assert mock_boto_delete.called_once()
Copy link
Contributor Author

@nss10 nss10 Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since IndexedFile.delete_files is patched with a MagicMock, we never really hit the core boto delete functionality in the past, since we were patching IndexedFile.delete_files before we reached the core functionality we wanted to test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests were passing in the past, because assert .called_once() returned a new MagicMock which is non-falsy in nature, making the assert to pass

"""
raise Exception("url not available")

with patch("fence.blueprints.data.indexd.flask.current_app", return_value=app):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since flask is coming from a fixture, flask.current_app is already set to app.
Setting this patch, was making everything internally to MagicMock. Removing this patch altogether tests the logic better

assert username_to_log_in == username
iss_sub_pair_to_user_records = db_session.query(IssSubPairToUser).all()
assert len(iss_sub_pair_to_user_records) == 1
iss_sub_pair_to_user = db_session.query(IssSubPairToUser).get((iss, sub))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# LegacyAPIWarning: The Query.get() method is considered legacy as of the 1.x series of SQLAlchemy and becomes a legacy construct in 2.0. The method is now available as Session.get() (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)

@github-actions
Copy link

Failed to Prepare CI environment

Please find the Github Action logs here

@github-actions
Copy link

filepath passed skipped SUBTOTAL
tests/test_oauth2.py 15 0 15
tests/test_centralized_auth.py 16 0 16
tests/test_audit_service.py 3 3 6
tests/test_data_upload.py 8 1 9
tests/test_presigned_url.py 7 0 7
tests/test_user_token.py 5 0 5
tests/test_dbgap.py 4 1 5
tests/test_drs_endpoint.py 4 0 4
tests/test_oidc_client.py 2 0 2
tests/test_client_credentials.py 1 0 1
tests/test_google_data_access.py 1 0 1
tests/test_register_user.py 2 0 2
tests/test_ras_authn.py 0 3 3
TOTAL 68 8 76

Please find the detailed integration test report here

Please find the Github Action logs here

@nss10 nss10 requested review from Avantol13 and k-burt-uch and removed request for k-burt-uch December 19, 2025 03:24
@nss10 nss10 requested a review from paulineribeyre December 23, 2025 17:05
Copy link
Contributor

@paulineribeyre paulineribeyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just minor comments!

pyproject.toml Outdated
"gunicorn", # not imported but used in Dockerfile
"psycopg2-binary", # not imported but used by sqlalchemy
"urllib3", # Needed to be pinned to a version >=2.6.0
"sniffio", # required by gen3authz, but not installed as a transitive dependency during poetry install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added it here, if you upgrade gen3authz to the latest version you should be able to remove sniffio here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gen3authz 3.0.0 requires backoff>=2.2.1, but fence has backoff pinned to <2 several years ago. I'm trying to remove that restriction and run unit tests to see if anything breaks.

@github-actions
Copy link

filepath passed failed skipped SUBTOTAL
tests/test_oauth2.py 15 0 0 15
tests/test_centralized_auth.py 15 1 0 16
tests/test_audit_service.py 3 0 3 6
tests/test_data_upload.py 8 0 1 9
tests/test_presigned_url.py 7 0 0 7
tests/test_dbgap.py 4 0 1 5
tests/test_drs_endpoint.py 4 0 0 4
tests/test_register_user.py 2 0 0 2
tests/test_user_token.py 5 0 0 5
tests/test_google_data_access.py 1 0 0 1
tests/test_client_credentials.py 1 0 0 1
tests/test_oidc_client.py 2 0 0 2
tests/test_ras_authn.py 0 0 3 3
TOTAL 67 1 8 76

Please find the detailed integration test report here

Please find the Github Action logs here

run_async(updater_queue.put(mock_users[0]))

# Mock the client to return a valid update process
mock_oidc_clients[0].update_user_authorization = AsyncMock()
Copy link
Contributor Author

@nss10 nss10 Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nss10 nss10 requested a review from paulineribeyre December 23, 2025 19:11
Copy link
Contributor

@paulineribeyre paulineribeyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just need to update gen3authz and remove the sniffio dependency if you can

@github-actions
Copy link

filepath passed failed skipped SUBTOTAL
tests/test_oauth2.py 15 0 0 15
tests/test_centralized_auth.py 16 0 0 16
tests/test_audit_service.py 3 0 3 6
tests/test_data_upload.py 8 0 1 9
tests/test_presigned_url.py 7 0 0 7
tests/test_dbgap.py 4 0 1 5
tests/test_user_token.py 4 1 0 5
tests/test_drs_endpoint.py 4 0 0 4
tests/test_register_user.py 2 0 0 2
tests/test_google_data_access.py 1 0 0 1
tests/test_oidc_client.py 2 0 0 2
tests/test_client_credentials.py 1 0 0 1
tests/test_ras_authn.py 0 0 3 3
TOTAL 67 1 8 76

Please find the detailed integration test report here

Please find the Github Action logs here

@github-actions
Copy link

filepath passed failed skipped SUBTOTAL
tests/test_oauth2.py 15 0 0 15
tests/test_centralized_auth.py 15 1 0 16
tests/test_audit_service.py 3 0 3 6
tests/test_data_upload.py 8 0 1 9
tests/test_presigned_url.py 7 0 0 7
tests/test_dbgap.py 4 0 1 5
tests/test_drs_endpoint.py 4 0 0 4
tests/test_register_user.py 2 0 0 2
tests/test_user_token.py 5 0 0 5
tests/test_google_data_access.py 1 0 0 1
tests/test_client_credentials.py 1 0 0 1
tests/test_oidc_client.py 2 0 0 2
tests/test_ras_authn.py 0 0 3 3
TOTAL 67 1 8 76

Please find the detailed integration test report here

Please find the Github Action logs here

@github-actions
Copy link

filepath passed SUBTOTAL
tests/test_centralized_auth.py 16 16
TOTAL 16 16

Please find the detailed integration test report here

Please find the Github Action logs here

@nss10 nss10 requested a review from paulineribeyre December 29, 2025 18:03
@nss10 nss10 merged commit 12eb038 into master Jan 2, 2026
11 of 12 checks passed
@nss10 nss10 deleted the temp/python_313_gen3_user branch January 2, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants