Merge pull request #1798 from dokku/1774_mh-invalid-appname-failure

ensure app name begins with lowercase alphanumeric character
This commit is contained in:
Jose Diaz-Gonzalez
2015-12-25 21:55:02 -05:00
3 changed files with 16 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
apps_create() {
[[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on"
[[ ! "$1" =~ ^[a-z].* && ! "$1" =~ ^[0-9].* ]] && dokku_log_fail "App name must begin with lowercase alphanumeric character"
[[ -d "$DOKKU_ROOT/$1" ]] && dokku_log_fail "Name is already taken"
local APP="$1"

View File

@@ -121,6 +121,10 @@ dokku_container_log_verbose_quiet() {
verify_app_name() {
local APP="$1"
[[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null"
if [[ ! "$APP" =~ ^[a-z].* && ! "$APP" =~ ^[0-9].* ]]; then
[[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "$DOKKU_ROOT/$APP"
dokku_log_fail "App name must begin with lowercase alphanumeric character"
fi
[[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist"
return 0

View File

@@ -17,6 +17,17 @@ load test_helper
echo "status: "$status
assert_success
destroy_app
run dokku apps:create 1994testapp
echo "output: "$output
echo "status: "$status
assert_success
dokku --force apps:destroy 1994testapp
run dokku apps:create TestApp
echo "output: "$output
echo "status: "$status
assert_failure
}
@test "(apps) apps:destroy" {