-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be more strict for openldap_access resource title
The openldap_access resource allows a lot of variations in the title for declaring a resource, making it possible to skip passing parameters such as `what` and `suffix`. This flexibility however can confuse Puppet when it is prefetching resources, leading to catalog compilation failures. Impose a more strict format for resource titles, and validate it with tighter custom types to raise a hopefully meaningful error instead of a Ruby error because something borked bad.
- Loading branch information
Showing
15 changed files
with
124 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
# See README.md for details. | ||
define openldap::server::access ( | ||
Optional[Enum['present', 'absent']] $ensure = undef, | ||
Optional[Variant[Integer,String[1]]] $position = undef, # FIXME We should probably choose Integer or String | ||
Optional[String[1]] $what = undef, | ||
Optional[String[1]] $suffix = undef, | ||
Optional[Array[String[1]]] $access = undef, | ||
String[1] $what, | ||
Array[Openldap::Access_rule] $access, | ||
Enum['present', 'absent'] $ensure = 'present', | ||
Optional[Variant[Integer,String[1]]] $position = undef, # FIXME deprecated | ||
Optional[String[1]] $suffix = undef, # FIXME deprecated | ||
) { | ||
include openldap::server | ||
|
||
if $position or $suffix { | ||
warning('openldap::server::access position and suffix are deprecated') | ||
} | ||
|
||
Class['openldap::server::service'] | ||
-> Openldap::Server::Access[$title] | ||
-> Class['openldap::server'] | ||
|
||
openldap_access { $title: | ||
ensure => $ensure, | ||
position => $position, | ||
position => $position, # FIXME deprecated | ||
target => $openldap::server::conffile, | ||
what => $what, | ||
suffix => $suffix, | ||
suffix => $suffix, # FIXME deprecated | ||
access => $access, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Openldap::Access_hash' do | ||
context 'valid types' do | ||
[ | ||
{ | ||
'0 on dc=example,dc=com' => { | ||
'what' => 'attrs=userPassword,shadowLastChange', | ||
'access' => [ | ||
'by dn="cn=admin,dc=example,dc=com" write', | ||
'by anonymous auth', | ||
'by self write', | ||
'by * none', | ||
], | ||
}, | ||
}, | ||
{ | ||
'0 on dc=example,dc=com' => { | ||
'position' => 3, | ||
'suffix' => 'dc=example,dc=com', | ||
'what' => 'attrs=userPassword,shadowLastChange', | ||
'access' => [ | ||
'by dn="cn=admin,dc=example,dc=com" write', | ||
'by anonymous auth', | ||
'by self write', | ||
'by * none', | ||
], | ||
}, | ||
}, | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.to allow_value(value) } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Openldap::Access_rule' do | ||
context 'valid value' do | ||
[ | ||
'by dn="cn=admin,dc=example,dc=com write', | ||
'by anonymous auth', | ||
].each do |value| | ||
describe value.inspect do | ||
it { is_expected.to allow_value(value) } | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.