Skip to content

Commit 420e082

Browse files
Merge pull request #922 from puppetlabs/CONT-1036_remove_validate_re
(cont-1036) remove validate_re depreciated function
2 parents 5e5a168 + 9a60569 commit 420e082

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

manifests/compose.pp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@
3737
Optional[String] $version = $docker::params::compose_version,
3838
Optional[String] $install_path = $docker::params::compose_install_path,
3939
Optional[String] $symlink_name = $docker::params::compose_symlink_name,
40-
Optional[String] $proxy = undef,
40+
Optional[Pattern['^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$']] $proxy = undef,
4141
Optional[String] $base_url = $docker::params::compose_base_url,
4242
Optional[String] $raw_url = undef,
4343
Optional[Boolean] $curl_ensure = $docker::params::curl_ensure,
4444
) inherits docker::params {
45-
if $proxy != undef {
46-
validate_re($proxy, '^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$')
47-
}
48-
4945
if $facts['os']['family'] == 'windows' {
5046
$file_extension = '.exe'
5147
$file_owner = 'Administrator'

manifests/machine.pp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@
2424
Enum[present,absent] $ensure = 'present',
2525
Optional[String] $version = $docker::params::machine_version,
2626
Optional[String] $install_path = $docker::params::machine_install_path,
27-
Optional[String] $proxy = undef,
27+
Optional[Pattern['^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$']] $proxy = undef,
2828
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $url = undef,
2929
Optional[Boolean] $curl_ensure = $docker::params::curl_ensure,
3030
) inherits docker::params {
31-
if $proxy != undef {
32-
validate_re($proxy, '^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$')
33-
}
34-
3531
if $facts['os']['family'] == 'windows' {
3632
$file_extension = '.exe'
3733
$file_owner = 'Administrator'

spec/classes/compose_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@
7373
params
7474
end
7575

76-
if params['proxy'] != :undef && !%r{^((https?)?://)?([^:^@]+:[^:^@]+@|)([\da-z.-]+)\.([\da-z.]{2,6})(:\d)?([/\w .-]*)*/?$}.match?(params['proxy'])
77-
it {
78-
expect(subject).to compile.and_raise_error(%r{does not match})
79-
}
80-
81-
next
76+
if title == 'when proxy is not a http proxy'
77+
it 'raises an error for invalid proxy URL' do
78+
expect(subject).to compile.and_raise_error(
79+
%r{parameter 'proxy' expects an undef value or a match for Pattern},
80+
)
81+
end
82+
else
83+
include_examples 'compose', params, facts
8284
end
83-
84-
include_examples 'compose', params, facts
8585
end
8686
end
8787
end

spec/classes/machine_spec.rb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
require 'spec_helper'
4-
4+
# Need to write test casees here
55
tests = {
66
'with default value' => {}
77
}
@@ -42,14 +42,17 @@
4242
params
4343
end
4444

45-
if params['proxy'] != :undef && !'^((http[s]?)?:\/\/)?([^:^@]+:[^:^@]+@|)([\da-z\.-]+)\.([\da-z\.]{2,6})(:[\d])?([\/\w \.-]*)*\/?$'.match?(params['proxy'])
46-
it {
47-
expect(subject).to compile.and_raise_error(%r{})
48-
}
49-
50-
next
51-
end
52-
45+
# Need to write check condition for params['proxy']
46+
# The block commented below currently has no test case, if in future more test cases are added to this spec file, please refer to spec/classes/compose_spec.rb and implement as required here.
47+
# if title == 'when proxy is not a http proxy'
48+
# it 'raises an error for invalid proxy URL' do
49+
# is_expected.to compile.and_raise_error(
50+
# %r{parameter 'proxy' expects an undef value or a match for Pattern},
51+
# )
52+
# end
53+
# else
54+
# include_examples 'machine', params, facts, defaults
55+
# end
5356
include_examples 'machine', params, facts, defaults
5457
end
5558
end

0 commit comments

Comments
 (0)