summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/aliases/absolutepath_spec.rb49
-rw-r--r--spec/aliases/httpsurl_spec.rb40
-rw-r--r--spec/aliases/httpurl_spec.rb43
-rw-r--r--spec/aliases/unixpath_spec.rb41
-rw-r--r--spec/aliases/windowspath_spec.rb44
-rw-r--r--spec/fixtures/test/manifests/absolutepath.pp6
-rw-r--r--spec/fixtures/test/manifests/httpsurl.pp6
-rw-r--r--spec/fixtures/test/manifests/httpurl.pp6
-rw-r--r--spec/fixtures/test/manifests/unixpath.pp6
-rw-r--r--spec/fixtures/test/manifests/windowspath.pp6
10 files changed, 247 insertions, 0 deletions
diff --git a/spec/aliases/absolutepath_spec.rb b/spec/aliases/absolutepath_spec.rb
new file mode 100644
index 0000000..aa435d7
--- /dev/null
+++ b/spec/aliases/absolutepath_spec.rb
@@ -0,0 +1,49 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.5
+ describe 'test::absolutepath', type: :class do
+ describe 'valid handling' do
+ %w{
+ /usr2/username/bin:/usr/local/bin:/usr/bin:.
+ C:/
+ C:\\
+ C:\\WINDOWS\\System32
+ C:/windows/system32
+ X:/foo/bar
+ X:\\foo\\bar
+ \\\\host\\windows
+ //host/windows
+ /var/tmp
+ /var/opt/../lib/puppet
+ }.each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile }
+ end
+ end
+ end
+
+ describe 'invalid path handling' do
+ context 'garbage inputs' do
+ [
+ nil,
+ [ nil ],
+ [ nil, nil ],
+ { 'foo' => 'bar' },
+ { },
+ '',
+ "*/Users//nope",
+ "\\Users/hc/wksp/stdlib",
+ "C:noslashes",
+ "\\var\\tmp"
+ ].each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Variant/) }
+ end
+ end
+ end
+
+ end
+ end
+end
diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb
new file mode 100644
index 0000000..97ae006
--- /dev/null
+++ b/spec/aliases/httpsurl_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.5
+ describe 'test::httpsurl', type: :class do
+ describe 'valid handling' do
+ %w{
+ https://hello.com
+ https://notcreative.org
+ https://notexciting.co.uk
+ }.each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile }
+ end
+ end
+ end
+
+ describe 'invalid path handling' do
+ context 'garbage inputs' do
+ [
+ nil,
+ [ nil ],
+ [ nil, nil ],
+ { 'foo' => 'bar' },
+ { },
+ '',
+ "httds://notquiteright.org",
+ "hptts:/nah",
+ "https;//notrightbutclose.org"
+ ].each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::HTTPSUrl/) }
+ end
+ end
+ end
+
+ end
+ end
+end
diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb
new file mode 100644
index 0000000..8bd57ca
--- /dev/null
+++ b/spec/aliases/httpurl_spec.rb
@@ -0,0 +1,43 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.5
+ describe 'test::httpurl', type: :class do
+ describe 'valid handling' do
+ %w{
+ https://hello.com
+ https://notcreative.org
+ https://canstillaccepthttps.co.uk
+ http://anhttp.com
+ http://runningoutofideas.gov
+ http://
+ }.each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile }
+ end
+ end
+ end
+
+ describe 'invalid path handling' do
+ context 'garbage inputs' do
+ [
+ nil,
+ [ nil ],
+ [ nil, nil ],
+ { 'foo' => 'bar' },
+ { },
+ '',
+ "httds://notquiteright.org",
+ "hptts:/nah",
+ "https;//notrightbutclose.org"
+ ].each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::HTTPUrl/) }
+ end
+ end
+ end
+
+ end
+ end
+end
diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb
new file mode 100644
index 0000000..aee161d
--- /dev/null
+++ b/spec/aliases/unixpath_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.5
+ describe 'test::unixpath', type: :class do
+ describe 'valid handling' do
+ %w{
+ /usr2/username/bin:/usr/local/bin:/usr/bin:.
+ /var/tmp
+ /Users/helencampbell/workspace/puppetlabs-stdlib
+ }.each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile }
+ end
+ end
+ end
+
+ describe 'invalid path handling' do
+ context 'garbage inputs' do
+ [
+ nil,
+ [ nil ],
+ [ nil, nil ],
+ { 'foo' => 'bar' },
+ { },
+ '',
+ "C:/whatever",
+ "\\var\\tmp",
+ "\\Users/hc/wksp/stdlib",
+ "*/Users//nope"
+ ].each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Unixpath/) }
+ end
+ end
+ end
+
+ end
+ end
+end
diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb
new file mode 100644
index 0000000..c13794e
--- /dev/null
+++ b/spec/aliases/windowspath_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper'
+
+if Puppet.version.to_f >= 4.5
+ describe 'test::windowspath', type: :class do
+ describe 'valid handling' do
+ %w{
+ C:\\
+ C:\\WINDOWS\\System32
+ C:/windows/system32
+ X:/foo/bar
+ X:\\foo\\bar
+ \\\\host\\windows
+ }.each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile }
+ end
+ end
+ end
+
+ describe 'invalid path handling' do
+ context 'garbage inputs' do
+ [
+ nil,
+ [ nil ],
+ [ nil, nil ],
+ { 'foo' => 'bar' },
+ { },
+ '',
+ "httds://notquiteright.org",
+ "/usr2/username/bin:/usr/local/bin:/usr/bin:.",
+ "C;//notright/here",
+ "C:noslashes"
+ ].each do |value|
+ describe value.inspect do
+ let(:params) {{ value: value }}
+ it { is_expected.to compile.and_raise_error(/parameter 'value' expects a match for Stdlib::Windowspath/) }
+ end
+ end
+ end
+
+ end
+ end
+end
diff --git a/spec/fixtures/test/manifests/absolutepath.pp b/spec/fixtures/test/manifests/absolutepath.pp
new file mode 100644
index 0000000..8321471
--- /dev/null
+++ b/spec/fixtures/test/manifests/absolutepath.pp
@@ -0,0 +1,6 @@
+# Class to test the Stdlib::Absolutepath type. Not to be confused with Stdlib::Compat::Absolute_path.
+class test::absolutepath(
+ Stdlib::Absolutepath $value,
+ ) {
+ notice("Success")
+}
diff --git a/spec/fixtures/test/manifests/httpsurl.pp b/spec/fixtures/test/manifests/httpsurl.pp
new file mode 100644
index 0000000..9d6b92d
--- /dev/null
+++ b/spec/fixtures/test/manifests/httpsurl.pp
@@ -0,0 +1,6 @@
+# Class to test the Stdlib::HTTPSUrl type alias
+class test::httpsurl(
+ Stdlib::HTTPSUrl $value,
+ ) {
+ notice("Success")
+}
diff --git a/spec/fixtures/test/manifests/httpurl.pp b/spec/fixtures/test/manifests/httpurl.pp
new file mode 100644
index 0000000..abf869e
--- /dev/null
+++ b/spec/fixtures/test/manifests/httpurl.pp
@@ -0,0 +1,6 @@
+# Class to test the Stdlib::HTTPUrl type alias
+class test::httpurl(
+ Stdlib::HTTPUrl $value,
+ ) {
+ notice("Success")
+}
diff --git a/spec/fixtures/test/manifests/unixpath.pp b/spec/fixtures/test/manifests/unixpath.pp
new file mode 100644
index 0000000..9311109
--- /dev/null
+++ b/spec/fixtures/test/manifests/unixpath.pp
@@ -0,0 +1,6 @@
+# Class to test the Stdlib::Unixpath type alias
+class test::unixpath(
+ Stdlib::Unixpath $value,
+ ) {
+ notice("Success")
+}
diff --git a/spec/fixtures/test/manifests/windowspath.pp b/spec/fixtures/test/manifests/windowspath.pp
new file mode 100644
index 0000000..af93ed3
--- /dev/null
+++ b/spec/fixtures/test/manifests/windowspath.pp
@@ -0,0 +1,6 @@
+# Class to test the Stdlib::Windowspath type alias
+class test::windowspath(
+ Stdlib::Windowspath $value,
+ ) {
+ notice("Success")
+}