Add ssh-keys core plugin

This commit is contained in:
Justin Clark
2016-06-30 17:34:07 -07:00
parent 0c5123410b
commit 283ed52520
9 changed files with 149 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bats
load test_helper
setup() {
create_key
}
teardown() {
destroy_key
}
@test "(ssh-keys) ssh-keys:add, ssh-keys:list, ssh-keys:remove" {
run /bin/bash -c "dokku ssh-keys:add name1 /tmp/testkey.pub"
echo "output: "$output
echo "status: "$status
assert_success
run /bin/bash -c "cat /tmp/testkey.pub | dokku ssh-keys:add name2"
echo "output: "$output
echo "status: "$status
assert_success
run /bin/bash -c "dokku ssh-keys:list | grep name1 && dokku ssh-keys:list | grep name2"
echo "output: "$output
echo "status: "$status
assert_success
run /bin/bash -c "dokku ssh-keys:remove name1"
echo "output: "$output
echo "status: "$status
assert_success
run /bin/bash -c "dokku ssh-keys:list | grep name1"
echo "output: "$output
echo "status: "$status
assert_failure
run /bin/bash -c "dokku ssh-keys:list | grep name2"
echo "output: "$output
echo "status: "$status
assert_success
}

View File

@@ -117,6 +117,12 @@ create_app() {
dokku apps:create "$TEST_APP"
}
create_key() {
touch "$DOKKU_ROOT/.ssh/authorized_keys" && chown dokku:dokku "$DOKKU_ROOT/.ssh/authorized_keys"
ssh-keygen -P "" -f /tmp/testkey &> /dev/null
}
destroy_app() {
local RC="$1"; local RC=${RC:=0}
local APP="$2"; local TEST_APP=${APP:=$TEST_APP}
@@ -124,6 +130,10 @@ destroy_app() {
return "$RC"
}
destroy_key() {
rm -f "$DOKKU_ROOT/.ssh/authorized_keys" /tmp/testkey* &> /dev/null || true
}
add_domain() {
dokku domains:add "$TEST_APP" "$1"
}