-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix readonly handling #358
Draft
towo
wants to merge
26
commits into
voxpupuli:master
Choose a base branch
from
b1-systems:fix/readonly-boolean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−3
Draft
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3302811
Update FreeBSD default version for OpenLDAP
smortex b8fffd8
Fix readonly handling
towo bc0cd00
Needs `newvalues` anolagous to mirromode to have symbols available
towo 9840c62
Add spec c/o @smortex
smortex e10d002
Linter and spec fixes
towo efc3ae2
Implement a test for readonly being set to true
towo bfda214
fixup! Implement a test for readonly being set to true
towo 2623158
fixup! Implement a test for readonly being set to true
towo 617816a
fixup! Implement a test for readonly being set to true
towo 1b47094
fixup! Implement a test for readonly being set to true
towo d0fe5db
fixup! Implement a test for readonly being set to true
towo 0737c84
fixup! Implement a test for readonly being set to true
towo eca43b8
fixup! Implement a test for readonly being set to true
towo 00cd63e
fixup! Implement a test for readonly being set to true
towo 12078a1
fixup! Implement a test for readonly being set to true
towo 21b822f
fixup! Implement a test for readonly being set to true
towo cec2110
fixup! Implement a test for readonly being set to true
towo 91b30c8
fixup! Implement a test for readonly being set to true
towo 3fafa30
fixup! Implement a test for readonly being set to true
towo ec7e5c6
fixup! Implement a test for readonly being set to true
towo f26427f
fixup! Implement a test for readonly being set to true
towo 405d793
fixup! Implement a test for readonly being set to true
towo a297ef1
fixup! Implement a test for readonly being set to true
towo 6da413a
fixup! Implement a test for readonly being set to true
towo cc08532
fixup! Implement a test for readonly being set to true
towo 936c78b
fixup! Implement a test for readonly being set to true
towo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,55 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Puppet::Type.type(:openldap_database).provider(:olc) do | ||
let(:params) do | ||
{ | ||
suffix: 'dc=example,dc=com', | ||
backend: 'mdb', | ||
readonly: false, | ||
# provider: described_class.name, | ||
} | ||
end | ||
|
||
let(:resource) do | ||
Puppet::Type.type(:openldap_database).new(params) | ||
end | ||
let(:provider) do | ||
resource.provider | ||
end | ||
|
||
before do | ||
allow(described_class).to receive(:slapcat).with('(|(olcDatabase=monitor)(olcDatabase={0}config)(&(objectClass=olcDatabaseConfig)(|(objectClass=olcBdbConfig)(objectClass=olcHdbConfig)(objectClass=olcMdbConfig)(objectClass=olcMonitorConfig)(objectClass=olcRelayConfig)(objectClass=olcLDAPConfig))))').and_return(<<~SLAPCAT) | ||
dn: olcDatabase={1}mdb,cn=config | ||
olcDatabase: {1}mdb | ||
olcReadOnly: FALSE | ||
SLAPCAT | ||
allow(provider).to receive(:slapcat) | ||
allow(provider).to receive(:ldapmodify) | ||
allow(provider).to receive(:ldapadd) | ||
# allow(described_class).to receive(:slapcat) | ||
# allow(described_class).to receive(:ldapmodify) | ||
# allow(described_class).to receive(:ldapadd) | ||
end | ||
|
||
describe 'when creating' do | ||
context 'with readonly set to false' do | ||
it 'parses olcReadOnly as false' do | ||
provider.create | ||
expect(described_class.instances.first.readonly).to eq :false | ||
# expect(described_class.instances.first.readonly).to eq(:false) | ||
end | ||
end | ||
|
||
context 'with readonly set to true' do | ||
let(:params) do | ||
super().merge({ readonly: true }) | ||
end | ||
|
||
it 'parses olcReadonly' do | ||
expect(described_class.instances.first.readonly).to eq(:true) | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use native types here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm a bit confused at this, to be quite honest; the
mirrormode
setting defined the:true
and:false
values, which appears to be an accepted way as it's used all throughout various modules, including modules by @puppetlabs. So I just tried to mirror (hah) that, and also pushed f2e809d since the symbol approach needed that.I could just drop it and go down to ruby booleans, but then there'd be a certain inconsistency, and one that the overall codebase, including @voxpupuli, seems split on. Or have I overlooked a style guide somewhere that defines the way to go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't help you, but: This is an ongoing problem since types and provider exists and everytime I don't know how to handle it properly :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecation of
:true
/:false
in favor oftrue
/false
is quite vague for me. I feel like it was needed with older parser and Puppet 4 fixed that. As you say, there are inconsistencies in the various modules around. Some module even mix both ways: https://github.com/puppetlabs/puppetlabs-vcsrepo/blob/bcae373622364f3088fd6d0c89c4d499c05b3e5d/lib/puppet/type/vcsrepo.rb#L290-L321This makes me think we can switch to pure
true
/false
but if it cause trouble that's not a major issue.