summaryrefslogtreecommitdiff
path: root/spec/unit/network/http/api
AgeCommit message (Collapse)AuthorFilesLines
2014-06-10(PUP-2426) Add missing fields to environment http jsonHenrik Lindberg1-3/+24
This adds the two new properties environment_timeout, and config_version to the returned settings properties. The timeout is either an integer measured in seconds from min 0, or the string 'unlimited'.
2014-04-07(PUP-2158) Report 404 for missing environmentAndrew Parker1-1/+11
Now that there is a possibility of environments not existing (when directory environments are enabled) the API needs to report a 404 Not Found error when the client requests an environment that doesn't exist.
2014-04-07(PUP-2158) Default a missing manifest to no_manifestAndrew Parker1-1/+1
The tests were often creating environments that didn't need to have manifests. Since we didn't have a way of specifying that when they were written, we used '' to fill in the blank. This actually caused a large number of tests to try to find code to load in the PWD, which caused tests to break if a developer had parse errors in manifests being used for testing in the root directory of their puppet project. This changes the manifest to be optional and removes '' from those tests. The tests no longer fail if a bad manifest is in the PWD :D
2014-02-21(PUP-1678) Puppet::Node::Environment.create expands manifest pathJosh Partlow1-2/+2
Modulepath was already being expanded; this ensures manifest is expanded as well and fixes some specs so that they will work on Windows too.
2014-02-20(PUP-1678) List environment settings instead of modulesAndrew Parker1-15/+6
In talking with consumers of the environment information it turns out that listing the modules isn't the desired feature. Instead they really want the settings of the environment (modulepath, manifest). Other settings may be added later. This has the added benefit that listing the environments is now a much cheaper operations since it doesn't need to load the module data.
2014-01-29(PUP-1118) Stop using Environment.newAndrew Parker1-13/+6
Instead of creating environments directly, we need to go through the configured environment loaders, otherwise environments can't come from other places.
2014-01-24(PUP-1151) Respond with 404 when path not knownAndrew Parker1-0/+14
The v2.0 api implementation had a type that was not caught by any tests. This fixes that issue (a typo) and adds a test that would have shown the problem.
2014-01-14(PUP-1151) Consolidate JSON schema validationAndrew Parker1-9/+4
This adds a new matcher to the JSONMatchers to validate json against a given json-schema. All of the json schema validation now goes through this one matcher, which also handles skipping the checks on windows.
2014-01-13(PUP-1151) Hard code return of only production environmentAndrew Parker1-0/+63
This plumbs in the first step and getting the list of environments returned. At the moment it is hard coded to only ever return the prodution environment.
2014-01-13(PUP-1151) Authorize v2 api requestsAndrew Parker1-0/+57
This commit does several things, all in order to make authorizing API V2 requests a bit easier: * Renames /v2 to /v2.0, which was chosen because it doesn't conflict with a legal environment name in the V1 API. * Adds route chaining so that a handler can deal with a request prefixed with /v2.0 and then continue on to another route * Changes how calls to authorization are handled so that full paths are checked rather than indirection/key pairs. * Introduces an authorization step in the /v2.0 request chain. This is currently limited to only handle GET requests (seen as find in auth.conf).
2014-01-13(PUP-1151) Move HTTP Errors to own moduleAndrew Parker1-3/+3
They aren't really part of the handler, and many more areas of HTTP processing are referring to them.
2014-01-09(PUP-1151) Add routing framework.Dan Lidral-Porter1-29/+29
Add a routing framework for the HTTP module that routes requests to either the V1 or V2 API as appropriate (first it sees if the V2 API would like to handle a request, and if not it's passed off to the V1 API). To support the routing framework, several new classes in the HTTP module are introduced: Request, Route, Response, and MemoryResponse (for testing). The V2 API is implemented in lib/puppet/network/http/api/v2.rb. Change the method to handle the request from process to call, which allows using lamdbas and procs as route handlers. Change the require path in the HTTP module to break a cycle, which necessitates changing requires in a few other files to just require the entire Puppet::Network::HTTP module (rather than just the V1 API class). Delete Puppet::Network::HTTP:RackHttpHandler because it was useless. Change the initialize method of Puppet::Network::HTTP::WEBrickRest to omit the unused handler argument.
2014-01-09(PUP-1151) Factor out v1 HTTP request processing into own request processor.Dan Lidral-Porter1-62/+365
The end goal is to have v1 and v2 API endpoints in their own processors, with the routes registered on a shared handler that performs client authentication and dispatch. This commit rips out the v1 endpoints to their own processor, but does not define anything about the handler including registration. v1-related behavorial tests have been moved from the handler spec to the v1 spec.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
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-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
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-04-24Merge branch 'pcarlisle-ticket/master/3910-updates'Daniel Pittman1-2/+2
This reflects pull request #691, but is being done by hand because the changes in this code reveal the weak stubbing performed in other agent tests.
2012-04-24Merge 2.6.x into 2.7.xDaniel Pittman1-0/+8
A variety of unexciting conflicts were manually resolved, and the delta checked for sanity, since it was tiny. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2012-04-23Make positional arguments distinct in Request#initializePatrick Carlisle1-2/+2
Puppet::Indirector::Request#initialize had a weird implementation giving variable semantics to positional arguments. This makes it normal again.
2012-04-03Fix for bucket_path security vulnerabilityAndrew Parker1-0/+8
This is a fix for Bugs #13553, #13418, #13511. The bucket_path parameter allowed control over where the filebucket will try to read and write to. The only place available to stop this parameter is in the resolution from a URI to an indirectory terminus. The bucket_path is used internally for local filebuckets and so cannot be removed completely without a larger change to the design.
2012-04-02Fix for bucket_path security vulnerabilityAndrew Parker1-0/+8
This is a fix for Bugs #13553, #13418, #13511. The bucket_path parameter allowed control over where the filebucket will try to read and write to. The only place available to stop this parameter is in the resolution from a URI to an indirectory terminus. The bucket_path is used internally for local filebuckets and so cannot be removed completely without a larger change to the design. Conflicts: lib/puppet/network/http/api/v1.rb spec/unit/network/http/api/v1_spec.rb Conflicts resolved by modifying the patch to fit the use of Puppet::Indirector::Request in the code.
2011-12-05(#7004) Correctly form singular for indirections ending in 'es'Brice Figureau1-0/+4
This got broken when the status indirection was added around d1f1858ea52d3089fd2088994e80d6f49d7e0347. The problem is that the regex matching is greedy so any indirection ending in e (and pluralized in 'es') will lose its trailing 'e'. Since all this was done for the status indirection, my fix is to treat differently this indirection only, instead of trying to fix the general case (and breaking it). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
2011-05-03(#7117) Return the environment as a Puppet::Node::Environment in uri2indirectionJacob Helwig1-2/+6
The environment returned by uri2indirection used to be a Puppet::Node::Environment. When this changed to simply being the string of the environment name, this broke assumptions made in other areas of the code. Paired-with: Nick Lewis <nick@puppetlabs.com>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-2/+1
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-12(#6117) Add POST support to indirector requestsNick Lewis1-0/+26
POST with a singular indirection is turned into a find in the indirector. When making a large find request from a REST terminus, POST is used, and for small requests, GET is used for backward compatibility. Paired-With: Jesse Wolfe
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
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 Robinson1-1/+1
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-07Merge branch '2.6.next' into nextMatt Robinson1-0/+28
This was a particularly nasty merge, so rather than hold up merges into next any longer, I'm going to push this merge with a few outstanding problems. The tests that were failing in the following areas have been marked pending, and will be addressed separately, immediately following this push. TODO: Verify that brice's rdoc change is still valid: tests to show that line numbers from class, define and node get into the ast Fix mount parsed_spec spec/unit/provider/mount/parsed_spec.rb * 2.6.next: (85 commits) (#5148) Fix failing spec due to timezone (#5148) Add support for PSON to facts (#6338) Remove inventory indirection, and move to facts indirection (#6445) Fix inline docs: puppet agent does not accept --mkusers Update CHANGELOG and version for 2.6.6rc1 (#6541) Fix content with checksum truncation bug (#6418) Recursive files shouldn't be audited (#6541) maint: whitespace cleanup on the file integration spec (#6541) Fix content with checksum truncation bug (#5466) Write specs for output of puppet resource (#5466) Monkey patch Symbol so that you can sort them (#5466) Fixed puppet resource bug with trailing , Update CHANGELOG for 2.6.5 (#4922) Don't truncate remotely-sourced files on 404 (#6338) Remove unused version control tags Maint: Align tabs in a code block in the Augeas type. (#6509) Inline docs: Fix erroneous code block in directoryservice provider for computer type Maint: Rewrite comments about symlinks to reflect best practice. (#6509) Inline docs: Fix broken lists in Launchd provider. (#6509) Inline docs: Fix broken code blocks in zpool type ... Manually Resolved Conflicts: lib/puppet/application/inspect.rb lib/puppet/defaults.rb lib/puppet/file_bucket/dipper.rb lib/puppet/network/http/handler.rb lib/puppet/node/facts.rb lib/puppet/parser/parser.rb lib/puppet/parser/parser_support.rb lib/puppet/util/command_line/puppet lib/puppet/util/command_line/puppetd lib/puppet/util/command_line/puppetmasterd lib/puppet/util/monkey_patches.rb lib/puppet/util/rdoc/parser.rb spec/unit/application/agent_spec.rb spec/unit/file_bucket/file_spec.rb spec/unit/indirector/file_bucket_file/file_spec.rb spec/unit/network/http/handler_spec.rb spec/unit/parser/parser_spec.rb spec/unit/provider/mount/parsed_spec.rb
2011-02-21(#6376) Add test case for facts find requestMax Martin1-1/+5
Added test case to ensure indirection name is not changed from "facts" when making an HTTP GET request. Reviewed-by:Paul Berry <paul@puppetlabs.com>
2011-02-18(#6376) Add support and testing for _search GET requestsMax Martin1-0/+12
Added support for adding "_search" to the end of any indirection to 'pluralize' it, and added tests to check this functionality and to test hidden side effect of plurality method unpluralizing indirections. Paired-With:Paul Berry <paul@puppetlabs.com>
2011-02-17(#5132) Provide a query REST interface for inventoryPaul Berry1-0/+12
This REST interface returns a list of nodes that match a fact query. Fact queries can use (in)equality testing as a string comparison, and >, <, >=, <= numerical comparisons. Multiple tests can be done as AND comparisons, not OR. The fact queries need to be prefixed by facts, and the comparisons other than equality are specified with a .comparison_type after the fact name. This will be better explained in the REST documentation on the website. Searches that don't match anything now return empty array instead of a 404 error. Conflicts: spec/spec_helper.rb
2011-01-19Merge branch '2.6.x' into nextMatt Robinson1-0/+4
* 2.6.x: (21 commits) (#5900) Include ResourceStatus#failed in serialized reports (#5882) Added error-handling for bucketing files in puppet inspect (#5882) Added error-handling to puppet inspect when auditing (#5171) Made "puppet inspect" upload audited files to a file bucket Prep for #5171: Added a missing require to inspect application. Locked Puppet license to GPLv2 (#5838) Support paths as part of file bucket requests. (#5838) Improve the quality of file bucket specs. (#5838) Make file bucket dipper efficient when saving a file that already exists (#5838) Implemented the "head" method for FileBucketFile::File terminus. (#5838) Reworked file dipper spec to perform less stubbing. (#5838) Added support for HEAD requests to the indirector. (#5838) Refactored error handling logic into find_in_cache. (#5838) Refactored Puppet::Network::Rights#fail_on_deny maint: Remove unused Rakefile in spec directory (#5171) Made filebucket able to perform diffs (#5710) Removed unnecessary calls to insync? Prep for fixing #5710: Refactor stub provider in resource harness spec Maint: test partial resource failure maint: Inspect reports should have audited = true on events ... Manually Resolved Conflicts: lib/puppet/file_bucket/dipper.rb lib/puppet/indirector.rb lib/puppet/network/rest_authconfig.rb spec/unit/file_bucket/dipper_spec.rb spec/unit/file_bucket/file_spec.rb spec/unit/indirector_spec.rb
2011-01-12(#5838) Added support for HEAD requests to the indirector.Paul Berry1-0/+4
Added the ability for the indirector to handle REST HEAD requests. These are done using a new indirector method, head(), which should return true if find() would return a result and false if find() would return nil. Access control for the head method is the union of that for the find and save methods. That is, if either find or save is allowed, then head is allowed. This is necessary so that users will not have to change their authconfig to take advantage of the new feature. Paired-with: Jesse Wolfe <jesse@puppetlabs.com>
2010-11-02Maint: Remove Indirector::Request objects from HTTP Handler and API V1Jesse Wolfe1-13/+14
This is a maintenance refactor to reduce the dependencies between the rest API and the implementation of the Indirector. The HTTP Handler code was creating temporary Request objects that were not actually being passed to the Indirector.
2010-10-28(#5132) Provide a query REST interface for inventoryMatt Robinson1-0/+12
This REST interface returns a list of nodes that match a fact query. Fact queries can use (in)equality testing as a string comparison, and >, <, >=, <= numerical comparisons. Multiple tests can be done as AND comparisons, not OR. The fact queries need to be prefixed by facts, and the comparisons other than equality are specified with a .comparison_type after the fact name. This will be better explained in the REST documentation on the website. Searches that don't match anything now return empty array instead of a 404 error.
2010-07-09Code smell: Two space indentationMarkus Roberts1-83/+83
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 Roberts1-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 Roberts1-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-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts1-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
2009-03-20Moving the REST API functions into a moduleLuke Kanies1-0/+122
This module is now used by the client and server side, rather than having a Handler module that's 90% server functionality but also used by the client. While we don't automatically get api choice from this, it at least provides a pattern for how we'll handle API development over time. Signed-off-by: Luke Kanies <luke@madstop.com>