Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace missing RawConfig #129

Merged
merged 1 commit into from
Jul 19, 2023
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 requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pydocstyle
pylint
pyotp
pyroma
pytest
pytest>=7.0.0,<=7.3.1
pytest-cov
pytest-env
pytest-mock
Expand Down
16 changes: 8 additions & 8 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -1214,15 +1214,15 @@ 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"
pytest_config.okta["org"] = "https://pytest/"
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
Expand Down
2 changes: 1 addition & 1 deletion tokendito/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions tokendito/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
Loading