~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/network/http/handler_spec.rb

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:50:52 UTC
  • mfrom: (1.1.30)
  • Revision ID: bkerensa@ubuntu.com-20121121235052-ah7nzabp77sh69gb
New Upstream Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env rspec
 
1
#! /usr/bin/env ruby
2
2
require 'spec_helper'
3
3
require 'puppet/network/http/handler'
4
 
require 'puppet/network/rest_authorization'
 
4
require 'puppet/network/authorization'
 
5
require 'puppet/network/authentication'
5
6
 
6
7
class HttpHandled
7
8
  include Puppet::Network::HTTP::Handler
17
18
  end
18
19
 
19
20
  it "should include the Rest Authorization system" do
20
 
    Puppet::Network::HTTP::Handler.ancestors.should be_include(Puppet::Network::RestAuthorization)
 
21
    Puppet::Network::HTTP::Handler.ancestors.should be_include(Puppet::Network::Authorization)
21
22
  end
22
23
 
23
24
  it "should have a method for initializing" do
51
52
      @result = stub 'result', :render => "mytext"
52
53
 
53
54
      @handler.stubs(:check_authorization)
 
55
      @handler.stubs(:warn_if_near_expiration)
54
56
 
55
57
      stub_server_interface
56
58
    end
66
68
      @handler.stubs(:http_method        ).returns("GET")
67
69
      @handler.stubs(:params             ).returns({})
68
70
      @handler.stubs(:content_type       ).returns("text/plain")
 
71
      @handler.stubs(:client_cert        ).returns(nil)
 
72
    end
 
73
 
 
74
    it "should check the client certificate for upcoming expiration" do
 
75
      cert = mock 'cert'
 
76
      @handler.stubs(:uri2indirection).returns(["facts", :mymethod, "key", {:node => "name"}])
 
77
      @handler.expects(:client_cert).returns(cert).with(@request)
 
78
      @handler.expects(:warn_if_near_expiration).with(cert)
 
79
 
 
80
      @handler.process(@request, @response)
69
81
    end
70
82
 
71
83
    it "should create an indirection request from the path, parameters, and http method" do
80
92
      @handler.process(@request, @response)
81
93
    end
82
94
 
83
 
    it "should call the 'do' method and delegate authorization to the RestAuthorization layer" do
 
95
    it "should call the 'do' method and delegate authorization to the authorization layer" do
84
96
      @handler.expects(:uri2indirection).returns(["facts", :mymethod, "key", {:node => "name"}])
85
97
 
86
98
      @handler.expects(:do_mymethod).with("facts", "key", {:node => "name"}, @request, @response)