Revision a977bd3b
Added by Daniel Lobato Garcia over 8 years ago
test/functional/unattended_controller_test.rb | ||
---|---|---|
Setting[:token_duration] = 30
|
||
Setting[:unattended_url] = "https://test.host"
|
||
@request.env["REMOTE_ADDR"] = @ub_host.ip
|
||
@ub_host.create_token(:value => token, :expires => Time.now + 5.minutes)
|
||
@ub_host.create_token(:value => token, :expires => Time.now.utc + 5.minutes)
|
||
get :host_template, {:kind => 'provision', 'token' => @ub_host.token.value }
|
||
assert @response.body.include?("#{Setting[:unattended_url]}/unattended/finish?token=#{token}")
|
||
end
|
||
... | ... | |
test "hosts with unknown ip and valid token should render a template" do
|
||
Setting[:token_duration] = 30
|
||
@request.env["REMOTE_ADDR"] = '127.0.0.1'
|
||
@ub_host.create_token(:value => "aaaaaa", :expires => Time.now + 5.minutes)
|
||
@ub_host.create_token(:value => "aaaaaa", :expires => Time.now.utc + 5.minutes)
|
||
get :host_template, {:kind => 'provision', 'token' => @ub_host.token.value }
|
||
assert_response :success
|
||
end
|
||
... | ... | |
Setting[:update_ip_from_built_request] = false
|
||
@request.env["REMOTE_ADDR"] = '127.0.0.1'
|
||
h=@ub_host
|
||
h.create_token(:value => "aaaaaa", :expires => Time.now + 5.minutes)
|
||
h.create_token(:value => "aaaaaa", :expires => Time.now.utc + 5.minutes)
|
||
get :built, {'token' => h.token.value }
|
||
h_new=Host.find_by_name(h.name)
|
||
|
||
... | ... | |
new_ip = h.subnet.network.gsub(/\.0$/,'.100') # Must be in the subnet, which isn't fixed
|
||
@request.env["REMOTE_ADDR"] = new_ip
|
||
refute_equal new_ip, h.ip
|
||
h.create_token(:value => "aaaaab", :expires => Time.now + 5.minutes)
|
||
h.create_token(:value => "aaaaab", :expires => Time.now.utc + 5.minutes)
|
||
get :built, {'token' => h.token.value }
|
||
h_new=Host.find_by_name(h.reload.name)
|
||
assert_response :success
|
||
... | ... | |
Setting[:update_ip_from_built_request] = true
|
||
@request.env["REMOTE_ADDR"] = @rh_host.ip
|
||
h=@ub_host
|
||
h.create_token(:value => "aaaaac", :expires => Time.now + 5.minutes)
|
||
h.create_token(:value => "aaaaac", :expires => Time.now.utc + 5.minutes)
|
||
get :built, {'token' => h.token.value }
|
||
assert_response :success
|
||
h_new=Host.find_by_name(h.reload.name)
|
||
... | ... | |
Setting[:token_duration] = 30
|
||
Setting[:unattended_url] = "http://test.host"
|
||
@request.env["REMOTE_ADDR"] = @ub_host.ip
|
||
@ub_host.create_token(:value => "aaaaaa", :expires => Time.now + 5.minutes)
|
||
@ub_host.create_token(:value => "aaaaaa", :expires => Time.now.utc + 5.minutes)
|
||
get :host_template, {:kind => 'provision'}
|
||
assert @response.body.include?("http://test.host/unattended/finish?token=aaaaaa")
|
||
end
|
||
... | ... | |
template_server_from_proxy = 'https://someproxy:8443'
|
||
ProxyAPI::Template.any_instance.stubs(:template_url).returns(template_server_from_proxy)
|
||
@request.env["REMOTE_ADDR"] = '127.0.0.1'
|
||
@host_with_template_subnet.create_token(:value => "aaaaad", :expires => Time.now + 5.minutes)
|
||
@host_with_template_subnet.create_token(:value => "aaaaad", :expires => Time.now.utc + 5.minutes)
|
||
get :host_template, {:kind => 'provision', 'token' => @host_with_template_subnet.token.value }
|
||
assert @response.body.include?("#{template_server_from_proxy}/unattended/finish?token=aaaaad")
|
||
end
|
||
... | ... | |
Setting[:token_duration] = 30
|
||
Setting[:unattended_url] = "http://test.host"
|
||
@request.env["REMOTE_ADDR"] = '127.0.0.1'
|
||
@host_with_template_subnet.create_token(:value => "aaaaae", :expires => Time.now + 5.minutes)
|
||
@host_with_template_subnet.create_token(:value => "aaaaae", :expires => Time.now.utc + 5.minutes)
|
||
get :host_template, {:kind => 'provision', 'token' => @host_with_template_subnet.token.value }
|
||
assert @response.body.include?("#{@host_with_template_subnet.subnet.tftp.url}/unattended/finish?token=aaaaae")
|
||
end
|
Also available in: Unified diff
Fixes #13557 - Rubocop enforce specifying a timezone
Rubocop can enforce what timezone to store in the database ,
so we can ensure everything is stored using UTC and we don't
miss these things in code reviews. When objects are displayed,
they must use the time provided by set_timezone in the
controller.
This is particularly relevant for Trends, Puppet graphs, etc... to
ensure they are stored always properly