Guest User

Untitled

a guest
Mar 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. diff --git a/spec/unit/network/http_pool.rb b/spec/unit/network/http_pool.rb
  2. index 5034402..3043c5e 100755
  3. --- a/spec/unit/network/http_pool.rb
  4. +++ b/spec/unit/network/http_pool.rb
  5. @@ -9,6 +9,9 @@ require 'puppet/network/http_pool'
  6. describe Puppet::Network::HttpPool, " when adding certificate information to http instances" do
  7. before do
  8. @http = mock 'http'
  9. + [:cert_store=, :verify_mode=, :ca_file=, :cert=, :key=].each { |m| @http.stubs(m) }
  10. + @store = stub 'store'
  11. + [:add_file,:purpose=].each { |m| @store.stubs(m) }
  12. end
  13.  
  14. it "should do nothing if no certificate is available" do
  15. @@ -20,26 +23,18 @@ describe Puppet::Network::HttpPool, " when adding certificate information to htt
  16. it "should add a certificate store" do
  17. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  18. Puppet::Network::HttpPool.stubs(:key).returns(:mykey)
  19. - store = stub "store"
  20. - OpenSSL::X509::Store.expects(:new).returns(store)
  21. - store.stubs(:add_file)
  22. - store.stubs(:purpose=)
  23. - [:verify_mode=, :ca_file=, :cert=, :key=].each { |method| @http.stubs(method) }
  24. - @http.expects(:cert_store=).with(store)
  25. + OpenSSL::X509::Store.expects(:new).returns(@store)
  26. + @http.expects(:cert_store=).with(@store)
  27.  
  28. Puppet::Network::HttpPool.cert_setup(@http)
  29. end
  30.  
  31. it "should add the local CA cert to the certificate store" do
  32. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  33. - store = stub "store"
  34. - OpenSSL::X509::Store.expects(:new).returns(store)
  35. - store.stubs(:purpose=)
  36. - @http.stubs(:cert_store=)
  37. + OpenSSL::X509::Store.expects(:new).returns(@store)
  38. Puppet.settings.stubs(:value).with(:localcacert).returns("/some/file")
  39. Puppet.settings.stubs(:value).with(:localcacert).returns("/some/file")
  40. - store.expects(:add_file).with("/some/file")
  41. - [:store=, :verify_mode=, :ca_file=, :cert=, :key=].each { |method| @http.stubs(method) }
  42. + @store.expects(:add_file).with("/some/file")
  43.  
  44. Puppet::Network::HttpPool.stubs(:key).returns(:whatever)
  45.  
  46. @@ -49,12 +44,9 @@ describe Puppet::Network::HttpPool, " when adding certificate information to htt
  47. it "should set the purpose of the cert store to OpenSSL::X509::PURPOSE_SSL_CLIENT" do
  48. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  49. Puppet::Network::HttpPool.stubs(:key).returns(:mykey)
  50. - store = stub "store"
  51. - OpenSSL::X509::Store.expects(:new).returns(store)
  52. - store.stubs(:add_file)
  53. - [:cert_store=, :verify_mode=, :ca_file=, :cert=, :key=].each { |method| @http.stubs(method) }
  54. + OpenSSL::X509::Store.expects(:new).returns(@store)
  55.  
  56. - store.expects(:purpose=).with(OpenSSL::X509::PURPOSE_SSL_CLIENT)
  57. + @store.expects(:purpose=).with(OpenSSL::X509::PURPOSE_SSL_CLIENT)
  58.  
  59. Puppet::Network::HttpPool.cert_setup(@http)
  60. end
  61. @@ -63,7 +55,7 @@ describe Puppet::Network::HttpPool, " when adding certificate information to htt
  62. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  63. Puppet::Network::HttpPool.stubs(:cert).returns(:mycert)
  64. Puppet::Network::HttpPool.stubs(:key).returns(:mykey)
  65. - [:cert_store=, :verify_mode=, :ca_file=, :key=].each { |method| @http.stubs(method) }
  66. + OpenSSL::X509::Store.expects(:new).returns(@store)
  67.  
  68. @http.expects(:cert=).with(:mycert)
  69.  
  70. @@ -73,7 +65,7 @@ describe Puppet::Network::HttpPool, " when adding certificate information to htt
  71. it "should add the client key" do
  72. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  73. Puppet::Network::HttpPool.stubs(:key).returns(:mykey)
  74. - [:cert_store=, :verify_mode=, :cert=, :ca_file=].each { |method| @http.stubs(method) }
  75. + OpenSSL::X509::Store.expects(:new).returns(@store)
  76.  
  77. @http.expects(:key=).with(:mykey)
  78.  
  79. @@ -83,7 +75,7 @@ describe Puppet::Network::HttpPool, " when adding certificate information to htt
  80. it "should set the verify mode to OpenSSL::SSL::VERIFY_PEER" do
  81. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  82. Puppet::Network::HttpPool.stubs(:key).returns(:mykey)
  83. - [:key=, :cert=, :cert_store=, :ca_file=].each { |method| @http.stubs(method) }
  84. + OpenSSL::X509::Store.expects(:new).returns(@store)
  85.  
  86. @http.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
  87.  
  88. @@ -93,12 +85,7 @@ describe Puppet::Network::HttpPool, " when adding certificate information to htt
  89. it "should set the ca file" do
  90. Puppet::Network::HttpPool.stubs(:read_cert).returns(true)
  91. Puppet.settings.stubs(:value).with(:localcacert).returns("/some/file")
  92. - [:key=, :cert=, :cert_store=, :verify_mode=].each { |method| @http.stubs(method) }
  93. -
  94. - store = stub "store"
  95. - OpenSSL::X509::Store.expects(:new).returns(store)
  96. - store.stubs(:purpose=)
  97. - store.stubs(:add_file)
  98. + OpenSSL::X509::Store.expects(:new).returns(@store)
  99.  
  100. @http.expects(:ca_file=).with("/some/file")
Add Comment
Please, Sign In to add comment