Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/enh-10-cov…
Browse files Browse the repository at this point in the history
…er-not-covered
  • Loading branch information
Kozakowski Karol committed Jan 22, 2016
2 parents ed302c0 + 3ee151e commit 1eb9009
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
language: ruby
# TODO: GH Issue #4 - Try to execute standard Ruby builds on Travis CI on container infrastructure
sudo: required
install:
- sudo add-apt-repository -y ppa:raphink/augeas
- sudo apt-get update
- sudo apt-get install -y libaugeas-dev libxml2-dev
- bundle install --without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
sudo: false
addons:
apt:
sources:
- augeas
packages:
- libaugeas-dev
- libxml2-dev
bundler_args: --without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
cache: bundler
script: bundle exec rake test
before_install: rm -f Gemfile.lock
matrix:
Expand Down
6 changes: 4 additions & 2 deletions lib/puppet/type/jboss_datasource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def change_to_s(current, desire)
desc "host to connect"
isrequired
validate do |value|
unless value =~ /\w/ or value == ''
# Regex developed here (hostnames, ipv4, ipv6): https://regex101.com/r/hJ4jD1/3
re = /^((?:[a-zA-Z0-9_-]+\.)*[a-zA-Z0-9_-]+|(?:[a-fA-F0-9]{0,4}:){2,5}[a-fA-F0-9]{1,4})$/
unless value == '' or re.match(value.to_s)
raise ArgumentError, "Datasource host is invalid, given #{value.inspect}"
end
end
Expand All @@ -108,7 +110,7 @@ def change_to_s(current, desire)
desc "port to connect"
isrequired
validate do |value|
unless value =~ /\d/ or value == ''
unless value == '' or /^\d+$/.match(value.to_s)
raise ArgumentError, "Datasource port is invalid, given #{value.inspect}"
end
end
Expand Down
20 changes: 15 additions & 5 deletions spec/unit/types/jboss_datasource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ def extend_params(given)
end
context 'given "5x45"' do
let(:params) { extend_params({ :port => "5x45" }) }
before { skip('FIXME: A buggy host validation, ref: coi-gov-pl/puppet-jboss#8') }
it do
expect { type }.to raise_error(ex_class,
'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"')
expect { type }.to raise_error(ex_class,
'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "5x45"')
end
end
context 'property :port' do
Expand All @@ -62,13 +61,24 @@ def extend_params(given)
end
end
context 'given "an invalid host"' do
before { skip('FIXME: A buggy host validation, ref: coi-gov-pl/puppet-jboss#8') }
let(:params) { extend_params({ :host => "an invalid host" }) }
it do
expect { type }.to raise_error(ex_class,
expect { type }.to raise_error(ex_class,
'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given "an invalid host"')
end
end
context 'given "node-01.example.org"' do
let(:params) { extend_params({ :host => "node-01.example.org" }) }
it { expect { type }.not_to raise_error }
end
context 'given "192.168.16.2"' do
let(:params) { extend_params({ :host => "192.168.16.2" }) }
it { expect { type }.not_to raise_error }
end
context 'given "fe80::250:56ff:fec0:8"' do
let(:params) { extend_params({ :host => "fe80::250:56ff:fec0:8" }) }
it { expect { type }.not_to raise_error }
end
end

describe 'minpoolsize' do
Expand Down

0 comments on commit 1eb9009

Please sign in to comment.