This change makes password authentication required for redis usage, and removes anonymous access. Users will need to change their underlying clients to enable writing the auth token for authenticating, otherwise requests will fail. This is a non-optional change, and improves security for users who wish to expose their redis installations outside of their network.
71 lines
2.6 KiB
Bash
Executable File
71 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
load test_helper
|
|
|
|
setup() {
|
|
dokku "$PLUGIN_COMMAND_PREFIX:create" l >&2
|
|
dokku apps:create my_app >&2
|
|
}
|
|
|
|
teardown() {
|
|
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l >&2
|
|
rm "$DOKKU_ROOT/my_app" -rf
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when there are no arguments" {
|
|
run dokku "$PLUGIN_COMMAND_PREFIX:link"
|
|
assert_contains "${lines[*]}" "Please specify a name for the service"
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the app argument is missing" {
|
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" l
|
|
assert_contains "${lines[*]}" "Please specify an app to run the command on"
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the app does not exist" {
|
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" l not_existing_app
|
|
assert_contains "${lines[*]}" "App not_existing_app does not exist"
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the service does not exist" {
|
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" not_existing_service my_app
|
|
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) error when the service is already linked to app" {
|
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
|
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
|
assert_contains "${lines[*]}" "Already linked as REDIS_URL"
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) exports REDIS_URL to app" {
|
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
|
url=$(dokku config:get my_app REDIS_URL)
|
|
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
|
assert_contains "$url" "redis://l:$password@dokku-redis-l:6379"
|
|
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) generates an alternate config url when REDIS_URL already in use" {
|
|
dokku config:set my_app REDIS_URL=redis://host:6379
|
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
|
run dokku config my_app
|
|
assert_contains "${lines[*]}" "DOKKU_REDIS_"
|
|
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) links to app with docker-options" {
|
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
|
run dokku docker-options my_app
|
|
assert_contains "${lines[*]}" "--link dokku.redis.l:dokku-redis-l"
|
|
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
|
}
|
|
|
|
@test "($PLUGIN_COMMAND_PREFIX:link) uses apps REDIS_DATABASE_SCHEME variable" {
|
|
dokku config:set my_app REDIS_DATABASE_SCHEME=redis2
|
|
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
|
url=$(dokku config:get my_app REDIS_URL)
|
|
password="$(cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
|
assert_contains "$url" "redis2://l:$password@dokku-redis-l:6379"
|
|
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
|
}
|