-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from zcutlip/dev/187-handle-missing-op-config…
…-gracefully issue #187 handle missing op config gracefully
- Loading branch information
Showing
17 changed files
with
208 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/config/mock-op/no-conf-no-bio-response-directory.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"meta": { | ||
"response_dir": "tests/config/mock-op/responses-no-conf-no-bio", | ||
"input_dir": "input" | ||
}, | ||
"commands": { | ||
"--account|5GHHPJK5HZC5BAT7WDUXW57G44|--format|json|whoami": { | ||
"exit_status": 1, | ||
"stdout": "output", | ||
"stderr": "error_output", | ||
"name": "whoami-account-uuid", | ||
"changes_state": false | ||
}, | ||
"--version": { | ||
"exit_status": 0, | ||
"stdout": "output", | ||
"stderr": "error_output", | ||
"name": "cli-version", | ||
"changes_state": false | ||
}, | ||
"--format|json|account|list": { | ||
"exit_status": 0, | ||
"stdout": "output", | ||
"stderr": "error_output", | ||
"name": "list-signed-in-accounts", | ||
"changes_state": false | ||
}, | ||
"--format|json|whoami": { | ||
"exit_status": 1, | ||
"stdout": "output", | ||
"stderr": "error_output", | ||
"name": "whoami", | ||
"changes_state": false | ||
} | ||
}, | ||
"commands_with_input": {} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ock-op/response-generation/no-initial-auth-no-conf/response-generation-no-conf-no-bio.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[MAIN] | ||
config-path = ./tests/config/mock-op | ||
response-path = responses-no-conf-no-bio | ||
response-dir-file = no-conf-no-bio-response-directory.json | ||
ignore-signin-fail = true | ||
skip-global-signin = True | ||
|
||
|
||
# be sure to do the following before generating responses | ||
# - remove ~/.config/op | ||
# - disable TouchID (or other biometric) in 1Password.app developer settings | ||
[cli-version] | ||
type = cli-version | ||
create-instance = False | ||
|
||
[list-signed-in-accounts] | ||
type = account-list | ||
create-instance = False | ||
# account_list returns an empty list, but succeeds | ||
expected-return = 0 | ||
|
||
[whoami] | ||
type = whoami | ||
create-instance = False | ||
expected-return = 1 |
Empty file.
1 change: 1 addition & 0 deletions
1
tests/config/mock-op/responses-no-conf-no-bio/cli-version/output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.26.0 |
Empty file.
1 change: 1 addition & 0 deletions
1
tests/config/mock-op/responses-no-conf-no-bio/list-signed-in-accounts/output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
1 change: 1 addition & 0 deletions
1
tests/config/mock-op/responses-no-conf-no-bio/whoami-account-uuid/error_output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ERROR] 2024/03/19 19:33:50 no account found for filter 5GHHPJK5HZC5BAT7WDUXW57G44 |
Empty file.
1 change: 1 addition & 0 deletions
1
tests/config/mock-op/responses-no-conf-no-bio/whoami/error_output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ERROR] 2024/03/19 19:34:06 no account found for filter |
Empty file.
2 changes: 1 addition & 1 deletion
2
...ock-op/responses-user-edit/new-user-name/responses-2/user-get-orig-user-name/error_output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[ERROR] 2023/12/15 21:26:48 "Zachary Cutlip" isn't a user in this account. Specify the user with their UUID, email address, or name. | ||
[ERROR] 2023/12/15 21:26:48 "Example User" isn't a user in this account. Specify the user with their UUID, email address, or name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import pytest | ||
|
||
from pyonepassword import OP | ||
from pyonepassword.api.exceptions import OPConfigNotFoundException | ||
from pyonepassword.op_cli_version import OPCLIVersion | ||
from pyonepassword.py_op_exceptions import OPWhoAmiException | ||
|
||
|
||
@pytest.mark.usefixtures("invalid_op_cli_config_missing") | ||
@pytest.mark.usefixtures("setup_no_conf_no_bio_env") | ||
def test_missing_op_config_010(console_logger): | ||
|
||
with pytest.raises(OPConfigNotFoundException): | ||
OP(op_path="mock-op", logger=console_logger) | ||
|
||
|
||
@pytest.mark.usefixtures("invalid_op_cli_config_missing") | ||
@pytest.mark.usefixtures("setup_no_conf_no_bio_env") | ||
def test_missing_op_config_020(console_logger): | ||
""" | ||
Simulate: | ||
- running op --format json account list with no ~/.config/op/ | ||
- Integration with the desktop app, and hence biometric, is disabled | ||
Verify: | ||
an empty list is returned | ||
""" | ||
OP.set_logger(console_logger) | ||
accounts = OP._get_account_list(op_path="mock-op") | ||
assert len(accounts) == 0 | ||
|
||
|
||
@pytest.mark.usefixtures("invalid_op_cli_config_missing") | ||
@pytest.mark.usefixtures("setup_no_conf_no_bio_env") | ||
def test_missing_op_config_030(console_logger): | ||
""" | ||
Simulate: | ||
- running op --format json whoami with no ~/.config/op/ | ||
- Integration with the desktop app, and hence biometric, is disabled | ||
Verify: | ||
OPWhoAmiException is raised | ||
""" | ||
OP.set_logger(console_logger) | ||
with pytest.raises(OPWhoAmiException): | ||
OP._whoami(op_path="mock-op") | ||
|
||
|
||
@pytest.mark.usefixtures("invalid_op_cli_config_missing") | ||
@pytest.mark.usefixtures("setup_no_conf_no_bio_env") | ||
def test_missing_op_config_040(console_logger): | ||
""" | ||
Simulate: | ||
- running op --version with no ~/.config/op/ | ||
- Integration with the desktop app, and hence biometric, is disabled | ||
Verify: | ||
a version is returned | ||
version is instance of OPCLIVersion | ||
""" | ||
OP.set_logger(console_logger) | ||
version = OP._get_cli_version(op_path="mock-op") | ||
assert version | ||
assert isinstance(version, OPCLIVersion) | ||
|
||
|
||
@pytest.mark.usefixtures("invalid_op_cli_config_missing") | ||
@pytest.mark.usefixtures("setup_no_conf_no_bio_env") | ||
def test_missing_op_config_050(console_logger): | ||
""" | ||
Simulate: | ||
- running op --format json whoami <account_uuid> with no ~/.config/op/ | ||
- Integration with the desktop app, and hence biometric, is disabled | ||
Verify: | ||
OPWhoAmiException is raised | ||
""" | ||
account_uuid = "5GHHPJK5HZC5BAT7WDUXW57G44" | ||
OP.set_logger(console_logger) | ||
with pytest.raises(OPWhoAmiException): | ||
OP._whoami(op_path="mock-op", account=account_uuid) |