summaryrefslogtreecommitdiff
path: root/spec/unit
AgeCommit message (Collapse)AuthorFilesLines
2014-08-08(PUP-2879) Add cryptdisks-udev to the services blacklistKylo Ginsberg1-1/+5
Also this patch splits out the long line in upstart_spec.rb to be one line per service, so more diff-friendly.
2014-08-08(PUP-744) Expand scope of OpenSSL rescue blockJosh Cooper1-3/+15
The persistent http connection work introduced a regression, preventing the agent from displaying useful error messages when SSL verification fails, e.g. the server's SSL certificate doesn't match the hostname the agent tried to connect to. The connection_spec test didn't catch the issue, because those tests execute with the non-caching pool, which always uses non-persistent connections. The root cause is because the Connection class assumed http connections are started by ruby in the `Net::HTTP#request` method, so the OpenSSL rescue block wrapped that call. However, in order to use persistent http connection, the caller needs to explicitly start the connection prior to calling Net::HTTP#request, which happens in the outer `Connection#with_connection` method. This commit expands the scope of the rescue block. This way we receive meaningful error messages if the connection is started explicitly for persistent connections, or on-demand for non-persistent connections. It also executes the ssl verification tests using persistent connections. Also note that `with_connection` is private, so the fact that `Pool#with_connection` or `Net::HTTP#request` can start the connection is not visible to users of the Connection class.
2014-08-08(maint) Refactor HTTPS verification tests into a shared examplesJosh Cooper1-43/+48
This commit refactors the spec tests that ensure puppet displays meaningful error messages when SSL verification fails, e.g. when the server certificate doesn't match the hostname we connected to.
2014-08-07(PUP-1527) After upgrade from 3.3.2-1 to 3.4.2-1 naginator fails toRichard Clark1-0/+9
create config from exported resources taken from hiera Some changes introduced in hiera around 3.4 resulted in type coersion from strings to FixNums when creating exported resources that were partially built from hiera data. This patch ensures that any non-array parameter passed through the Nagios::Base.to_s is actually a string before trying to run the .sub method on it, and so fixes the above error with exported resources whilst also introducing support for fixnum params for any of the nagios type parameters
2014-08-07(maint) Test that external fact syncing depends on external featureJosh Cooper1-18/+22
Previously, the test was trying to verify that the downloader objects were created with the correct arguments, and testing that the downloader was evaluated twice (since the same downloader was used for both pluginsync and facts). However, the downloader_factory_spec now tests that downloader objects are created correctly, e.g. based on Puppet[:plugindest], so it is not necessary to repeat that here. This commit modifies the test to ensure the Downloader#evaluate methods are called for both downloader objects, and adds a test to ensure we skip downloading facts if the external facts feature is false.
2014-08-07(maint) Move methods for creating downloaders to factoryJosh Cooper3-10/+100
Previously, the plugin_handler module was responsible for creating downloaders and evaluating them. Since all of this happens within a single method it is hard to test that the downloaders are created with the correct set of properties. For example, we `ignore` source permissions when downloading plugins, but we `use` source permissions when downloading external facts, since those often contain scripts, which must be executable. This commit moves the logic for creating the downloaders to a factory and updates the tests accordingly. As part of this change, the PluginHandler module is changed to a class and is no longer mixed into the Configurer.
2014-08-06Merge pull request #2934 from peterhuene/pup/2971Kylo Ginsberg1-0/+1
(PUP-2971) Fix yum package provider missing install_options for list.
2014-08-06Merge pull request #2863 from joshcooper/ticket/master/PUP-744-http-poolingKylo Ginsberg9-61/+618
(PUP-744) Support persistent HTTP connections
2014-08-06(PUP-3019) Make PMT check for string status codes when downloadingAlex Dreyer1-3/+2
Previously PMT was checking for integer status codes when downloading modules. This results in all module downloads failing. After this PMT will check for string status codes when downloading modules.
2014-08-05(PUP-744) Cleanup puppet/ssl require logicJosh Cooper1-1/+0
Previously, validator_spec.rb was requiring 'puppet/ssl/configuration', because puppet/ssl.rb did not require it. Commit 658e4fd34 fixed puppet/ssl.rb, so it is no longer necessary or desired for validator_spec.rb to require puppet/ssl/configuration. Also, the default and no_validators were not consistent in expressing their dependencies on openssl and puppet/ssl.
2014-08-05(PUP-3009) Add error handling to PMT module downloadsAlex Dreyer3-10/+14
Before this PMT would not check if the module download request succeeded before trying install the module. This causes informative errors from forge to be hidden by an error about the checksum of the download not matching. After this PMT will only move forward with module installation if a 200 is received from forge otherwise it will display the error returned by forge.
2014-08-04(PUP-2898) Specify terminal semicolon for resource bodiesJosh Partlow1-0/+9
There was a regression in the future parser in d25e462 which caused resources with multiple attributeless bodies constructed like this: file { '/foo':; '/bar':; } to fail because the future parser grammar was not allowing the terminal semicolon. The acceptance suite picked this up running with parser future. It slipped past specs because, even though we have a spec testing multiple attributeless resource bodies, it lacked a terminal semicolon. Henrik Lindberg figured out the minor egrammar fix here to correct the expression, and a test case is added to catch it in specs.
2014-08-04(PUP-2971) Fix yum package provider missing install_options for list.Peter Huene1-0/+1
When executing the list command to filter virtual packages (when allow_virtual is false or nil), the yum package provider was not passing down the install options to the list command. For users passing options like --enablerepo, this prevents the packages from being discovered and the list command fails. The fix is to properly pass down the install options when executing the list command.
2014-08-01Merge pull request #2851 from highb/fix/master/pup-2745_forge_dependency_fixAnderson Mills2-91/+230
PUP-2745 Forge malformed dependency fix
2014-08-01(PUP-501) Check virtual and exported resourcesAndrew Parker1-1/+1
This adds checks for the specification's assertions that virutal and exported resources are not in the produced catalog, but are available for later operations (realization) and reference (reading a parameter value). This cannot check that the exported resources are made available to catalog processors, since that is implementation dependent. In order to check this the compile_to_catalog method needed to be changed to filter out expoerted resources, just like the catalog indirection does. This required a change to the create_resources test.
2014-08-01(maint) Add tests and fix up dump actionAndrew Parker1-32/+70
There were a few formatting problems with the dump action. This fixes those up and adds tests around the dump functionality.
2014-08-01(PUP-2898) Add 4x style resource expressionsHenrik Lindberg6-85/+230
This changes the following: * Assignment has lower precedence than resource expressions * Local defaults are supported in resource instantiation expressions * A Resource body may have a new expression AttributesOperation that must evaluate to a hash. * Stricter validation of resource titles * Changes to TreeModelDumper wrt how BlockExpression is rendered (to improve debugging output). As a consequence many tests needed adjustments. * Tests that previously passed have been modified because of stricter validation. This also includes maintenance. Removing dead code/fixing stale comments and documentation.
2014-08-01(PUP-2898) Drop support for AST Transform of ResourcesHenrik Lindberg1-185/+0
The implementation no longer needs to transform resource expressions to 3x AST. This changes the transformer to raise an error if attempted. The spec test for resource transformation is also dropped. No new test added that transformer raises exceptions for resource transformation since all transformation eventually will be dropped.
2014-07-31Merge pull request #2930 from highb/fix/master/pup-2912-windows-spec-testsAnderson Mills2-4/+6
(PUP-2912) Puppet FS symlinks in build/unpack
2014-07-31(PUP-2912) Puppet FS symlinks in build/unpackBrandon High2-4/+6
Prior to this commit build/unpack were trying to use the Ruby stdlib symlink to deal with symlinks. This fails on platforms (Windows) that Puppet says supports symlinks because it does not duck punch Ruby stdlib. This commit switches the specs and code for build/unpack to use Puppet FS lib's symlink functions. This should allow it to function correctly on Windows hosts that Puppet supports symlinks.
2014-07-31Merge pull request #2927 from highb/fix/master/pup-2912-windows-spec-testsAnderson Mills2-4/+4
(PUP-2912) Build/unpack spec tests w/o symlinks
2014-07-31(PUP-2912) Build/unpack spec tests w/o symlinksBrandon High2-4/+4
Prior to this commit we would try to use symlinks in the tests on platforms that do not support symlinking. This commit uses the Puppet feature checker to conditionally try the tests if Puppet thinks the platform supports symlinks (Unixes, Linuxes, Win 2k8+).
2014-07-31Merge pull request #2867 from hlindberg/PUP-2860_optimizations-and-maintenanceAndrew Parker2-841/+1
(PUP-2860) optimizations and maintenance
2014-07-30Merge pull request #2854 from highb/fix/master/pup-2912_build_no_symlinksAnderson Mills2-1/+61
(PUP-2912) PMT Build symlink exception
2014-07-30(PUP-2745) Ignore malformed forge dependenciesBrandon High1-89/+173
Prior to this commit a malformed name in the dependencies for a downloaded forge module dependency would cause the PMT to fail unexpectedly. This commit causes the PMT to ignore malformed dependencies.
2014-07-29Merge pull request #2880 from ↵Adrien Thebo1-0/+15
fiddyspence/feature/2945/warning_on_windows_package_source (PUP-398) Windows package provider source munging and test
2014-07-29(PUP-2912) Builder/unpacker spec testsBrandon High2-1/+61
Adding spec tests to check for symlinks in build/install.
2014-07-29(PUP-398) Munge package source on Windowsfiddyspence1-0/+15
Adding munge and slashreplace method to windows package provider to ensure successful installation of packages. Validation in the type validate() not possible because we haven't chosen a provider at that point. Outputs debug as a means of notifying the user that the source has been changed.
2014-07-28Merge pull request #2918 from ↵Peter Huene1-71/+90
adrienthebo/fixup/master/pup-2871-install-uninstall-options-pacman Fixup/master/pup 2871 install uninstall options pacman
2014-07-28(PUP-2901) Add module dependency validationBrandon High1-2/+57
Prior to this commit there wasn't much verification for module dependencies. This commit adds verification the module dependencies have sane names and version ranges. If verification fails, it will raise an argument exception.
2014-07-28(maint) Make pacman (un)install_options privateAdrien Thebo1-43/+0
These methods should not be called by any outside class; this commit makes them private and removes the tests that invoke them directly.
2014-07-28(PUP-2871) Concatenate uninstall_options to argvAdrien Thebo1-4/+8
In the same manner as 9137faf uninstall_options were being appended as a nested array value; this commit changes the uninstall method to concatentate options to the array.
2014-07-28(PUP-2871) Concatenate install install_options to argvAdrien Thebo1-0/+20
Before this commit, install_options were passed as a nested array to pacman/yaourt. This commit changes that to concatentate the values with the argument vector.
2014-07-28(maint) Isolate specs from whether yaourt is installedAdrien Thebo1-13/+10
2014-07-28(maint) use RSpec helpers over instance and local variablesAdrien Thebo1-72/+70
2014-07-27(maint) Remove extra abstraction PAbstractType - change to PAnyTypeHenrik Lindberg1-1/+1
Since all types now are PAnyType, there is no need to have an extra abstratin called PAbstractType, it just adds level in the ancestor hierarchy that needs to be consulted for methods, one extra step to go when checking is_a? against PAbstractType instead of PAnyType, etc.
2014-07-27(PUP-2860) Remove future parser's old lexerHenrik Lindberg1-840/+0
The old (intermediate) lexer was still hanging around even if it was not being used. Cycles were also wasted on unit testing it. The new lexer "Lexer2" has been in use for quite some time and the old lexer is not useful even as a reference at this point. This speeds up both loading and unit testing.
2014-07-25Merge pull request #2893 from whopper/upstart-ubuntu-testAdrien Thebo1-0/+5
(maint) Add test to ensure upstart is default init daemon in Ubuntu
2014-07-25(maint) Fix description of masterlog testCharlie Sharpsteen1-1/+1
Re-word the description of a test in `webrick_spec.rb` as it is testing the behavior of `masterhttplog` and not `masterlog`.
2014-07-25Merge pull request #2907 from adrienthebo/maint/master/remove-pending-face-testsJosh Partlow6-42/+0
(maint) Remove pending face specs
2014-07-25(PUP-744) Only cache HTTP and verified HTTPS connectionsJosh Cooper1-1/+37
Previously, it was possible for puppet to create an HTTPS connection with VERIFY_NONE, and cache the connection. As a result, the pool code could hand out an insecure connection, when the caller expected a secure one (VERIFY_PEER). In practice this isn't an issue, because puppet only uses insecure HTTPS connections when bootstrapping its SSL key and certs, and that happens before `Configurer#run` overrides the default non-caching pool implementation. However, it could be an issue if a provider were to request a insecure connection *during* catalog application, as that connection would be cached, and possibly reused by puppet, e.g. when sending the report. This commit modifies the connection pool to only cache HTTP or secure HTTPS connections. All other connections are closed after one HTTP request/response.
2014-07-25(PUP-744) Document http pooling classes and methodsJosh Cooper1-0/+14
Add yard doc for http pooling. Also adds a test to verify multiple persistent connections can be borrowed from the pool.
2014-07-25(maint) Remove unnecessary expectationsJosh Cooper1-6/+2
Remove expectations that were secondary to the actual test, also clarify behavior that was being tested.
2014-07-25(maint) Remove pending test for releasing expired connectionsJosh Cooper1-4/+0
Previously, I was concerned that a caller could borrow a connection from the pool, and perform a long operation before returning it to the pool. That could make it trivial for the caller to add expired connections back to the pool, and cause issues for the next HTTP request. However, that is not likely, because connections are only borrowed for the duration of the `Connection#get`, `#post`, etc calls, and those methods don't take a block. The connection methods that do take a block, e.g. `#request_get` are deprecated, and are not used within puppet.
2014-07-25(PUP-744) Fix off-by-one redirect limit errorJosh Cooper1-1/+19
Previously, the `redirect_limit` specified the maximum number of HTTP requests that the connection would make, not the maximum number of redirects that it would follow. As a result, a limit of 0 would prevent any HTTP requests from being made. This was introduced in 60f22eb1 when the redirect logic was added. This commit changes the limit so that 0 means don't follow redirects, 1 means follow one redirect, etc.
2014-07-25(PUP-744) Don't modify site information when following redirectsJosh Cooper3-50/+81
Previously, the connection would mutate its host, port, etc when following redirects. This wasn't really an issue, because connections were always single use. Now that connections can be cached, we do not want to mutate the original site information even when following permanent redirects.
2014-07-25(PUP-744) Remove private Connection#connection methodJosh Cooper2-29/+58
Previously, the `Connection#connection` method was used in `connection_spec.rb` to validate the state of the Net::HTTP object created by the puppet connection. Since the puppet connection no longer owns an Net::HTTP object (it may use newly created or cached instances), the `#connection` method doesn't make sense, and since it was private, can be removed. The tests that relied on the private method have been updated, and in some cases moved to the factory_spec, e.g. verifying proxy settings.
2014-07-25(PUP-744) Ensure connections we create support at least HTTP 1.1Josh Cooper1-0/+6
When starting a persistent HTTP connection, we do not expliclty specify `Connection: Keep-Alive`, because that is the default in HTTP/1.1[1]. This commit adds a test to ensure we are using HTTP 1.1 or later. Amazingly ruby has defaulted to 1.1 as far back as ruby 1.8.7[2]. [1] http://tools.ietf.org/html/rfc7230#appendix-A.1.2 [2] https://github.com/ruby/ruby/blob/v1_8_7/lib/net/http.rb#L282
2014-07-25(PUP-744) Remove unnecessary after each routineJosh Cooper1-4/+0
The puppet connection class doesn't have an ssl_host instance variable.
2014-07-25(PUP-744) Move connection factory into the poolsJosh Cooper5-57/+53
Previously, the puppet connection class owned the Net::HTTP factory and passed it to the pool when requesting a connection. However, the caching pool only needs the factory when creating a new connection. This commit makes the factory stateless and pushes it into the respective pools. The SSL verifier is stateful (contains peer certs) and remains in puppet's connection class. When a pool needs to create a connection, it calls back into the puppet connection object to initialize SSL on the Net::HTTP object. In the case of the caching poool, it needs to do this before starting the connection, which will perform the TCP connect and SSL handshake operations.