Skip to content

Commit a21353f

Browse files
committed
fixes when the mapname is too long
when the mapname (or any other field in the ident file) exceeds the predefined width, the values are 'glued' together. This renders the file invalid. similar like this issue: #733 we now force a space between the values if the exceed the column width.
1 parent b15c741 commit a21353f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

libraries/ident.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def to_s
184184
ENTRY_FIELD_FORMAT.each do |field, ljust_count|
185185
field = respond_to?(field) ? send(field) : ''
186186
field_string = field.to_s.ljust(ljust_count)
187+
field_string += ' ' unless field_string.include?(' ') || field == :comment
187188
entry_string.concat(field_string)
188189
end
189190

test/cookbooks/test/recipes/ident.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
action :delete
5555
end
5656

57+
postgresql_ident 'map with very long name' do
58+
map_name 'this_is_a_very_long_map_name_that_should_be_handled_correctly_by_the_postgresql_ident_resource'
59+
system_username 'shef'
60+
database_username 'sous_chef'
61+
62+
notifies :reload, 'postgresql_service[postgresql]', :delayed
63+
end
64+
5765
postgresql_access 'postgresql host superuser' do
5866
type 'host'
5967
database 'all'

test/integration/ident/controls/ident_map.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,13 @@
3131
its('output') { should include 'sous_chef' }
3232
end
3333
end
34+
35+
control 'postgresql-ident-long-map-name' do
36+
impact 1.0
37+
desc 'This test ensures postgres configures ident access with long map names correctly'
38+
39+
describe postgres_ident_conf.where { map_name == 'this_is_a_very_long_map_name_that_should_be_handled_correctly_by_the_postgresql_ident_resource' } do
40+
its('system_username') { should cmp 'shef' }
41+
its('pg_username') { should cmp 'sous_chef' }
42+
end
43+
end

0 commit comments

Comments
 (0)