Skip to content

Commit

Permalink
Add cache_policy property to keycloal_ldap_user_provider (#296)
Browse files Browse the repository at this point in the history
Fixes #292
  • Loading branch information
treydock authored Jul 14, 2023
1 parent 927454a commit 84b7c6d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/puppet/type/keycloak_ldap_user_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
defaultto '0'
end

newproperty(:cache_policy) do
desc 'cachePolicy'
newvalues('DEFAULT', 'EVICT_DAILY', 'EVICT_WEEKLY', 'MAX_LIFESPAN', 'NO_CACHE')
defaultto 'DEFAULT'
end

newproperty(:batch_size_for_sync) do
desc 'batchSizeForSync'
defaultto '1000'
Expand Down
3 changes: 3 additions & 0 deletions spec/acceptance/3_ldap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class { 'keycloak': }
expect(d['config']['trustEmail']).to eq(['false'])
expect(d['config']['fullSyncPeriod']).to eq(['-1'])
expect(d['config']['changedSyncPeriod']).to eq(['-1'])
expect(d['config']['cachePolicy']).to eq(['DEFAULT'])
end
end

Expand Down Expand Up @@ -108,6 +109,7 @@ class { 'keycloak': }
trust_email => true,
full_sync_period => 60,
changed_sync_period => 30,
cache_policy => 'EVICT_DAILY',
}
keycloak_ldap_mapper { 'full-name':
realm => 'test',
Expand Down Expand Up @@ -142,6 +144,7 @@ class { 'keycloak': }
expect(d['config']['trustEmail']).to eq(['true'])
expect(d['config']['fullSyncPeriod']).to eq(['60'])
expect(d['config']['changedSyncPeriod']).to eq(['30'])
expect(d['config']['cachePolicy']).to eq(['EVICT_DAILY'])
end
end

Expand Down
14 changes: 14 additions & 0 deletions spec/unit/puppet/type/keycloak_ldap_user_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@
expect { resource }.to raise_error(Puppet::Error, %r{must start with "\(" and end with "\)"})
end

it 'defaults cache_policy to default' do
expect(resource[:cache_policy]).to eq(:DEFAULT)
end

it 'supports cache_policy to default' do
config[:cache_policy] = 'EVICT_DAILY'
expect(resource[:cache_policy]).to eq(:EVICT_DAILY)
end

it 'does not allow invalid cache_policy' do
config[:cache_policy] = 'foo'
expect { resource }.to raise_error(Puppet::Error)
end

defaults = {
enabled: :true,
priority: '0',
Expand Down

0 comments on commit 84b7c6d

Please sign in to comment.