service_kiosk 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Vagrantfile +25 -0
- data/bin/kiosk +55 -0
- data/bin/start_kiosk.sh +3 -0
- data/lib/Procfile.kiosk +1 -0
- data/lib/internal_service.rb +59 -0
- data/lib/json-simple-1.1.1.jar +0 -0
- data/lib/kiosk.rb +57 -0
- data/lib/kiosks/logger/output_logger.rb +16 -0
- data/lib/mall.rb +77 -0
- data/lib/mallcop.rb +9 -0
- data/lib/remote_service.rb +61 -0
- data/lib/tasks/local_mall.rake +93 -0
- data/provision/bootstrap.sh +21 -0
- data/provision/manifests/default.pp +49 -0
- data/provision/modules/apt/CHANGELOG +83 -0
- data/provision/modules/apt/LICENSE +19 -0
- data/provision/modules/apt/Modulefile +14 -0
- data/provision/modules/apt/README.md +119 -0
- data/provision/modules/apt/Rakefile +1 -0
- data/provision/modules/apt/manifests/backports.pp +48 -0
- data/provision/modules/apt/manifests/builddep.pp +16 -0
- data/provision/modules/apt/manifests/conf.pp +18 -0
- data/provision/modules/apt/manifests/debian/testing.pp +21 -0
- data/provision/modules/apt/manifests/debian/unstable.pp +21 -0
- data/provision/modules/apt/manifests/force.pp +24 -0
- data/provision/modules/apt/manifests/init.pp +114 -0
- data/provision/modules/apt/manifests/key.pp +80 -0
- data/provision/modules/apt/manifests/params.pp +23 -0
- data/provision/modules/apt/manifests/pin.pp +48 -0
- data/provision/modules/apt/manifests/ppa.pp +49 -0
- data/provision/modules/apt/manifests/release.pp +17 -0
- data/provision/modules/apt/manifests/source.pp +83 -0
- data/provision/modules/apt/manifests/update.pp +9 -0
- data/provision/modules/apt/spec/classes/apt_spec.rb +129 -0
- data/provision/modules/apt/spec/classes/backports_spec.rb +71 -0
- data/provision/modules/apt/spec/classes/debian_testing_spec.rb +14 -0
- data/provision/modules/apt/spec/classes/debian_unstable_spec.rb +14 -0
- data/provision/modules/apt/spec/classes/params_spec.rb +13 -0
- data/provision/modules/apt/spec/classes/release_spec.rb +22 -0
- data/provision/modules/apt/spec/defines/builddep_spec.rb +18 -0
- data/provision/modules/apt/spec/defines/conf_spec.rb +57 -0
- data/provision/modules/apt/spec/defines/force_spec.rb +41 -0
- data/provision/modules/apt/spec/defines/key_spec.rb +123 -0
- data/provision/modules/apt/spec/defines/pin_spec.rb +58 -0
- data/provision/modules/apt/spec/defines/ppa_spec.rb +92 -0
- data/provision/modules/apt/spec/defines/source_spec.rb +158 -0
- data/provision/modules/apt/spec/fixtures/manifests/site.pp +0 -0
- data/provision/modules/apt/spec/spec_helper.rb +1 -0
- data/provision/modules/apt/templates/pin.pref.erb +5 -0
- data/provision/modules/apt/templates/source.list.erb +5 -0
- data/provision/modules/apt/tests/builddep.pp +2 -0
- data/provision/modules/apt/tests/debian/testing.pp +2 -0
- data/provision/modules/apt/tests/debian/unstable.pp +2 -0
- data/provision/modules/apt/tests/force.pp +7 -0
- data/provision/modules/apt/tests/init.pp +1 -0
- data/provision/modules/apt/tests/key.pp +5 -0
- data/provision/modules/apt/tests/params.pp +1 -0
- data/provision/modules/apt/tests/pin.pp +5 -0
- data/provision/modules/apt/tests/ppa.pp +4 -0
- data/provision/modules/apt/tests/release.pp +4 -0
- data/provision/modules/apt/tests/source.pp +29 -0
- data/provision/modules/stdlib/CHANGELOG +177 -0
- data/provision/modules/stdlib/LICENSE +19 -0
- data/provision/modules/stdlib/Modulefile +11 -0
- data/provision/modules/stdlib/README.markdown +929 -0
- data/provision/modules/stdlib/README_DEVELOPER.markdown +35 -0
- data/provision/modules/stdlib/RELEASE_PROCESS.markdown +24 -0
- data/provision/modules/stdlib/Rakefile +2 -0
- data/provision/modules/stdlib/lib/facter/pe_version.rb +53 -0
- data/provision/modules/stdlib/lib/facter/puppet_vardir.rb +26 -0
- data/provision/modules/stdlib/lib/facter/root_home.rb +19 -0
- data/provision/modules/stdlib/lib/facter/util/puppet_settings.rb +21 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/abs.rb +36 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/bool2num.rb +49 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/capitalize.rb +34 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/chomp.rb +35 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/chop.rb +37 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/defined_with_params.rb +35 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/delete.rb +46 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/delete_at.rb +49 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/downcase.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/empty.rb +28 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/ensure_packages.rb +24 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/ensure_resource.rb +35 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/flatten.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/fqdn_rotate.rb +46 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/get_module_path.rb +17 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/getvar.rb +26 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/grep.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/has_interface_with.rb +52 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/has_ip_address.rb +25 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/has_ip_network.rb +25 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/has_key.rb +28 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/hash.rb +41 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_array.rb +22 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_domain_name.rb +47 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_float.rb +27 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_hash.rb +22 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_integer.rb +27 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_ip_address.rb +32 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb +27 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_numeric.rb +27 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/is_string.rb +26 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/join.rb +41 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/join_keys_to_values.rb +47 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/keys.rb +26 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/loadyaml.rb +20 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/lstrip.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/max.rb +13 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/member.rb +44 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/merge.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/min.rb +13 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +40 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/parsejson.rb +24 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/parseyaml.rb +24 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/pick.rb +29 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/prefix.rb +45 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/range.rb +80 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/reject.rb +31 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/reverse.rb +28 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/rstrip.rb +32 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/shuffle.rb +46 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/size.rb +48 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/sort.rb +27 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/squeeze.rb +36 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/str2bool.rb +41 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +32 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/strftime.rb +107 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/strip.rb +39 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/swapcase.rb +39 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/time.rb +49 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/to_bytes.rb +28 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/type.rb +50 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/unique.rb +51 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/upcase.rb +41 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/uriescape.rb +36 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_absolute_path.rb +56 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_array.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_bool.rb +34 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_hash.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_re.rb +40 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_slength.rb +52 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/validate_string.rb +33 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/values.rb +39 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/values_at.rb +98 -0
- data/provision/modules/stdlib/lib/puppet/parser/functions/zip.rb +65 -0
- data/provision/modules/stdlib/lib/puppet/provider/file_line/ruby.rb +59 -0
- data/provision/modules/stdlib/lib/puppet/type/anchor.rb +41 -0
- data/provision/modules/stdlib/lib/puppet/type/file_line.rb +70 -0
- data/provision/modules/stdlib/manifests/init.pp +20 -0
- data/provision/modules/stdlib/manifests/stages.pp +43 -0
- data/provision/modules/stdlib/spec/functions/defined_with_params_spec.rb +37 -0
- data/provision/modules/stdlib/spec/functions/ensure_packages_spec.rb +42 -0
- data/provision/modules/stdlib/spec/functions/ensure_resource_spec.rb +40 -0
- data/provision/modules/stdlib/spec/monkey_patches/alias_should_to_must.rb +8 -0
- data/provision/modules/stdlib/spec/monkey_patches/publicize_methods.rb +10 -0
- data/provision/modules/stdlib/spec/spec.opts +6 -0
- data/provision/modules/stdlib/spec/spec_helper.rb +28 -0
- data/provision/modules/stdlib/spec/unit/facter/pe_version_spec.rb +76 -0
- data/provision/modules/stdlib/spec/unit/facter/root_home_spec.rb +40 -0
- data/provision/modules/stdlib/spec/unit/facter/util/puppet_settings_spec.rb +35 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/abs_spec.rb +25 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/bool2num_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/capitalize_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/chomp_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/chop_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/delete_at_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/delete_spec.rb +38 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/downcase_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/empty_spec.rb +23 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/flatten_spec.rb +23 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/fqdn_rotate_spec.rb +33 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/get_module_path_spec.rb +46 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/getvar_spec.rb +37 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/grep_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_interface_with_spec.rb +64 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_address_spec.rb +39 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_ip_network_spec.rb +36 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/has_key_spec.rb +42 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/hash_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_array_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_domain_name_spec.rb +64 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_float_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_hash_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_integer_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_ip_address_spec.rb +39 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_mac_address_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_numeric_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/is_string_spec.rb +34 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/join_keys_to_values_spec.rb +40 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/join_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/keys_spec.rb +21 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/lstrip_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/max_spec.rb +23 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/member_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/merge_spec.rb +47 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/min_spec.rb +23 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/num2bool_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/parsejson_spec.rb +22 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/parseyaml_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/pick_spec.rb +34 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/prefix_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/range_spec.rb +34 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/reject_spec.rb +20 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/reverse_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/rstrip_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/shuffle_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/size_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/sort_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/squeeze_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/str2bool_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/str2saltedsha512_spec.rb +45 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/strftime_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/strip_spec.rb +18 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/swapcase_spec.rb +19 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/time_spec.rb +29 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/to_bytes_spec.rb +58 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/type_spec.rb +43 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/unique_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/upcase_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/uriescape_spec.rb +24 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_absolute_path_spec.rb +83 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb +38 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_bool_spec.rb +51 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_hash_spec.rb +43 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_re_spec.rb +76 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_slength_spec.rb +48 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_string_spec.rb +60 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/values_at_spec.rb +38 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/values_spec.rb +31 -0
- data/provision/modules/stdlib/spec/unit/puppet/parser/functions/zip_spec.rb +15 -0
- data/provision/modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb +127 -0
- data/provision/modules/stdlib/spec/unit/puppet/type/anchor_spec.rb +11 -0
- data/provision/modules/stdlib/spec/unit/puppet/type/file_line_spec.rb +69 -0
- data/provision/modules/stdlib/spec/watchr.rb +86 -0
- data/provision/modules/stdlib/tests/file_line.pp +9 -0
- data/provision/modules/stdlib/tests/has_interface_with.pp +10 -0
- data/provision/modules/stdlib/tests/has_ip_address.pp +3 -0
- data/provision/modules/stdlib/tests/has_ip_network.pp +4 -0
- data/provision/modules/stdlib/tests/init.pp +1 -0
- metadata +291 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe Puppet::Parser::Functions.function(:has_ip_address) do
|
|
5
|
+
|
|
6
|
+
let(:scope) do
|
|
7
|
+
PuppetlabsSpec::PuppetInternals.scope
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
subject do
|
|
11
|
+
function_name = Puppet::Parser::Functions.function(:has_ip_address)
|
|
12
|
+
scope.method(function_name)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "On Linux Systems" do
|
|
16
|
+
before :each do
|
|
17
|
+
scope.stubs(:lookupvar).with('interfaces').returns('eth0,lo')
|
|
18
|
+
scope.stubs(:lookupvar).with('ipaddress').returns('10.0.2.15')
|
|
19
|
+
scope.stubs(:lookupvar).with('ipaddress_eth0').returns('10.0.2.15')
|
|
20
|
+
scope.stubs(:lookupvar).with('ipaddress_lo').returns('127.0.0.1')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should have primary address (10.0.2.15)' do
|
|
24
|
+
subject.call(['10.0.2.15']).should be_true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should have lookupback address (127.0.0.1)' do
|
|
28
|
+
subject.call(['127.0.0.1']).should be_true
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should not have other address' do
|
|
32
|
+
subject.call(['192.1681.1.1']).should be_false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'should not have "mspiggy" on an interface' do
|
|
36
|
+
subject.call(['mspiggy']).should be_false
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe Puppet::Parser::Functions.function(:has_ip_network) do
|
|
5
|
+
|
|
6
|
+
let(:scope) do
|
|
7
|
+
PuppetlabsSpec::PuppetInternals.scope
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
subject do
|
|
11
|
+
function_name = Puppet::Parser::Functions.function(:has_ip_network)
|
|
12
|
+
scope.method(function_name)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "On Linux Systems" do
|
|
16
|
+
before :each do
|
|
17
|
+
scope.stubs(:lookupvar).with('interfaces').returns('eth0,lo')
|
|
18
|
+
scope.stubs(:lookupvar).with('network').returns(:undefined)
|
|
19
|
+
scope.stubs(:lookupvar).with('network_eth0').returns('10.0.2.0')
|
|
20
|
+
scope.stubs(:lookupvar).with('network_lo').returns('127.0.0.1')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'should have primary network (10.0.2.0)' do
|
|
24
|
+
subject.call(['10.0.2.0']).should be_true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'should have loopback network (127.0.0.0)' do
|
|
28
|
+
subject.call(['127.0.0.1']).should be_true
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should not have other network' do
|
|
32
|
+
subject.call(['192.168.1.0']).should be_false
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe Puppet::Parser::Functions.function(:has_key) do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
describe 'when calling has_key from puppet' do
|
|
8
|
+
it "should not compile when no arguments are passed" do
|
|
9
|
+
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
|
|
10
|
+
Puppet[:code] = '$x = has_key()'
|
|
11
|
+
expect {
|
|
12
|
+
scope.compiler.compile
|
|
13
|
+
}.to raise_error(Puppet::ParseError, /wrong number of arguments/)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should not compile when 1 argument is passed" do
|
|
17
|
+
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
|
|
18
|
+
Puppet[:code] = "$x = has_key('foo')"
|
|
19
|
+
expect {
|
|
20
|
+
scope.compiler.compile
|
|
21
|
+
}.to raise_error(Puppet::ParseError, /wrong number of arguments/)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should require the first value to be a Hash" do
|
|
25
|
+
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
|
|
26
|
+
Puppet[:code] = "$x = has_key('foo', 'bar')"
|
|
27
|
+
expect {
|
|
28
|
+
scope.compiler.compile
|
|
29
|
+
}.to raise_error(Puppet::ParseError, /expects the first argument to be a hash/)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe 'when calling the function has_key from a scope instance' do
|
|
34
|
+
it 'should detect existing keys' do
|
|
35
|
+
scope.function_has_key([{'one' => 1}, 'one']).should be_true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should detect existing keys' do
|
|
39
|
+
scope.function_has_key([{'one' => 1}, 'two']).should be_false
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the hash function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("hash").should == "function_hash"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_hash([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should convert an array to a hash" do
|
|
16
|
+
result = scope.function_hash([['a',1,'b',2,'c',3]])
|
|
17
|
+
result.should(eq({'a'=>1,'b'=>2,'c'=>3}))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_array function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_array").should == "function_is_array"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_array([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if passed an array" do
|
|
16
|
+
result = scope.function_is_array([[1,2,3]])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if passed a hash" do
|
|
21
|
+
result = scope.function_is_array([{'a'=>1}])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if passed a string" do
|
|
26
|
+
result = scope.function_is_array(["asdf"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_domain_name function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_domain_name([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if a valid short domain name" do
|
|
16
|
+
result = scope.function_is_domain_name(["x.com"])
|
|
17
|
+
result.should(be_true)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return true if the domain is ." do
|
|
21
|
+
result = scope.function_is_domain_name(["."])
|
|
22
|
+
result.should(be_true)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return true if the domain is x.com." do
|
|
26
|
+
result = scope.function_is_domain_name(["x.com."])
|
|
27
|
+
result.should(be_true)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should return true if a valid domain name" do
|
|
31
|
+
result = scope.function_is_domain_name(["foo.bar.com"])
|
|
32
|
+
result.should(be_true)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should allow domain parts to start with numbers" do
|
|
36
|
+
result = scope.function_is_domain_name(["3foo.2bar.com"])
|
|
37
|
+
result.should(be_true)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should allow domain to end with a dot" do
|
|
41
|
+
result = scope.function_is_domain_name(["3foo.2bar.com."])
|
|
42
|
+
result.should(be_true)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "should allow a single part domain" do
|
|
46
|
+
result = scope.function_is_domain_name(["orange"])
|
|
47
|
+
result.should(be_true)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should return false if domain parts start with hyphens" do
|
|
51
|
+
result = scope.function_is_domain_name(["-3foo.2bar.com"])
|
|
52
|
+
result.should(be_false)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should return true if domain contains hyphens" do
|
|
56
|
+
result = scope.function_is_domain_name(["3foo-bar.2bar-fuzz.com"])
|
|
57
|
+
result.should(be_true)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should return false if domain name contains spaces" do
|
|
61
|
+
result = scope.function_is_domain_name(["not valid"])
|
|
62
|
+
result.should(be_false)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_float function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_float").should == "function_is_float"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_float([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if a float" do
|
|
16
|
+
result = scope.function_is_float(["0.12"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if a string" do
|
|
21
|
+
result = scope.function_is_float(["asdf"])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if an integer" do
|
|
26
|
+
result = scope.function_is_float(["3"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_hash function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_hash").should == "function_is_hash"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_hash([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if passed a hash" do
|
|
16
|
+
result = scope.function_is_hash([{"a"=>1,"b"=>2}])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if passed an array" do
|
|
21
|
+
result = scope.function_is_hash([["a","b"]])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if passed a string" do
|
|
26
|
+
result = scope.function_is_hash(["asdf"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_integer function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_integer").should == "function_is_integer"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_integer([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if an integer" do
|
|
16
|
+
result = scope.function_is_integer(["3"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if a float" do
|
|
21
|
+
result = scope.function_is_integer(["3.2"])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if a string" do
|
|
26
|
+
result = scope.function_is_integer(["asdf"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_ip_address function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_ip_address").should == "function_is_ip_address"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_ip_address([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if an IPv4 address" do
|
|
16
|
+
result = scope.function_is_ip_address(["1.2.3.4"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return true if a full IPv6 address" do
|
|
21
|
+
result = scope.function_is_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"])
|
|
22
|
+
result.should(eq(true))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return true if a compressed IPv6 address" do
|
|
26
|
+
result = scope.function_is_ip_address(["fe00::1"])
|
|
27
|
+
result.should(eq(true))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should return false if not valid" do
|
|
31
|
+
result = scope.function_is_ip_address(["asdf"])
|
|
32
|
+
result.should(eq(false))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should return false if IP octets out of range" do
|
|
36
|
+
result = scope.function_is_ip_address(["1.1.1.300"])
|
|
37
|
+
result.should(eq(false))
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_mac_address function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if a valid mac address" do
|
|
16
|
+
result = scope.function_is_mac_address(["00:a0:1f:12:7f:a0"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if octets are out of range" do
|
|
21
|
+
result = scope.function_is_mac_address(["00:a0:1f:12:7f:g0"])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if not valid" do
|
|
26
|
+
result = scope.function_is_mac_address(["not valid"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_numeric function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_numeric").should == "function_is_numeric"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 argument" do
|
|
12
|
+
lambda { scope.function_is_numeric([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if an integer" do
|
|
16
|
+
result = scope.function_is_numeric(["3"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return true if a float" do
|
|
21
|
+
result = scope.function_is_numeric(["3.2"])
|
|
22
|
+
result.should(eq(true))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if a string" do
|
|
26
|
+
result = scope.function_is_numeric(["asdf"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the is_string function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("is_string").should == "function_is_string"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_is_string([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if a string" do
|
|
16
|
+
result = scope.function_is_string(["asdf"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if an integer" do
|
|
21
|
+
result = scope.function_is_string(["3"])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should return false if a float" do
|
|
26
|
+
result = scope.function_is_string(["3.23"])
|
|
27
|
+
result.should(eq(false))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should return false if an array" do
|
|
31
|
+
result = scope.function_is_string([["a","b","c"]])
|
|
32
|
+
result.should(eq(false))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the join_keys_to_values function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("join_keys_to_values").should == "function_join_keys_to_values"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there are fewer than two arguments" do
|
|
12
|
+
lambda { scope.function_join_keys_to_values([{}]) }.should raise_error Puppet::ParseError
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should raise a ParseError if there are greater than two arguments" do
|
|
16
|
+
lambda { scope.function_join_keys_to_values([{}, 'foo', 'bar']) }.should raise_error Puppet::ParseError
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should raise a TypeError if the first argument is an array" do
|
|
20
|
+
lambda { scope.function_join_keys_to_values([[1,2], ',']) }.should raise_error TypeError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should raise a TypeError if the second argument is an array" do
|
|
24
|
+
lambda { scope.function_join_keys_to_values([{}, [1,2]]) }.should raise_error TypeError
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should raise a TypeError if the second argument is a number" do
|
|
28
|
+
lambda { scope.function_join_keys_to_values([{}, 1]) }.should raise_error TypeError
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should return an empty array given an empty hash" do
|
|
32
|
+
result = scope.function_join_keys_to_values([{}, ":"])
|
|
33
|
+
result.should == []
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should join hash's keys to its values" do
|
|
37
|
+
result = scope.function_join_keys_to_values([{'a'=>1,2=>'foo',:b=>nil}, ":"])
|
|
38
|
+
result.should =~ ['a:1','2:foo','b:']
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the join function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("join").should == "function_join"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_join([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should join an array into a string" do
|
|
16
|
+
result = scope.function_join([["a","b","c"], ":"])
|
|
17
|
+
result.should(eq("a:b:c"))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the keys function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("keys").should == "function_keys"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_keys([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return an array of keys when given a hash" do
|
|
16
|
+
result = scope.function_keys([{'a'=>1, 'b'=>2}])
|
|
17
|
+
# =~ performs 'array with same elements' (set) matching
|
|
18
|
+
# For more info see RSpec::Matchers::MatchArray
|
|
19
|
+
result.should =~ ['a','b']
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the lstrip function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("lstrip").should == "function_lstrip"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_lstrip([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should lstrip a string" do
|
|
16
|
+
result = scope.function_lstrip([" asdf"])
|
|
17
|
+
result.should(eq('asdf'))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe "the max function" do
|
|
6
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
7
|
+
|
|
8
|
+
it "should exist" do
|
|
9
|
+
Puppet::Parser::Functions.function("max").should == "function_max"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
13
|
+
lambda { scope.function_max([]) }.should( raise_error(Puppet::ParseError))
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should be able to compare strings" do
|
|
17
|
+
scope.function_max(["albatross","dog","horse"]).should(eq("horse"))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should be able to compare numbers" do
|
|
21
|
+
scope.function_max([6,8,4]).should(eq(8))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "the member function" do
|
|
5
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
6
|
+
|
|
7
|
+
it "should exist" do
|
|
8
|
+
Puppet::Parser::Functions.function("member").should == "function_member"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should raise a ParseError if there is less than 1 arguments" do
|
|
12
|
+
lambda { scope.function_member([]) }.should( raise_error(Puppet::ParseError))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should return true if a member is in an array" do
|
|
16
|
+
result = scope.function_member([["a","b","c"], "a"])
|
|
17
|
+
result.should(eq(true))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should return false if a member is not in an array" do
|
|
21
|
+
result = scope.function_member([["a","b","c"], "d"])
|
|
22
|
+
result.should(eq(false))
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#! /usr/bin/env ruby -S rspec
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Puppet::Parser::Functions.function(:merge) do
|
|
6
|
+
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
|
7
|
+
|
|
8
|
+
describe 'when calling merge from puppet' do
|
|
9
|
+
it "should not compile when no arguments are passed" do
|
|
10
|
+
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
|
|
11
|
+
Puppet[:code] = '$x = merge()'
|
|
12
|
+
expect {
|
|
13
|
+
scope.compiler.compile
|
|
14
|
+
}.to raise_error(Puppet::ParseError, /wrong number of arguments/)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should not compile when 1 argument is passed" do
|
|
18
|
+
pending("Fails on 2.6.x, see bug #15912") if Puppet.version =~ /^2\.6\./
|
|
19
|
+
Puppet[:code] = "$my_hash={'one' => 1}\n$x = merge($my_hash)"
|
|
20
|
+
expect {
|
|
21
|
+
scope.compiler.compile
|
|
22
|
+
}.to raise_error(Puppet::ParseError, /wrong number of arguments/)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe 'when calling merge on the scope instance' do
|
|
27
|
+
it 'should require all parameters are hashes' do
|
|
28
|
+
expect { new_hash = scope.function_merge([{}, '2'])}.should raise_error(Puppet::ParseError, /unexpected argument type String/)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should be able to merge two hashes' do
|
|
32
|
+
new_hash = scope.function_merge([{'one' => '1', 'two' => '1'}, {'two' => '2', 'three' => '2'}])
|
|
33
|
+
new_hash['one'].should == '1'
|
|
34
|
+
new_hash['two'].should == '2'
|
|
35
|
+
new_hash['three'].should == '2'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should merge multiple hashes' do
|
|
39
|
+
hash = scope.function_merge([{'one' => 1}, {'one' => '2'}, {'one' => '3'}])
|
|
40
|
+
hash['one'].should == '3'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'should accept empty hashes' do
|
|
44
|
+
scope.function_merge([{},{},{}]).should == {}
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|