Skip to content

Commit

Permalink
Don't delete account_info_file
Browse files Browse the repository at this point in the history
  • Loading branch information
agoncharov-reef committed Mar 21, 2024
1 parent 9a502ad commit bd44cb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 0 additions & 6 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,6 @@ def account_info_file() -> pathlib.Path:
return pathlib.Path(os.environ[B2_ACCOUNT_INFO_ENV_VAR]).expanduser()


@pytest.fixture
def no_account_info_file(account_info_file):
"""Remove account info file to deauthorize b2_tool"""
yield account_info_file.unlink()


@pytest.fixture
def schedule_bucket_cleanup(global_b2_tool):
"""
Expand Down
19 changes: 12 additions & 7 deletions test/integration/test_b2_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ def test_authorize_account_via_params_saving_credentials(
application_key,
application_key_id,
account_info_file,
no_account_info_file,
):
"""
When calling `authorize-account` and passing credentials as params,
we want the credentials to be saved.
"""

assert not account_info_file.exists()
b2_tool.should_succeed(['clear-account'])

assert B2_APPLICATION_KEY_ID_ENV_VAR not in os.environ
assert B2_APPLICATION_KEY_ENV_VAR not in os.environ

Expand All @@ -91,14 +91,14 @@ def test_authorize_account_via_env_vars_saving_credentials(
application_key,
application_key_id,
account_info_file,
no_account_info_file,
):
"""
When calling `authorize-account` and passing credentials
via env vars, we still want the credentials to be saved.
"""

assert not account_info_file.exists()
b2_tool.should_succeed(['clear-account'])

assert B2_APPLICATION_KEY_ID_ENV_VAR not in os.environ
assert B2_APPLICATION_KEY_ENV_VAR not in os.environ

Expand Down Expand Up @@ -154,15 +154,15 @@ def test_command_with_env_vars_not_saving_credentials(
application_key_id,
account_info_file,
bucket_name,
no_account_info_file,
b2_uri_args,
):
"""
When calling any command other then `authorize-account` and passing credentials
via env vars, we don't want them to be saved.
"""

assert not account_info_file.exists()
b2_tool.should_succeed(['clear-account'])

assert B2_APPLICATION_KEY_ID_ENV_VAR not in os.environ
assert B2_APPLICATION_KEY_ENV_VAR not in os.environ

Expand All @@ -174,7 +174,12 @@ def test_command_with_env_vars_not_saving_credentials(
}
)

assert not account_info_file.exists()
assert account_info_file.exists()
account_info = SqliteAccountInfo()
with pytest.raises(MissingAccountData):
account_info.get_application_key()
with pytest.raises(MissingAccountData):
account_info.get_application_key_id()


@pytest.fixture
Expand Down

0 comments on commit bd44cb1

Please sign in to comment.