Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/puma/dsl.rb
Expand Up @@ -105,7 +105,12 @@ def activate_control_app(url="auto", opts={})
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'
Jesus marked this conversation as resolved.
Show resolved Hide resolved
else
auth_token = opts[:auth_token]
auth_token ||= Configuration.random_token
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/runner.rb
Expand Up @@ -55,7 +55,7 @@ def start_control
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
Expand Down
5 changes: 5 additions & 0 deletions test/config/control_no_token.rb
@@ -0,0 +1,5 @@
activate_control_app 'unix:///tmp/pumactl.sock', { no_token: true }

app do |env|
[200, {}, ["embedded app"]]
end
10 changes: 10 additions & 0 deletions test/test_pumactl.rb
Expand Up @@ -29,6 +29,16 @@ def test_config_file
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
Expand Down