Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/auth_manager/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def login_callback(self):
user_id=attributes["id"][0],
groups=attributes["groups"],
username=saml_auth.get_nameid(),
email=attributes["email"][0] if "email" in attributes else None,
email=attributes["email"][0],
)
session["aws_user"] = user

Expand Down
12 changes: 4 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,15 +1092,11 @@ def refuse_to_run_test_from_wrongly_named_files(request):
dirname: str = request.node.fspath.dirname
filename: str = request.node.fspath.basename
is_system_test: bool = "tests/system/" in dirname
if is_system_test and not (
request.node.fspath.basename.startswith("example_")
or request.node.fspath.basename.startswith("test_")
):
if is_system_test and not request.node.fspath.basename.startswith("example_"):
raise Exception(
f"All test method files in tests/system must start with 'example_' or 'test_'. "
f"Seems that {filename} contains {request.function} that looks like a test case. "
f"Please rename the file to follow the example_* or test_* pattern if you want to run the tests "
f"in it."
f"All test method files in tests/system must start with 'example_'. Seems that {filename} "
f"contains {request.function} that looks like a test case. Please rename the file to "
f"follow the example_* pattern if you want to run the tests in it."
)
if not is_system_test and not request.node.fspath.basename.startswith("test_"):
raise Exception(
Expand Down
33 changes: 18 additions & 15 deletions tests/providers/amazon/aws/auth_manager/views/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,24 @@

@pytest.fixture
def aws_app():
with conf_vars(
{
(
"core",
"auth_manager",
): "airflow.providers.amazon.aws.auth_manager.aws_auth_manager.AwsAuthManager",
("aws_auth_manager", "enable"): "True",
("aws_auth_manager", "saml_metadata_url"): SAML_METADATA_URL,
}
):
with patch(
"airflow.providers.amazon.aws.auth_manager.views.auth.OneLogin_Saml2_IdPMetadataParser"
) as mock_parser:
mock_parser.parse_remote.return_value = SAML_METADATA_PARSED
return application.create_app(testing=True)
def factory():
with conf_vars(
{
(
"core",
"auth_manager",
): "airflow.providers.amazon.aws.auth_manager.aws_auth_manager.AwsAuthManager",
("aws_auth_manager", "enable"): "True",
("aws_auth_manager", "saml_metadata_url"): SAML_METADATA_URL,
}
):
with patch(
"airflow.providers.amazon.aws.auth_manager.views.auth.OneLogin_Saml2_IdPMetadataParser"
) as mock_parser:
mock_parser.parse_remote.return_value = SAML_METADATA_PARSED
return application.create_app(testing=True)

return factory()


@pytest.mark.db_test
Expand Down
16 changes: 0 additions & 16 deletions tests/system/providers/amazon/aws/tests/__init__.py

This file was deleted.

210 changes: 0 additions & 210 deletions tests/system/providers/amazon/aws/tests/test_aws_auth_manager.py

This file was deleted.

8 changes: 3 additions & 5 deletions tests/system/providers/amazon/aws/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
DEFAULT_ENV_ID: str = f"{DEFAULT_ENV_ID_PREFIX}{uuid4()!s:.{DEFAULT_ENV_ID_LEN}}"
PURGE_LOGS_INTERVAL_PERIOD = 5

# All test file names will contain one of these strings.
TEST_FILE_IDENTIFIERS: list[str] = ["example", "test"]
# All test file names will contain this string.
TEST_FILE_IDENTIFIER: str = "example"

INVALID_ENV_ID_MSG: str = (
"In order to maximize compatibility, the SYSTEM_TESTS_ENV_ID must be an alphanumeric string "
Expand All @@ -68,9 +68,7 @@ def _get_test_name() -> str:
# The exact layer of the stack will depend on if this is called directly
# or from another helper, but the test will always contain the identifier.
test_filename: str = next(
frame.filename
for frame in inspect.stack()
if any(identifier in frame.filename for identifier in TEST_FILE_IDENTIFIERS)
frame.filename for frame in inspect.stack() if TEST_FILE_IDENTIFIER in frame.filename
)
return Path(test_filename).stem

Expand Down