forked from basecamp/kamal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dependencies check and improve methods
- Loading branch information
1 parent
580e1a1
commit d08bd04
Showing
2 changed files
with
31 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ class DashlaneAdapterTest < SecretAdapterTestCase | |
end | ||
|
||
test "fetch" do | ||
stub_ticks.with("dcli accounts whoami").returns("[email protected]") | ||
stub_ticks.with("dcli --version 2> /dev/null") | ||
stub_ticks.with("dcli accounts whoami < /dev/null").returns("[email protected]") | ||
|
||
stub_ticks | ||
.with("dcli secret SECRET1 FOLDER1/FSECRET1 FOLDER1/FSECRET2 -o json") | ||
|
@@ -63,7 +64,8 @@ class DashlaneAdapterTest < SecretAdapterTestCase | |
end | ||
|
||
test "fetch with from" do | ||
stub_ticks.with("dcli accounts whoami").returns("[email protected]") | ||
stub_ticks.with("dcli --version 2> /dev/null") | ||
stub_ticks.with("dcli accounts whoami < /dev/null").returns("[email protected]") | ||
|
||
stub_ticks | ||
.with("dcli secret FOLDER1/FSECRET1 FOLDER1/FSECRET2 -o json") | ||
|
@@ -107,8 +109,9 @@ class DashlaneAdapterTest < SecretAdapterTestCase | |
end | ||
|
||
test "fetch with signin" do | ||
stub_ticks_with("dcli accounts whoami", succeed: false).returns("") | ||
stub_ticks_with("dcli sync", succeed: true).returns("") | ||
stub_ticks.with("dcli --version 2> /dev/null") | ||
stub_ticks_with("dcli accounts whoami < /dev/null", succeed: false).returns("") | ||
stub_ticks_with("(echo [email protected]; cat) | dcli sync").returns("") | ||
stub_ticks.with("dcli secret SECRET1 -o json").returns(single_item_json) | ||
|
||
json = JSON.parse(shellunescape(run_command("fetch", "SECRET1"))) | ||
|
@@ -120,6 +123,15 @@ class DashlaneAdapterTest < SecretAdapterTestCase | |
assert_equal expected_json, json | ||
end | ||
|
||
test "fetch without CLI installed" do | ||
stub_ticks_with("dcli --version 2> /dev/null", succeed: false) | ||
|
||
error = assert_raises RuntimeError do | ||
JSON.parse(shellunescape(run_command("fetch", "SECRET1"))) | ||
end | ||
assert_equal "Dashlane CLI is not installed", error.message | ||
end | ||
|
||
private | ||
def run_command(*command) | ||
stdouted do | ||
|