Previously, we would always set the port mapping during a dockerfile build, making it difficult for users to override mappings. We also only _sometimes_ updated the detected port mapping, further confusing issues when users were migrating from Dockerfile to Buildpacks for builds. Now, we always detect the port mapping during the build process, and only use that detected port mapping if an override is not specified. This greatly simplifies the experience around port mapping, as now a user can create an app, set a port mapping, and that first deploy will respect the port mapping without an additional deploy. The builder always has the best context for what the app should be listening on, and thus we can always specify a "default" port mapping at this stage. Users can override this map as desired later. This change also results in the removal of a ton of internal code that is now centralized in the ports plugin. Closes #4067
158 lines
4.2 KiB
Bash
158 lines
4.2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup() {
|
|
global_setup
|
|
[[ -f "$DOKKU_ROOT/VHOST" ]] && cp -fp "$DOKKU_ROOT/VHOST" "$DOKKU_ROOT/VHOST.bak"
|
|
create_app
|
|
}
|
|
|
|
teardown() {
|
|
destroy_app
|
|
[[ -f "$DOKKU_ROOT/VHOST.bak" ]] && mv "$DOKKU_ROOT/VHOST.bak" "$DOKKU_ROOT/VHOST" && chown dokku:dokku "$DOKKU_ROOT/VHOST"
|
|
global_teardown
|
|
}
|
|
|
|
@test "(nginx-vhosts) nginx:set client-max-body-size" {
|
|
run deploy_app
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:set $TEST_APP client-max-body-size"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "client_max_body_size" 0
|
|
|
|
run /bin/bash -c "dokku nginx:set $TEST_APP client-max-body-size 1m"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "client_max_body_size 1m;" 1
|
|
}
|
|
|
|
@test "(nginx-vhosts) nginx:set proxy-read-timeout" {
|
|
run deploy_app
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:set $TEST_APP proxy-read-timeout 45s"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "45s;"
|
|
|
|
run /bin/bash -c "dokku nginx:set $TEST_APP proxy-read-timeout"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "45s;" 0
|
|
}
|
|
|
|
@test "(nginx-vhosts) nginx:set proxy-read-timeout (with SSL)" {
|
|
setup_test_tls
|
|
run deploy_app
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:set $TEST_APP proxy-read-timeout 45s"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "45s;"
|
|
|
|
run /bin/bash -c "dokku nginx:set $TEST_APP proxy-read-timeout"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "45s;" 0
|
|
}
|
|
|
|
@test "(nginx-vhosts) proxy:build-config ignore bad https mapping" {
|
|
setup_test_tls
|
|
run deploy_app "dockerfile-noexpose"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "Ignoring detected https port mapping without an accompanying ssl certificate" 0
|
|
|
|
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map-detected"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output "http:80:5000 https:443:5000"
|
|
teardown_test_tls
|
|
|
|
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map-detected"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output "http:80:5000"
|
|
|
|
run /bin/bash -c "dokku proxy:build-config $TEST_APP"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
run /bin/bash -c "dokku nginx:show-config $TEST_APP"
|
|
assert_output_contains "Ignoring detected https port mapping without an accompanying ssl certificate" 0
|
|
|
|
run /bin/bash -c "dokku ports:report $TEST_APP --ports-map-detected"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output "http:80:5000"
|
|
}
|