summaryrefslogtreecommitdiff
path: root/spec/unit/reports
AgeCommit message (Collapse)AuthorFilesLines
2014-08-18(PUP-3030) Refactor 'store' report to use replace_fileChris Price1-16/+0
There was some logic in the 'store' report processor that was almost identical to the logic in 'puppet/util.rb''s 'replace_file' method. This commit refactors 'store' to re-use the existing logic.
2014-01-08Merge pull request #2232 from ↵Josh Partlow1-2/+2
hlindberg/pup-716_short-lived-objects-in-filesystem (PUP-716) short lived objects in filesystem
2014-01-06(PUP-761) Make most FileSystem API change related test passHenrik Lindberg1-2/+2
2014-01-03(PUP-1068) Add basic auth to HTTP ConnectionAndrew Parker1-6/+8
Sometimes a request needs to perform authentication. We can support this with basic auth readily enough. This commit moves the basic auth support from the report processor and makes it a capability of the network connection code. As part of this it needed to move away from using the #get, #post, etc calls on the connection object and instead construct the Net::HTTP request objects. This might present a slight change in behavior, but not one that users will normally notice. The most noticable change is that the #request method can no longer be used for calling arbitrary methods on the underlying connection, instead it can only be used to call to the appropriate request method (get, head, delete, post, put) In order to make this work more clearly, this also adds actual parameters to the connection class's #get, #post, etc methods. The defaults are taken from the Net::HTTP defaults, which is what would have been used before.
2014-01-03(#7173) Add HTTP basic auth support to HTTP reporting in Puppet.Stephen Gelman1-0/+9
Does the following: * Add logic in Puppet::Reports::Http to properly handle HTTP basic auth using the form http://username:password@host/path * Add a unit test to make sure HTTP basic auth is done if it is given in the url
2013-12-20(PUP-1133) Windows tests write config to tempEthan J. Brown1-1/+0
- Previously tests were writing to the shared %ALLUSERSPROFILE%\PuppetLabs\puppet directory, and would blow up if this directory did not exist - Because this directory was shared from one run to the next, failing tests could be masked by data generated / used by a locally installed Puppet - The stubbing of FileSystem::File.exist? to return true was causing some tests to treat files like c:\dev\null\foo to attempt to be loaded, which would cause these tests to fail in isolation, but not when run within the suite - Had to change some doc specs under Ruby 1.9 / OSX to verify a value instead of asserting a method was called, to prevent a stack overflow - In some unit tests, the process of reading / writing settings caused issues with test loading, so Puppet.settings.use has been stubbed
2013-11-19(#23116) Provide pluggable SSL verificationAndrew Parker1-34/+19
This provides the ability to create a verifier for SSL connections opened with puppet's Puppet::Network::HTTP::Connection. The verifier is provided the Net::HTTP connection and it just needs to configure it for the correct verification mode. The new functionality can be used when puppet's standard SSL verification rules are not suited to the needs of the caller. The impetus for this was a requirement that a connection be able to be made, the certificates checked, but the subject and alt name checks skipped. Rather than put that directly into puppet, this allows a new validator to be written that performs those checks.
2013-11-13(#19447) Puppet::FileSystem::File.unlinkEthan J. Brown1-1/+1
- All previous File.unlink calls go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-11-08(#19447) Puppet::FileSystem::File.exist?Ethan J. Brown1-1/+1
- All previous File and FileTest calls to exist? or exists? go through the new FileSystem::File abstraction so that the implementation can later be swapped for a Windows specific one to support symlinks
2013-07-03(#18255) - Follow http redirectionsBrice Figureau1-1/+1
This patch adds support for HTTP redirection in the Puppet HTTP client. The http client includes a redirection limit, and recreate the redirected connection with the same certificates and store as the original (as long as the redirect new location is ssl protected). This patch allows redirection following for all HTTP methods, which in the Puppet ecosystem shouldn't be an issue. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com> Use a loop - temp commit
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune4-4/+4
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-08-17(#15975) Extract HTTP methods from REST IndirectorChris Price1-10/+15
There were some useful HTTP methods (http_get, http_post, ..., http_request) in the Puppet::Indirector::REST class. Most noteworthy is the http_request method, which provides some useful error handling so that users get less confusing error messages when something goes wrong with their certificates / SSL setup. These methods would be useful in several other places (among them: the HTTP reports processor and several places in the puppetdb termini), but prior to this commit it was very difficult (or impossible) to use them without doing a very confusing dance with unnecessary ruby mixins and inheritance from classes in the Indirectory hierarchy. This commit factors these methods out into the new Puppet::Network::HTTP::Connection class, and tweaks Puppet::Network::HttpPool to return instances of this new class. It also refactors the HTTP report processor to use Puppet::Network::HTTP::Connection.
2012-08-01(#15786) Allow plain http connections for report processorsPatrick Carlisle1-11/+31
A recent change (commit ce44885) to support https connections for report processors accidentally enabled SSL for all http report processors. This patch fixes protocol detection and adds tests to make sure both cases work.
2012-07-12Merge branch '2.7.x' into 3.0rcPatrick Carlisle1-0/+28
* 2.7.x: (26 commits) Extract host validation in store report processor Use cross-platform absolute paths in file_serving tests (#15221) Create /etc/puppet/modules directory for puppet module tool (Maint:) Fix bad doc strings for two settings ("wether") Try again to avoid circular dependency in file indirections Remove useless tests for Envelope Clear deprecation warnings between tests Avoid circular requirement in FileMetadata indirection (Maint) Document common Windows issues Update CHANGELOG lib/puppet.rb conf/redhat/puppet.spec for 2.7.18 Maint: Note in docs that the file type's "replace" attribute defaults to true Reject directory traversal in store report processor Tighten permissions on classfile, resourcefile, lastrunfile, and lastrunreport. Use "inspect" when listing certificates Don't allow the creation of SSL objects with invalid certnames Validate CSR CN and provided certname before signing Add specs for selector terminuses of file_{content,metadata} Fix whitespace inside parentheses Use head method to determine if file is in file bucket Always use the local file_bucket on master ... Conflicts: CHANGELOG conf/redhat/puppet.spec lib/puppet.rb lib/puppet/application/master.rb lib/puppet/defaults.rb lib/puppet/file_serving/terminus_selector.rb lib/puppet/reports/store.rb lib/puppet/test/test_helper.rb spec/integration/file_serving/content_spec.rb spec/integration/file_serving/metadata_spec.rb spec/shared_behaviours/file_serving.rb spec/unit/file_serving/terminus_selector_spec.rb spec/unit/network/handler/ca_spec.rb test/ral/manager/attributes.rb
2012-07-12Extract host validation in store report processorPatrick Carlisle1-13/+13
Extract the validation step and refactor tests around this. Tests now don't touch the filesystem which avoids a corner case on windows that caused test failures.
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune4-4/+4
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2012-06-28Reject directory traversal in store report processorPatrick Carlisle1-0/+28
2012-04-24Merge 2.7.x into master.Daniel Pittman1-0/+50
2012-04-17(#13645) Add test cases to tagmail_specStefan Schulte1-0/+50
If puppet is configured to use tagmail as a report, it should not send an email if no message match any tag in tagmail.conf The former behaviour was that puppet opened an smtp connection, did not send any mail and then closed the connection again leading to errors on the smtp server. The added tests now prove that the send method is never even called when no message match any positive tag.
2012-04-09Merge branch '2.7.x'Patrick Carlisle1-0/+77
* 2.7.x: (#9167) Do not send email when nothing changes [#13686] Fix directoryservices ShadowHashData code Fixup tests to work on CentOS 5 fix bug in Util#symbolizehash! (#13567) Fix create_resources name parameter bug (#13636) Update Module Face copyright date (#13737) Swap build_tree and format_tree method names (#9167) Do not send email when nothing changes Add Module Tool Make core changes needed for the puppet module tool (#13367) Patch SemVer to permit ranges including pre-release components. Monkey patch FileUtils.mv in Ruby 1.8.5 (#1076) Show warning if an empty group is specified Maint: Remove unused mock objects in user spec Maint: Use real objects in user spec Maint: Add a real provider class to user spec Maint: Remove unused variable in user spec Conflicts: lib/puppet/util/monkey_patches.rb spec/unit/type/resources_spec.rb spec/unit/type/user_spec.rb
2012-04-09(#9167) Do not send email when nothing changesKelsey Hightower1-0/+77
Without this patch the tagmail report sends an email even when there are no changes or resources out of sync. This has the undesired effect of sending emails after every Puppet run. When there are no changes or out of sync resources, tagmail logs a notice stating the fact and skips processing logs and sending emails. This patch includes new spec tests for the changes in behavior.
2012-03-05Merge branch '2.7.x'Patrick Carlisle1-31/+47
* 2.7.x: (#10722) Add spec to verify that an error is logged on bad http (#10722) Refactor http_spec to use expectations Updating CHANGELOG for 2.7.12rc2 (#7592) Remove redundant call to String#to_s (#11988) Work around Augeas reload bug when changing save modes (#11988) Don't overwrite symlinks in augeas provider (#8312) Fix zypper provider so ensure => 'latest' now works (#12844) Fix a unit test relating to lockfiles (#12914) Allow puppet to be interrupted while waiting for child (#12933) Better error message when agent is administratively disabled (#7592) Remove redundant call to String#to_s (#12844) Agent lockfiles: backwards compatibility with 2.7.10/2.7.11 (#10722) Display errors on HTTP report submission failures Revert "Merge remote-tracking branch 'masterzen/tickets/2.7.x/3757' into 2.7.x" Revert "(#12844) Backwards compatibility for 'puppet agent --enable'" (#11988) Work around Augeas reload bug when changing save modes (#11988) Don't overwrite symlinks in augeas provider (#12881) Fix cron type default name error on windows (#12844) Backwards compatibility for 'puppet agent --enable' (#8312) Fix zypper provider so ensure => 'latest' now works Conflicts: lib/puppet/provider/augeas/augeas.rb lib/puppet/reports/http.rb lib/puppet/util/pidlock.rb spec/unit/application/agent_spec.rb spec/unit/provider/augeas/augeas_spec.rb spec/unit/reports/http_spec.rb
2012-03-05(#10722) Add spec to verify that an error is logged on bad httpPatrick Carlisle1-0/+23
2012-03-05(#10722) Refactor http_spec to use expectationsPatrick Carlisle1-31/+24
2012-02-02(#8465) Test for SSL if using https reporturlLauri Tirkkonen1-0/+7
2012-02-02(#8465) Fix args to http_instance in specLauri Tirkkonen1-1/+1
2012-02-02(#8465) Support SSL in HTTP report via HttpPoolLauri Tirkkonen1-2/+3
2011-12-19(#8119) Write reports to a temporary file and move them into placeRicky Zhou1-1/+19
When writing reports, there is a window in between opening and writing to the report file when the report file exists as an empty file. This makes writing report processors a little annoying as they have to deal with this case. This writes the report into a temporary file then renames it to the report file. Signed-off-by: Patrick Carlisle <patrick@puppetlabs.com>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman4-8/+4
We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman4-4/+4
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2011-03-22maint: Change code for finding spec_helper to work with Ruby 1.9Matt Robinson4-4/+4
Running the specs under Ruby 1.9 didn't work using the lambda to recurse down directories to find the spec_helper. Standardizing the way to find spec_helper like the rest of specs seemed like the way to go. Here's the command line perl I used to make the change: perl -p -i -e "s/Dir.chdir.*lambda.*spec_helper.*$/require File.expand_path(File.dirname(__FILE__) + '\/..\/..\/spec_helper')/" `find spec -name "*_spec.rb"` Then I fixed the number of dots for files that weren't two levels from the spec dir and whose tests failed. Reviewed-by: Nick Lewis <nick@puppetlabs.com>
2011-03-18 Merge branch '2.6.x' into nextMatt Robinson1-1/+1
* 2.6.x: (36 commits) Updated CHANGELOG for 2.6.7rc1 (#5073) Download plugins even if you're filtering on tags Fix #5610: Prevent unnecessary RAL lookups Revert "Merge branch 'ticket/2.6.x/5605' of git://github.com/stschulte/puppet into 2.6.next" (#6723) Fix withenv environment restoration bug (#6689) Remove extraneous include of Puppet::Util in InventoryActiveRecord Remove extra trailing whitespace from lib/puppet/resource.rb (#5428) More fully "stub" Puppet::Resource::Reference for use with storedconfigs (#6707) Fix typo in rest_authconfig.rb (#6689) Make inventory_active_record terminus search quickly (#5392) Give a better error when realizing a non-existant resource (#2645) Adding a less-stubby test to verify the "system" attribute's behavior Update CHANGELOG for 2.6.6 maint: Remove serialization of InventoryFact values maint: Rename InventoryHost to InventoryNode Fixed #2645 - Added support for creating system users maint: Remove spec run noise maint:Refactor of mount provider integration tests (#6338) Support searching on metadata in InventoryActiveRecord terminus (#6338) Implement search for InventoryActiveRecord facts terminus ... This merge includes essentially reverting #4904's change to the mount type since tests that came in from 2.6.x specified different behavior and what's correct is not clear to me. I've reopened #4904 and added it to our backlog, and talked to Nigel about the RFC that's currently out on the puppet-users mailing list for a bigger refactor of how the mount provider works. Manually Resolved Conflicts: spec/spec_helper.rb spec/unit/indirector/queue_spec.rb
2011-03-05(#5794) create reports directory when creating host specific directoryValdis Victor Vitayaudom1-1/+1
2011-03-03(#6582) Eliminate the old fakedata helper method.Daniel Pittman1-5/+2
This is replaced with the new my_fixture{,s} methods; old fixture data is ported into the spec tests at the same time, but left where it was against unit tests that require it. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
2011-01-06(#5799) Simplify report dir creationNick Lewis1-0/+31
This report processor was unnecessarily using Puppet to create a single directory. This was causing complex failures in any spec dealing with reports. Paired-With: Paul Berry
2010-12-16(#5493) Add report_format, puppet_version, and configuration_version to ReportsNick Lewis2-2/+2
Current report formats are: 0: 0.25 reports and earlier 1: 0.26.1 - 0.26.4 reports 2: 0.26.5 and beyond Paired-With: Jesse Wolfe
2010-09-29[#4783] (#4783) Fix RRDGraph report generationMatt Robinson1-0/+31
The code made assumptions about report structure that weren't valid for 2.6.x. The change has been verified to work with 0.25.x and 2.6.x report formats. Paired with: Rein Henrichs
2010-09-23Fix for #4708 - tagmail should allow . in tagnameDan Bode1-0/+1
changed the regex so that tagmail allows . in tagname.
2010-09-03[#4308] Remove puppettest from specsMatt Robinson1-2/+2
The less stuff being done in the spec_helper the better for reasoning about what's happening in the tests. puppettest.rb does a lot of things that aren't necessary for the specs, so this patch gets those things out of the spec_helper. Reviewed by: Jesse Wolfe
2010-07-09Code smell: Two space indentationMarkus Roberts2-105/+105
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
2010-06-28[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts2-0/+0
Part 2 re-did the change on the spec files, which it shouldn't have.
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts2-0/+0
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
2010-06-25maint: Rework testing of Reports http processor to be self containedRein Henrichs1-5/+19
* do not monkey patch Net::HTTP in a way that breaks other specs * Use fakes to sense behavior of Net::HTTP
2010-06-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts2-0/+0
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
2010-02-17[#3810] Add http reports processor and `reporturl` settingRein Henrichs1-0/+42
Example puppet.conf: [puppetmasterd] reports = store, http reporturl = http://localhost:3000/reports * Group reporturl and reportdir in new reports section of Puppet::Settings * Add specs for both
2010-04-12Fixing and porting Transaction Report testsLuke Kanies1-0/+94
There are still a few unported tests, but it's at least better now. Signed-off-by: Luke Kanies <luke@puppetlabs.com>