Skip to content

Commit

Permalink
chore: removed unexpected changes
Browse files Browse the repository at this point in the history
those changes were caused by long-running MR. some changes were applied
to develop, and were rewritten.
  • Loading branch information
Aleksandr Chikovani committed Dec 18, 2024
1 parent 257a473 commit fc1011e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[run]
source = ./
omit = mlflow_oidc_auth/tests/*,mlflow_oidc_auth/db/migrations/versions/*
omit = mlflow_oidc_auth/tests/*,mlflow_oidc_auth/db/migrations/versions/*,mlflow_oidc_auth/views/*
11 changes: 1 addition & 10 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,13 @@ jobs:
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: 3.11
- name: Install build dependencies
- name: Run tests
run: |
python -m pip install --upgrade pip
pip install tox
tox -e py
- name: Build coverage file
run: |
tox -e py
pytest --cache-clear --junitxml=coverage.xml --cov-report=term-missing:skip-covered --cov=mlflow_oidc_auth > pytest-coverage.txt
- name: Override Coverage Source Path for Sonar
run: sed -i "s@<source>/home/runner/work/mlflow-oidc-auth/mlflow-oidc-auth</source>@<source>/github/workspace</source>@g" /home/runner/work/mlflow-oidc-auth/mlflow-oidc-auth/coverage.xml
- name: debug cov
run: |
pwd
ls -alh
head -n50 coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 # v2.3.0
env:
Expand Down
24 changes: 24 additions & 0 deletions mlflow_oidc_auth/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
authenticate_request_basic_auth,
authenticate_request_bearer_token,
)
import importlib


class TestAuth:
Expand Down Expand Up @@ -33,6 +34,29 @@ def test_get_oauth_instance(self, mock_config, mock_oauth):
)
assert result == mock_oauth_instance

def test__get_oidc_jwks(self):
with patch("mlflow_oidc_auth.auth.requests") as mock_requests:
mlflow_oidc_app = importlib.import_module("mlflow_oidc_auth.app")
mock_cache = MagicMock()
mock_app = MagicMock()
mock_app.logger.debug = MagicMock()
mock_requests.get.return_value.json.return_value = {"jwks_uri": "mock_jwks_uri"}
mock_cache.get.return_value = None

with patch.object(mlflow_oidc_app, "cache", mock_cache):
with patch.object(mlflow_oidc_app, "app", mock_app):
result = _get_oidc_jwks()

assert len(mock_requests.get.call_args) == 2

assert mock_requests.get.call_args[0][0] == "mock_jwks_uri"
assert mock_requests.get.call_args[1] == {} # TODO: proper patch for first .get() return_value

mock_cache.set.assert_called_once_with(
"jwks", mock_requests.get.return_value.json.return_value, timeout=3600
)
assert result == mock_requests.get.return_value.json.return_value

@patch("mlflow_oidc_auth.auth._get_oidc_jwks")
@patch("mlflow_oidc_auth.auth.jwt.decode")
def test_validate_token(self, mock_jwt_decode, mock_get_oidc_jwks):
Expand Down
33 changes: 20 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,38 @@ classifiers = [
requires-python = ">=3.8"
dependencies = [
"cachelib<1",
"mlflow-skinny<3,>=2.11.1",
"mlflow<3,>=2.11.1",
"oauthlib<4",
"python-dotenv<2",
"requests<3,>=2.31.0",
"sqlalchemy<3,>=1.4.0",
"Flask<4",
"Flask-Session>=0.7.0",
"gunicorn<24; platform_system != 'Windows'",
"alembic<2,!=1.10.0",
"Authlib<2",
"Flask-Caching<3",
"authlib>=1.3.2",
"flask-caching>=2.3.0"
]

[project.optional-dependencies]
full = ["mlflow<3,>=2.11.1"]
caching-redis = ["redis[hiredis]<6"]
dev = [
"black==24.8.0",
"pytest==8.3.2",
"pre-commit==3.5.0",
]
test = [
"pytest==8.3.2",
"pytest-cov==5.0.0",
]

[[project.maintainers]]
name = "Data Platform folks"
email = "noreply@example.com"
name = "Alexander Kharkevich"
email = "alexander_kharkevich@outlook.com"

[project.license]
file = "LICENSE"
Expand Down Expand Up @@ -72,14 +90,3 @@ version = {attr = "mlflow_oidc_auth.version"}

[tool.black]
line-length = 128

[project.optional-dependencies]
dev = [
"black==24.8.0",
"pytest==8.3.2",
"pre-commit==3.5.0",
]
test = [
"pytest==8.3.2",
"pytest-cov==5.0.0",
]
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ sonar.organization=data-platform-hq
sonar.python.version=3.11
sonar.python.coverage.reportPaths=coverage.xml
sonar.test.inclusions=**/test_*.py
sonar.coverage.exclusions==**/test_*.py,**/app.py,**/db/migrations/versions/**/*.*,**/sqlalchemy_store.py,**/views.py # TODO: review sqlalchemy_store.py and views.py
sonar.coverage.exclusions==**/test_*.py,**/app.py,**/db/migrations/versions/**/*.*,mlflow_oidc_auth/views/*

0 comments on commit fc1011e

Please sign in to comment.