From e9e87688111dd51e50d170dd6ba869c1aa66f926 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Sun, 30 Aug 2020 10:36:53 +0100 Subject: [PATCH] Add tests and docs for `debug_connections` `Stdlib::IP::Address` also added to the type alias so that it accepts IPv6 networks. --- manifests/init.pp | 4 ++++ spec/classes/nginx_spec.rb | 9 +++++++++ spec/type_aliases/debugconnection_spec.rb | 10 ++++++++++ types/debugconnection.pp | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 spec/type_aliases/debugconnection_spec.rb diff --git a/manifests/init.pp b/manifests/init.pp index 3e28d2e2b..c75bd2e69 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -40,6 +40,10 @@ # already installed. If the fact is unavailable, it defaults to '1.6.0'. # You may need to set this manually to get a working and idempotent # configuration. +# +# @param debug_connections +# Configures nginx `debug_connection` lines in the `events` section of the nginx config. +# See http://nginx.org/en/docs/ngx_core_module.html#debug_connection class nginx ( ### START Nginx Configuration ### Variant[Stdlib::Absolutepath, Boolean] $client_body_temp_path = $nginx::params::client_body_temp_path, diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 02478e1b6..91ecb3bb2 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -1077,6 +1077,15 @@ attr: 'ssl_password_file', value: '/path/to/password_file', match: ' ssl_password_file /path/to/password_file;' + }, + { + title: 'should contain debug_connection directives', + attr: 'debug_connections', + value: %w[127.0.0.1 unix:], + match: [ + ' debug_connection 127.0.0.1;', + ' debug_connection unix:;' + ] } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do diff --git a/spec/type_aliases/debugconnection_spec.rb b/spec/type_aliases/debugconnection_spec.rb new file mode 100644 index 000000000..d9d4cb4cd --- /dev/null +++ b/spec/type_aliases/debugconnection_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe 'Nginx::DebugConnection' do + it { is_expected.to allow_value('127.0.0.1') } + it { is_expected.to allow_value('localhost') } + it { is_expected.to allow_value('192.0.2.0/24') } + it { is_expected.to allow_value('::1') } + it { is_expected.to allow_value('2001:0db8::/32') } + it { is_expected.to allow_value('unix:') } +end diff --git a/types/debugconnection.pp b/types/debugconnection.pp index 67b8388bc..399fc4bb5 100644 --- a/types/debugconnection.pp +++ b/types/debugconnection.pp @@ -1 +1 @@ -type Nginx::DebugConnection = Variant[Stdlib::Host, Enum['unix:']] +type Nginx::DebugConnection = Variant[Stdlib::Host, Stdlib::IP::Address, Enum['unix:']]