Revision 3552acf4
Added by Daniel Lobato Garcia over 7 years ago
test/controllers/puppetca_controller_test.rb | ||
---|---|---|
require 'test_helper'
|
||
|
||
class PuppetcaControllerTest < ActionController::TestCase
|
||
setup do
|
||
@proxy = smart_proxies(:puppetmaster)
|
||
end
|
||
|
||
test 'problems when signing certificate redirect to certificates page' do
|
||
proxy = smart_proxies(:puppetmaster)
|
||
# Try set any random path in the referer to ensure it doesn't redirect_to :back
|
||
@request.env['HTTP_REFERER'] = hosts_path
|
||
# This will try to find the certificate to no avail and will raise a ProxyException
|
||
post :update, { :smart_proxy_id => proxy.id, :id => 1 }, set_session_user
|
||
assert_redirected_to smart_proxy_path(proxy, :anchor => 'certificates')
|
||
assert_match /ProxyAPI::ProxyException/, flash[:error]
|
||
post :update, { :smart_proxy_id => @proxy.id, :id => 1 }, set_session_user
|
||
assert_redirected_to smart_proxy_path(@proxy, :anchor => 'certificates')
|
||
assert_match(/ProxyAPI::ProxyException/, flash[:error])
|
||
end
|
||
|
||
test 'index encodes any CN to an url safe string' do
|
||
cert = SmartProxies::PuppetCACertificate.new(
|
||
['mcollective/OL=mcollective', 'pending'])
|
||
ProxyStatus::PuppetCA.any_instance.expects(:certs).returns([cert])
|
||
assert_nothing_raised do
|
||
get :index, { :smart_proxy_id => @proxy.id }, set_session_user
|
||
end
|
||
assert_match(/mcollective%252FOL%253Dmcollective/, response.body)
|
||
assert_empty flash[:error]
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #18040 - URL escape PuppetCA CN on proxy view
If the CN contains characters that cannot be displayed in an URL, like
'mcollective/OL=mcollective', the puppetca list will not be able to
render.
The reason is that Rails cannot generate an URL for such CNs, so we need
to convert it into URL-friendly style.
(cherry picked from commit 73633f3db179f47a582b8ca2f31a9e430c10f4fb)