-
Notifications
You must be signed in to change notification settings - Fork 488
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 #1121 from kylerippey/adapter-cli-installation-checks
Raise meaningful error messages when secret adapter CLIs are not installed
- Loading branch information
Showing
8 changed files
with
87 additions
and
0 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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ class LastPassAdapterTest < SecretAdapterTestCase | |
end | ||
|
||
test "fetch" do | ||
stub_ticks.with("lpass --version 2> /dev/null") | ||
stub_ticks.with("lpass status --color never").returns("Logged in as [email protected].") | ||
|
||
stub_ticks | ||
|
@@ -63,6 +64,7 @@ class LastPassAdapterTest < SecretAdapterTestCase | |
end | ||
|
||
test "fetch with from" do | ||
stub_ticks.with("lpass --version 2> /dev/null") | ||
stub_ticks.with("lpass status --color never").returns("Logged in as [email protected].") | ||
|
||
stub_ticks | ||
|
@@ -107,6 +109,8 @@ class LastPassAdapterTest < SecretAdapterTestCase | |
end | ||
|
||
test "fetch with signin" do | ||
stub_ticks.with("lpass --version 2> /dev/null") | ||
|
||
stub_ticks_with("lpass status --color never", succeed: false).returns("Not logged in.") | ||
stub_ticks_with("lpass login [email protected]", succeed: true).returns("") | ||
stub_ticks.with("lpass show SECRET1 --json").returns(single_item_json) | ||
|
@@ -120,6 +124,15 @@ class LastPassAdapterTest < SecretAdapterTestCase | |
assert_equal expected_json, json | ||
end | ||
|
||
test "fetch without CLI installed" do | ||
stub_ticks_with("lpass --version 2> /dev/null", succeed: false) | ||
|
||
error = assert_raises RuntimeError do | ||
JSON.parse(shellunescape(run_command("fetch", "SECRET1", "FOLDER1/FSECRET1", "FOLDER1/FSECRET2"))) | ||
end | ||
assert_equal "LastPass CLI is not installed", error.message | ||
end | ||
|
||
private | ||
def run_command(*command) | ||
stdouted do | ||
|
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