Sha256: 2a003929f802fc83995e6d99d9cf9d285abaac47069352706cc315edc4b36356
Contents?: true
Size: 1.54 KB
Versions: 160
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' require 'puppet/network/http' describe Puppet::Network::HTTP::API::Master::V3::Authorization do let(:response) { Puppet::Network::HTTP::MemoryResponse.new } let(:authz) { Puppet::Network::HTTP::API::Master::V3::Authorization.new } let(:noop_handler) { lambda do |request, response| end } it "accepts v3 api requests that match allowed authconfig entries" do request = Puppet::Network::HTTP::Request.from_hash({ :path => "/v3/environments", :method => "GET", :params => { :authenticated => true, :node => "testing", :ip => "127.0.0.1" } }) allow(authz).to receive(:authconfig).and_return(Puppet::Network::AuthConfigParser.new(<<-AUTH).parse) path /v3/environments method find allow * AUTH handler = authz.wrap do noop_handler end expect do handler.call(request, response) end.to_not raise_error end it "rejects v3 api requests that are disallowed by authconfig entries" do request = Puppet::Network::HTTP::Request.from_hash({ :path => "/v3/environments", :method => "GET", :params => { :authenticated => true, :node => "testing", :ip => "127.0.0.1" } }) allow(authz).to receive(:authconfig).and_return(Puppet::Network::AuthConfigParser.new(<<-AUTH).parse) path /v3/environments method find auth any deny testing AUTH handler = authz.wrap do noop_handler end expect do handler.call(request, response) end.to raise_error(Puppet::Network::HTTP::Error::HTTPNotAuthorizedError, /Forbidden request/) end end
Version data entries
160 entries across 160 versions & 1 rubygems