From d1fd37f88ecb0d1acad99bbebcb7709d42ad26ac Mon Sep 17 00:00:00 2001 From: Jean-Pierre Sevigny <41591249+sevignyj@users.noreply.github.com> Date: Mon, 17 Jul 2023 11:35:56 -0400 Subject: [PATCH] hotfix 2.1.2: replace missing RawConfig, keep pytest between 7.0.0 and 7.3.1, and update help text. --- requirements-dev.txt | 2 +- tests/unit_test.py | 16 ++++++++-------- tokendito/__init__.py | 2 +- tokendito/user.py | 11 ++++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 32a7e1a9..45c51f1f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -13,7 +13,7 @@ pydocstyle pylint pyotp pyroma -pytest +pytest>=7.0.0,<=7.3.1 pytest-cov pytest-env pytest-mock diff --git a/tests/unit_test.py b/tests/unit_test.py index 57b077c2..e57336e8 100644 --- a/tests/unit_test.py +++ b/tests/unit_test.py @@ -504,14 +504,14 @@ def test_process_arguments(): from tokendito import user - valid_settings = dict(okta_username="pytest", okta_password="pytest_password") + valid_settings = dict(okta_username="pytest", okta_password="%pytest_!&%password^") invalid_settings = dict(pytest_expected_failure="pytest_failure") args = {**valid_settings, **invalid_settings} ret = user.process_arguments(Namespace(**args)) # Make sure that the arguments we passed are interpreted assert ret.okta["username"] == "pytest" - assert ret.okta["password"] == "pytest_password" + assert ret.okta["password"] == "%pytest_!&%password^" # Make sure that incorrect arguments are not passed down to the Config object. assert "pytest" not in ret.__dict__ @@ -549,7 +549,7 @@ def test_process_ini_file(tmpdir): from tokendito import user valid_settings = dict( - okta_password="pytest_password", + okta_password="%pytest_!&%password^", okta_username="pytest", ) invalid_settings = dict(user_pytest_expected_failure="pytest") @@ -559,7 +559,7 @@ def test_process_ini_file(tmpdir): user.update_ini("pytest", path, **valid_settings) ret = user.process_ini_file(path, "pytest") assert ret.okta["username"] == "pytest" - assert ret.okta["password"] == "pytest_password" + assert ret.okta["password"] == "%pytest_!&%password^" # Ensure we fail if the section is not found user.update_ini("pytest", path, **valid_settings) @@ -1134,7 +1134,7 @@ def test_config_object(): pytest_config_aws = Config(aws={"profile": "pytest_aws"}) pytest_config_okta = Config(okta={"username": "pytest_username"}) pytest_config_mixed = Config( - user={"config_profile": "pytest_user"}, okta={"password": "pytest_password"} + user={"config_profile": "pytest_user"}, okta={"password": "%pytest_!&%password^"} ) assert (pytest_config == pytest_config_aws) is False @@ -1149,7 +1149,7 @@ def test_config_object(): # Check that an update overwrites matching values only pytest_config.update(pytest_config_mixed) assert pytest_config.okta["username"] == "pytest_username" - assert pytest_config.okta["password"] == "pytest_password" + assert pytest_config.okta["password"] == "%pytest_!&%password^" assert pytest_config.user["config_profile"] == "pytest_user" # Check that default values from the original object are kept @@ -1214,7 +1214,7 @@ def test_process_interactive_input(mocker): from tokendito import user # Check that a good object retrieves an interactive password - mocker.patch("getpass.getpass", return_value="pytest_password") + mocker.patch("getpass.getpass", return_value="%pytest_!&%password^") pytest_config = Config() pytest_config.okta["tile"] = "https://pytest/tile" @@ -1222,7 +1222,7 @@ def test_process_interactive_input(mocker): pytest_config.okta["username"] = "pytest" ret = user.process_interactive_input(pytest_config) pytest_config.update(ret) - assert pytest_config.okta["password"] == "pytest_password" + assert pytest_config.okta["password"] == "%pytest_!&%password^" # Check that quiet mode does not retrieve a username pytest_config.user["quiet"] = True diff --git a/tokendito/__init__.py b/tokendito/__init__.py index 167f273b..5d2fab86 100644 --- a/tokendito/__init__.py +++ b/tokendito/__init__.py @@ -8,7 +8,7 @@ from platformdirs import user_config_dir -__version__ = "2.1.1" +__version__ = "2.1.2" __title__ = "tokendito" __description__ = "Get AWS STS tokens from Okta SSO" __long_description_content_type__ = "text/markdown" diff --git a/tokendito/user.py b/tokendito/user.py index 55d1a7d8..9fff2fb8 100644 --- a/tokendito/user.py +++ b/tokendito/user.py @@ -131,10 +131,15 @@ def parse_cli_args(args): "--okta-tile", help="Okta tile URL to use.", ) - parser.add_argument("--okta-mfa", help="Sets the MFA method") + parser.add_argument( + "--okta-mfa", + help="Sets the MFA method. You " + "can also use the TOKENDITO_OKTA_MFA environment variable.", + ) parser.add_argument( "--okta-mfa-response", - help="Sets the MFA response to a challenge", + help="Sets the MFA response to a challenge. You " + "can also use the TOKENDITO_OKTA_MFA_RESPONSE environment variable.", ) parser.add_argument( "--quiet", @@ -582,7 +587,7 @@ def process_ini_file(file, profile): res = dict() pattern = re.compile(r"^(.*?)_(.*)") - ini = configparser.ConfigParser(default_section=config.user["config_profile"]) + ini = configparser.RawConfigParser(default_section=config.user["config_profile"]) # Here, group(1) is the dictionary key, and group(2) the configuration element try: ini.read(file)