Skip to content

Commit c16d850

Browse files
mooreandrewsmortex
authored andcommitted
Role valid_until documentation and tests
1 parent 95922a8 commit c16d850

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

manifests/server/role.pp

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# @param inherit Specifies whether to grant inherit capability for the new role.
1212
# @param superuser Specifies whether to grant super user capability for the new role.
1313
# @param replication Provides provides replication capabilities for this role if set to true.
14+
# @param valid_until Specifies whether to set a valid until date for the role.
1415
# @param connection_limit Specifies how many concurrent connections the role can make. Default value: '-1', meaning no limit.
1516
# @param username Defines the username of the role to create.
1617
# @param connect_settings Specifies a hash of environment variables used when connecting to a remote server.

spec/defines/server_instance_spec.rb

+12-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class { 'postgresql::server':
7373
'app_test1': { 'login' => true },
7474
'rep_test1': { 'replication' => true,
7575
'login' => true },
76-
'rou_test1': { 'login' => true }, },
76+
'rou_test1': { 'login' => true },
77+
'val_test1': { 'login' => true,
78+
'valid_until' => '2030-01-01 00:00:00+00' }, },
7779
'pg_hba_rules': { 'local all INSTANCE user': { 'type' => 'local',
7880
'database' => 'all',
7981
'user' => 'ins_test1',
@@ -214,10 +216,19 @@ class { 'postgresql::server':
214216
it { is_expected.to contain_postgresql_psql('ALTER ROLE "rou_test1" NOCREATEROLE') }
215217
it { is_expected.to contain_postgresql_psql('ALTER ROLE "rou_test1" NOREPLICATION') }
216218
it { is_expected.to contain_postgresql_psql('ALTER ROLE "rou_test1" NOSUPERUSER') }
219+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" CONNECTION LIMIT -1') }
220+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" INHERIT') }
221+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" LOGIN') }
222+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" NOCREATEDB') }
223+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" NOCREATEROLE') }
224+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" NOREPLICATION') }
225+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" NOSUPERUSER') }
226+
it { is_expected.to contain_postgresql_psql('ALTER ROLE "val_test1" VALID UNTIL \'2030-01-01 00:00:00+00\'') }
217227
it { is_expected.to contain_postgresql_psql('CREATE ROLE app_test1 ENCRYPTED PASSWORD ****') }
218228
it { is_expected.to contain_postgresql_psql('CREATE ROLE dba_test1 ENCRYPTED PASSWORD ****') }
219229
it { is_expected.to contain_postgresql_psql('CREATE ROLE ins_test1 ENCRYPTED PASSWORD ****') }
220230
it { is_expected.to contain_postgresql_psql('CREATE ROLE rep_test1 ENCRYPTED PASSWORD ****') }
221231
it { is_expected.to contain_postgresql_psql('CREATE ROLE rou_test1 ENCRYPTED PASSWORD ****') }
232+
it { is_expected.to contain_postgresql_psql('CREATE ROLE val_test1 ENCRYPTED PASSWORD ****') }
222233
end
223234
end

0 commit comments

Comments
 (0)