This is an automated email from the ASF dual-hosted git repository.
vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 3722c7f84d7 Add unit tests for auth manager login datamodels (#72265)
(#75544)
3722c7f84d7 is described below
commit 3722c7f84d7e8603c1a104e455dc6b4d0e650c1b
Author: Anisayak Mitra <[email protected]>
AuthorDate: Thu Oct 29 02:11:11 2026 +0530
Add unit tests for auth manager login datamodels (#72265) (#75544)
---
.../tests/unit/always/test_project_structure.py | 2 -
.../amazon/aws/auth_manager/datamodels/__init__.py | 16 ++++++++
.../aws/auth_manager/datamodels/test_login.py | 46 ++++++++++++++++++++++
.../api_fastapi/datamodels/test_login.py | 45 +++++++++++++++++++++
4 files changed, 107 insertions(+), 2 deletions(-)
diff --git a/airflow-core/tests/unit/always/test_project_structure.py
b/airflow-core/tests/unit/always/test_project_structure.py
index 100094f8f78..aa43f5013f1 100644
--- a/airflow-core/tests/unit/always/test_project_structure.py
+++ b/airflow-core/tests/unit/always/test_project_structure.py
@@ -61,7 +61,6 @@ class TestProjectStructure:
# A long-standing bug in the test below allowed modules without tests
to go undetected.
# This list tracks those modules and should shrink to zero as tests
are added.
OVERLOOKED_TESTS = [
-
"providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/test_login.py",
"providers/amazon/tests/unit/amazon/aws/executors/batch/test_batch_executor_config.py",
"providers/amazon/tests/unit/amazon/aws/executors/ecs/test_ecs_executor_config.py",
"providers/amazon/tests/unit/amazon/aws/executors/aws_lambda/test_utils.py",
@@ -77,7 +76,6 @@ class TestProjectStructure:
"providers/cncf/kubernetes/tests/unit/cncf/kubernetes/test_python_kubernetes_script.py",
"providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_delete_from.py",
"providers/common/compat/tests/unit/common/compat/standard/test_utils.py",
-
"providers/fab/tests/unit/fab/auth_manager/api_fastapi/datamodels/test_login.py",
"providers/fab/tests/unit/fab/migrations/test_env.py",
"providers/fab/tests/unit/fab/www/extensions/test_init_appbuilder.py",
"providers/fab/tests/unit/fab/www/extensions/test_init_jinja_globals.py",
diff --git
a/providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/__init__.py
b/providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/__init__.py
new file mode 100644
index 00000000000..13a83393a91
--- /dev/null
+++ b/providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
diff --git
a/providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/test_login.py
b/providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/test_login.py
new file mode 100644
index 00000000000..29f07ed916b
--- /dev/null
+++
b/providers/amazon/tests/unit/amazon/aws/auth_manager/datamodels/test_login.py
@@ -0,0 +1,46 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import pytest
+
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
+if not AIRFLOW_V_3_0_PLUS:
+ pytest.skip("AWS auth manager is only compatible with Airflow >= 3.0.0",
allow_module_level=True)
+
+from pydantic import ValidationError
+
+from airflow.providers.amazon.aws.auth_manager.datamodels.login import
LoginResponse
+
+
+class TestLoginResponse:
+ def test_login_response_valid(self):
+ token = "test_aws_jwt_access_token_12345"
+ response = LoginResponse(access_token=token)
+ assert response.access_token == token
+ assert response.model_dump() == {"access_token": token}
+
+ def test_login_response_from_dict(self):
+ data = {"access_token": "valid_token"}
+ response = LoginResponse.model_validate(data)
+ assert response.access_token == "valid_token"
+
+ def test_login_response_missing_access_token(self):
+ with pytest.raises(ValidationError):
+ LoginResponse.model_validate({})
diff --git
a/providers/fab/tests/unit/fab/auth_manager/api_fastapi/datamodels/test_login.py
b/providers/fab/tests/unit/fab/auth_manager/api_fastapi/datamodels/test_login.py
new file mode 100644
index 00000000000..165ca034b6c
--- /dev/null
+++
b/providers/fab/tests/unit/fab/auth_manager/api_fastapi/datamodels/test_login.py
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import pytest
+
+from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
+
+if not AIRFLOW_V_3_0_PLUS:
+ pytest.skip("FAB auth manager is only compatible with Airflow >= 3.0.0",
allow_module_level=True)
+
+from pydantic import ValidationError
+
+from airflow.providers.fab.auth_manager.api_fastapi.datamodels.login import
LoginResponse
+
+
+class TestLoginResponse:
+ def test_login_response_valid(self):
+ token = "test_fab_jwt_access_token_67890"
+ response = LoginResponse(access_token=token)
+ assert response.access_token == token
+ assert response.model_dump() == {"access_token": token}
+
+ def test_login_response_from_dict(self):
+ data = {"access_token": "valid_token"}
+ response = LoginResponse.model_validate(data)
+ assert response.access_token == "valid_token"
+
+ def test_login_response_missing_access_token(self):
+ with pytest.raises(ValidationError):
+ LoginResponse.model_validate({})