Commit graph

88 commits

Author SHA1 Message Date
Bryan Jen
ecfdbb2690 Merge pull request #600 from dmitryilyin/master
Add the default value to the "loadyaml" function
2016-05-12 14:14:14 -07:00
Dmitry Ilyin
870a272cee Add the default value to the "loadyaml" function
This value will be returned if the is no file
to load or a file could not be parsed.
It's similar to the "parseyaml" function's
default value.

Add the "loadjson" function too
2016-04-26 21:58:29 +03:00
David Schmitt
ee6413b95a Update to newest modulesync_configs [9ca280f] 2016-04-18 20:15:09 +01:00
Alex Tomlins
44596e73da (MODULES-3246) Fix concat with Hash arguments.
85d5ead Updated the concat function so that it wouldn't modify the
original array. A side-effect of this change is that it now always calls
`Array()` on the second argument. If thit is a Hash, this results in
`to_a` being called on the hash, which converts it to an array or
tuples. This is undesired.

Update the behaviour so that it doesn't (indirectly) call `to_a` on
anything, instead test for the type of the argument, wrapping it in an
array if it's not already an array.
2016-04-08 13:42:13 +01:00
Bryan Jen
7943b25ec1 (maint) Fixes fqdn_rand_string tests
Puppet 4.4.0 and later has changed fqdn_rand to use a higher ceiling
(PUP-5646), the tests for fqdn_rand_string needed to be updated to
reflect the new expected output.
2016-03-16 13:57:36 -07:00
Giulio Fidente
d85aec41a3 Add is_ipv4_address and is_ipv6_address functions
These are useful when making decisions based on the type of IP
address received.
2016-01-22 18:01:49 +01:00
David Schmitt
9cce93054a Merge pull request #545 from mpolenchuk/master
Add clamp function
2016-01-04 15:35:42 +00:00
Michael Polenchuk
27782242bc Add clamp function
Clamp keeps value within the range.
Employ of soft() makes the whole thing is independant of order.
2015-12-31 12:46:07 +03:00
David Schmitt
02965b89e5 (FM-3802) make ensure_resource test of packages
This ensures that the test passes independently of changes to rubygems.
2015-12-17 13:50:15 +00:00
Helen Campbell
c7c4d41a82 Added acceptance test and updated readme 2015-09-28 16:18:56 +01:00
Morgan Haskel
b20239e796 Update is_a acceptance tests to only run on puppet4 2015-09-21 14:12:25 -07:00
Morgan Haskel
799c38e14e Fix backwards compatibility from #511
Maintain the old behavior in the case where the optional second
parameter isn't passed. Also, adding arity is backwards incompatible since
stdlib still supports 2.7, so remove that.
2015-09-21 11:11:21 -07:00
Bryan Jen
0ea0e40228 Merge pull request #523 from DavidS/modules-2516-is_a
(MODULES-2561) add is_a function
2015-09-14 10:49:50 -07:00
Bryan Jen
c0df8192ee Merge pull request #511 from dmitryilyin/parseyaml_default
[MODULES-2462] Improve parseyaml function
2015-09-14 10:40:35 -07:00
David Schmitt
00c881d0da (MODULES-2516) Adds an is_a() function
The data type system is very hard to understand. Many people don't
understand why

    type_of([1,2,3]) == Array

will fail, but

    type_of([1,2,3]) <= Array

passes. This does a simpler validation that doesn't rely on explicit
data types. Instead, use

    $foo = [1,2,3]
    if $foo.is_a(Array) {
      notify { 'This is an array': }
    }

This is based on code by Ben Ford <ben.ford@puppetlabs.com>.

  * Added acceptance tests
  * Added dispatch
  * Improved unit tests
  * Added docs to README
2015-09-14 18:26:25 +01:00
David Schmitt
5ef5c6629f (MAINT) fix up try_get_value acceptance test 2015-09-02 13:34:15 +01:00
David Schmitt
64267eb650 Merge pull request #513 from dmitryilyin/fetch
Add a new function "try_get_value"
2015-09-02 09:23:46 +01:00
Dmitry Ilyin
823a352f0f Add a new function "try_get_value"
* Extracts a value from a deeply-nested data structure
* Returns default if a value could not be extracted
2015-09-01 21:45:44 +03:00
Dmitry Ilyin
eb948c4a0d [MODULES-2462] Improve parseyaml function
* Add default value support
  Second argument will be returned if yaml cannot be parsed
  instead of false value
* Update tests
2015-08-25 21:41:03 +03:00
Jetroid
1d9189d860 (MODULE-2456) Modify union to accept more than two arrays
Add spec tests to test the new functionality:
 *Case for 3 arrays.
 *Case for 4 arrays.
Modify README to note new functionality.

This is for issue MODULE-2456, follow the precedent of MODULE-444.

This change allows union to be much more useful, unioning many arrays
in one line rather than in n lines. Additionally, as this is only added
functionality, and does not affect the 2 array case that all modules
currently using array are using, it should not affect any existing
modules utilizing union.

