Skip to content

Commit 116be5f

Browse files
committed
pg_hba_rule: Move type datatype to own type
This makes it easier to test the type, and people can use it in their downstream modules. In addition I added the type `hostnogssenc`. The list is now complete/covers all auth types from PostgreSQL 14.
1 parent 766508d commit 116be5f

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

manifests/server/pg_hba_rule.pp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @summary This resource manages an individual rule that applies to the file defined in target.
22
#
33
# @param type Sets the type of rule.
4-
# Enum['local','host','hostssl','hostnossl','hostgssenc'].
54
# @param database Sets a comma-separated list of databases that this rule matches.
65
# @param user Sets a comma-separated list of users that this rule matches.
76
# @param auth_method Provides the method that is used for authentication for the connection that this rule matches. Described further in the PostgreSQL pg_hba.conf documentation.
@@ -12,7 +11,7 @@
1211
# @param target Provides the target for the rule, and is generally an internal only property. Use with caution.
1312
# @param postgresql_version Manages pg_hba.conf without managing the entire PostgreSQL instance.
1413
define postgresql::server::pg_hba_rule (
15-
Enum['local', 'host', 'hostssl', 'hostnossl', 'hostgssenc'] $type,
14+
Postgresql::Pg_hba_rule_type $type,
1615
String $database,
1716
String $user,
1817
String $auth_method,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'Postgresql::Pg_hba_rule_type' do
6+
describe 'valid values' do
7+
[
8+
'local',
9+
'host',
10+
'hostssl',
11+
'hostnossl',
12+
'hostgssenc',
13+
'hostnogssenc',
14+
].each do |value|
15+
describe value.inspect do
16+
it { is_expected.to allow_value(value) }
17+
end
18+
end
19+
end
20+
21+
describe 'invalid values' do
22+
context 'with garbage inputs' do
23+
[
24+
:symbol,
25+
nil,
26+
'foobar',
27+
'',
28+
true,
29+
false,
30+
['meep', 'meep'],
31+
65_538,
32+
[95_000, 67_000],
33+
{},
34+
{ 'foo' => 'bar' },
35+
].each do |value|
36+
describe value.inspect do
37+
it { is_expected.not_to allow_value(value) }
38+
end
39+
end
40+
end
41+
end
42+
end

types/pg_hba_rule_type.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @summary enum for all different types for the pg_hba_conf
2+
# @see https://www.postgresql.org/docs/current/auth-pg-hba-conf.html
3+
type Postgresql::Pg_hba_rule_type = Enum['local', 'host', 'hostssl', 'hostnossl', 'hostgssenc', 'hostnogssenc']

0 commit comments

Comments
 (0)