1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Fixes the bug that wouldn't allow no_token be set to true (#1803)

* Fix crash when no_token is set

* Use a more meaningful name instead of an empty string

* Adds a test to ensure `{ no_token: true }` works

* Adds an explanation for the usage of a String

Just to justify the use of a String instead of a Symbol.

* Removes thread that would start the server

This removes the part of the test that would start the server. The
reason why the thread was being created originally in the PR was to
ensure that the server was booting even with `{ no_token: true }`.

I believe we don't need to test the full server boot but just ensure
that we won't pass a Symbol to OptionParser. In particular the test
ensures that the token will be set to `'none'` when `no_token: true`.

There're already other tests testing that the server boots.
This commit is contained in:
Jesús Burgos Maciá 2019-05-28 09:37:34 -04:00 committed by Nate Berkopec
parent e26b4dfb59
commit d39fe92a2d
4 changed files with 22 additions and 2 deletions

View file

@ -105,7 +105,12 @@ module Puma
end
if opts[:no_token]
auth_token = :none
# We need to use 'none' rather than :none because this value will be
# passed on to an instance of OptionParser, which doesn't support
# symbols as option values.
#
# See: https://github.com/puma/puma/issues/1193#issuecomment-305995488
auth_token = 'none'
else
auth_token = opts[:auth_token]
auth_token ||= Configuration.random_token

View file

@ -55,7 +55,7 @@ module Puma
app = Puma::App::Status.new @launcher
if token = @options[:control_auth_token]
app.auth_token = token unless token.empty? or token == :none
app.auth_token = token unless token.empty? || token == 'none'
end
control = Puma::Server.new app, @launcher.events

View file

@ -0,0 +1,5 @@
activate_control_app 'unix:///tmp/pumactl.sock', { no_token: true }
app do |env|
[200, {}, ["embedded app"]]
end

View file

@ -29,6 +29,16 @@ class TestPumaControlCli < Minitest::Test
assert_equal "t3-pid", control_cli.instance_variable_get("@pidfile")
end
def test_control_no_token
opts = [
"--config-file", "test/config/control_no_token.rb",
"start"
]
control_cli = Puma::ControlCLI.new opts, @ready, @ready
assert_equal 'none', control_cli.instance_variable_get("@control_auth_token")
end
def test_control_url
host = "127.0.0.1"
port = find_open_port