Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use "inspect" when listing certificates

This fixes an issue of `puppet cert list` potentially not accurately
depicting the actual certname of the certificate/request. For instance,
"foo^H^H^Hbar" would simply appear as "bar".
  • Loading branch information...
commit 9607bd784b2f04b759932d36e843ba42d82635f1 1 parent 0144e68
@nicklewis nicklewis authored
View
6 lib/puppet/ssl/certificate_authority/interface.rb
@@ -88,6 +88,8 @@ def list(ca)
names = certs.values.map(&:keys).flatten
name_width = names.sort_by(&:length).last.length rescue 0
+ # We quote these names, so account for those characters
+ name_width += 2
output = [:request, :signed, :invalid].map do |type|
next if certs[type].empty?
@@ -113,11 +115,11 @@ def format_host(ca, host, type, info, width)
alt_names.delete(host)
- alt_str = "(alt names: #{alt_names.join(', ')})" unless alt_names.empty?
+ alt_str = "(alt names: #{alt_names.map(&:inspect).join(', ')})" unless alt_names.empty?
glyph = {:signed => '+', :request => ' ', :invalid => '-'}[type]
- name = host.ljust(width)
+ name = host.inspect.ljust(width)
fingerprint = "(#{ca.fingerprint(host, @digest)})"
explanation = "(#{verify_error})" if verify_error
View
34 spec/unit/ssl/certificate_authority/interface_spec.rb
@@ -212,9 +212,9 @@
applier = @class.new(:list, :to => [])
applier.expects(:puts).with(<<-OUTPUT.chomp)
- host1 (fingerprint)
- host2 (fingerprint)
- host3 (fingerprint)
+ "host1" (fingerprint)
+ "host2" (fingerprint)
+ "host3" (fingerprint)
OUTPUT
applier.apply(@ca)
@@ -228,12 +228,12 @@
applier = @class.new(:list, :to => :all)
applier.expects(:puts).with(<<-OUTPUT.chomp)
- host1 (fingerprint)
- host2 (fingerprint)
- host3 (fingerprint)
-+ host5 (fingerprint)
-+ host6 (fingerprint)
-- host4 (fingerprint) (certificate revoked)
+ "host1" (fingerprint)
+ "host2" (fingerprint)
+ "host3" (fingerprint)
++ "host5" (fingerprint)
++ "host6" (fingerprint)
+- "host4" (fingerprint) (certificate revoked)
OUTPUT
applier.apply(@ca)
@@ -245,9 +245,9 @@
applier = @class.new(:list, :to => :signed)
applier.expects(:puts).with(<<-OUTPUT.chomp)
-+ host4 (fingerprint)
-+ host5 (fingerprint)
-+ host6 (fingerprint)
++ "host4" (fingerprint)
++ "host5" (fingerprint)
++ "host6" (fingerprint)
OUTPUT
applier.apply(@ca)
@@ -260,7 +260,7 @@
applier = @class.new(:list, :to => ['host1'])
applier.expects(:puts).with(<<-OUTPUT.chomp)
- host1 (fingerprint) (alt names: DNS:foo, DNS:bar)
+ "host1" (fingerprint) (alt names: "DNS:foo", "DNS:bar")
OUTPUT
applier.apply(@ca)
@@ -272,10 +272,10 @@
applier = @class.new(:list, :to => %w{host1 host2 host4 host5})
applier.expects(:puts).with(<<-OUTPUT.chomp)
- host1 (fingerprint)
- host2 (fingerprint)
-+ host4 (fingerprint)
-+ host5 (fingerprint)
+ "host1" (fingerprint)
+ "host2" (fingerprint)
++ "host4" (fingerprint)
++ "host5" (fingerprint)
OUTPUT
applier.apply(@ca)
Please sign in to comment.
Something went wrong with that request. Please try again.