This is now useful, for example, for merging many arrays of resources
(eg: packages.) to generate just one list with no duplicates, to avoid
duplicate resource declarations.
2015-08-24 14:24:10 +01:00
Hunter Haugen
dfa98b89f7 Prep 4.8.0 2015-08-10 16:30:27 -07:00
David Schmitt
a8d7563a44 (main) clean up fqdn_rand acceptance tests to work on windows 2015-07-22 17:30:39 +01:00
David Schmitt
24b1cd78db (maint) Remove failing acceptance test for ensure_packages
This only duplicates what's already being tested in ensure_packages_spec.rb
but doesn't work on all our supported platforms.
2015-07-22 12:21:31 +01:00
Hunter Haugen
615227918a disable pw_hash test on sles, as it only supports md5 2015-07-21 14:43:34 -07:00
Travis Fields
78e8c73671 (maint) Fix test to not assume is_pe fact on > 4.0.0 puppet 2015-07-20 15:51:39 -07:00
Eli Young
98c2f283b0 fqdn_rand_string: Add acceptance tests for custom charsets 2015-06-02 12:02:30 -07:00
Eli Young
84279e90ab fqdn_rotate: Add acceptance tests for custom seeds 2015-06-02 12:02:30 -07:00
Eli Young
601f681787 fqdn_rotate: Don't use the value itself as part of the random seed
Previously, the random number generator was seeded with the array or
string to be rotated in addition to any values specifically provided for
seeding. This behavior is potentially insecure in that it allows an
attacker who can modify the source data to choose the post-shuffle
order.
2015-06-01 16:19:07 -07:00
David Schmitt
f3e79ddcd5 Convert tests to use plain rspec-puppet
Tests in the new style produces the following documentation output:

abs
  should not eq nil
  should run abs() and raise an Puppet::ParseError
  should run abs(-34) and return 34
  should run abs("-34") and return 34
  should run abs(34) and return 34
  should run abs("34") and return 34
2015-06-01 18:02:22 +01:00
Colleen Murphy
65116dafd5 Fix acceptance tests for #405
This fixes the acceptance tests by:
 - Ensuring the fqdn_rand_string spec is passed undef as the second
   parameter so that the seed is not used as the charset
 - Ensuring the pw_hash spec is passed the key specifying the type of
   hash, rather than the value that will be used to generate the
   password
 - Expecting puppet to report nil instead of empty string for undef
   passwords
 - Removing the fqdn_rand_base64 test because there is no such function
2015-04-10 09:15:15 -07:00
Colleen Murphy
e43f058296 Fix unsupported platforms variable name in tests
unsupported_platforms is not a valid identifier, and trying to use it
causes acceptance tests to error out before running any tests. The
correct identifier for the unsupported platforms constants is
UNSUPPORTED_PLATFORMS.
2015-04-09 15:53:16 -07:00
Hunter Haugen
8fba5c058b Merge pull request #405 from elyscape/feature/fqdn_rand_strings
(MODULES-1715) Add FQDN-based random string generator
2015-04-09 10:45:38 -07:00
Eli Young
23be4020dd (MODULES-1737) Add pw_hash() function 2015-04-05 17:21:17 -07:00
Eli Young
a82266c256 (MODULES-1715) Add fqdn_rand string generators 2015-03-31 17:33:04 -07:00
Adam Crews
53b1802a92 Add a ceiling function to complement the floor function. 2015-02-01 22:46:16 -08:00
Hunter Haugen
bfb526899f Change all to each
The existence of this directory is behavior for each test, but will also
stop rspec 3 from complaining.
2015-01-13 17:21:28 -08:00
Morgan Haskel
31a6d89410 Fix bad check in test 2014-12-18 16:20:02 -08:00
Peter Souter
5e49c50458 (MODULES-444) Acceptance for multiple arrays
Acceptance test to take multiple arrays for concatenation
2014-12-04 14:15:33 +00:00
Peter Souter
7c570f75a5 (MODULES-444) Acceptance test for primitives
`concat` should be able to concat arrays and primitives
2014-12-04 14:15:03 +00:00
Travis Fields
3584485902 Fix exclude windows test on ensure_package
Update to fix ensure_resource as well
2014-11-11 16:41:53 -08:00
Hunter Haugen
970141e36a Correct type() logic
It should NOT run if the future parser is enabled
2014-11-11 10:46:01 -08:00
Travis Fields
992ed8ffa8 Remove windows from ensure_package and ensure_resource testing 2014-11-10 16:34:05 -08:00
Morgan Haskel
850297b560 Merge pull request #354 from puppetlabs/4.3.x
4.3.x
2014-11-10 11:10:41 -08:00
Morgan Haskel
03f0ecd128 Merge pull request #350 from cyberious/modules1413
MODULES-1413 Add ability for member to take numeric objects
2014-11-04 15:29:25 -08:00
Travis Fields
f19aea5a75 MODULES-1413 Ability to for future parser to use member with FixNum types 2014-11-04 14:33:34 -08:00
Travis Fields
4bff0d2d61 Merge branch '4.3.x'
Conflicts:
	spec/acceptance/ensure_packages_spec.rb
	spec/acceptance/ensure_resource_spec.rb
2014-11-04 14:17:03 -08:00
Travis Fields
26e864f224 Fix the unless for test cases on ensure_package and ensure_resource
Conflicts:
	spec/acceptance/ensure_packages_spec.rb
	spec/acceptance/ensure_resource_spec.rb
2014-11-04 10:45:13 -08:00
Travis Fields
35c2dc7ca3 Merge branch '4.3.x' 2014-10-30 10:23:12 -07:00
Travis Fields
6c7da72c0f Fix validate_cmd, previous addition of SystemCallError only works for Puppet 3.7, previous version throw different exception. Wrapping in generic Exception catch all 2014-10-29 20:03:07 -07:00
Travis Fields
2b1cc82d24 Add windows test exclusion to ensure_resource 2014-10-28 16:43:15 -07:00