Permalink
Browse files

SSL test coverage.

  • Loading branch information...
1 parent 9ca2dd5 commit 371e91e86ba035ba02075f0a7be7db97e36aa1b6 @tomlea tomlea committed Mar 9, 2012
Showing with 75 additions and 13 deletions.
  1. +13 −0 test/fixtures/127.0.0.1.crt
  2. +15 −0 test/fixtures/127.0.0.1.key
  3. +36 −13 test/geminabox_test_case.rb
  4. +11 −0 test/integration/pushing_gems/ssl_test.rb
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIIB4zCCAUwCCQCYUPxlLEZT5DANBgkqhkiG9w0BAQUFADA2MQswCQYDVQQGEwJB
+VTETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEChMJMTI3LjAuMC4xMB4XDTEy
+MDMwOTAxNDcyMloXDTEzMDMwOTAxNDcyMlowNjELMAkGA1UEBhMCQVUxEzARBgNV
+BAgTClNvbWUtU3RhdGUxEjAQBgNVBAoTCTEyNy4wLjAuMTCBnzANBgkqhkiG9w0B
+AQEFAAOBjQAwgYkCgYEA2NFoF0JTpM/yiPGbLTawJK21FEYs7Q7GkQUNDxKXQLFt
+u/lh6YdbMQSKL5v+/BXZZXOOC0b6rJku0lztyIDa85aUzE6d+OlRNUwu2A0k4E9E
+bF2MNBATehYlHazXrA6E5tC6lzt/w/Cf8N1KmMK6qhJvHxsxT+Oy+lTHKFGXNr0C
+AwEAATANBgkqhkiG9w0BAQUFAAOBgQAENVdGZJj0yWRxcnCX7nEpuMbbHlIW6Cf3
+dyMWx0k5rKPSKSTxUwiGNt02hHPVqZlHGaBHJ10WsRUULDc8N5jIOxEjDh6V6irF
+WdPYkJfRABl7TKCJO4OTGJx27NJr3MyZFnjwQRvvFBXXsV5aQlbZpcuSSAFYDRtR
+rCFbh09ZDA==
+-----END CERTIFICATE-----
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQDY0WgXQlOkz/KI8ZstNrAkrbUURiztDsaRBQ0PEpdAsW27+WHp
+h1sxBIovm/78Fdllc44LRvqsmS7SXO3IgNrzlpTMTp346VE1TC7YDSTgT0RsXYw0
+EBN6FiUdrNesDoTm0LqXO3/D8J/w3UqYwrqqEm8fGzFP47L6VMcoUZc2vQIDAQAB
+AoGBAKG/XtLzNSkfxMSq0WPih3dla1ArpfpXaoTnar2S1el6M+3mdkfcJYik5V3t
+F0UCG8NWeGIrWniGcmqWzwEkN7HfBc0MDLyD3TVEpfjNkq99PBoIMOyG+rbiUWaI
+BxUjc8xARcmd8AuHgdO9mL/KSRIllIck5YllYQOntNUwT0bVAkEA9m5yZNbqPvwQ
+sqBeOMyBtwl2yTOnESZM8kNdqtXd+Ad3pPb+H8Tzq97ghqWj2o/tZUcPz+6MFErN
+6sPUmY6yjwJBAOE8mWWbrZxDuL3LarxvNuZgZsnZVxx5BMDwM9rqg4nE5LTHIg+Z
+cPJwsWu3ncGmkG14lnZwjanp/izc4kRJN/MCQFdyafWOriEboXFBpy3QpFcnbJeJ
+VMepJ7TwYtS0f8f8HmDTpOnxIebjeBlPvg1Y9Yzy4pGOvPaWdOvSAidbk9ECQD0n
+ePbPmAmvkX9mtapH//34+q+fZTmD2jiQf2PW/LPxU6+JycO2g6Yv1txKVHj5wokW
+jrPFx5D0yWBg8MZdouUCQA39VWZa0F6Bs+s/YkNrhw49CY+rB7/DDs2MFsmYV7P4
+6oHngFhYL/UaJb56RIOH5X/qKx01QCpo4ExwEOSJQ6U=
+-----END RSA PRIVATE KEY-----
@@ -6,6 +6,7 @@
require 'fileutils'
require 'tempfile'
require 'webrick'
+require 'webrick/https'
require 'logger'
require 'rack/auth/abstract/handler'
require 'rack/auth/abstract/request'
@@ -17,6 +18,14 @@ def url(url = nil)
@url ||= url || "http://localhost/"
end
+ def ssl(ssl = nil)
+ if ssl.nil?
+ @ssl
+ else
+ @ssl = ssl
+ end
+ end
+
def data(data = nil)
@data ||= data || "/tmp/geminabox-test-data"
end
@@ -95,7 +104,9 @@ def geminabox_push(gemfile)
end
def assert_can_push(gemname = :example, *args)
- assert_match /Gem .* received and indexed./, geminabox_push(gem_file(gemname, *args))
+ assert_match( /Gem .* received and indexed./, geminabox_push(gem_file(gemname, *args)))
+ end
+
def self.fixture(path)
File.join(File.expand_path("../fixtures", __FILE__), path)
end
@@ -110,20 +121,32 @@ def start_app!
FileUtils.rm_rf("/tmp/geminabox-test-data")
FileUtils.mkdir("/tmp/geminabox-test-data")
+ server_options = {
+ :app => config.to_app,
+ :Port => @test_server_port,
+ :AccessLog => [],
+ :Logger => WEBrick::Log::new("/dev/null", 7)
+ }
+
+ if config.ssl
+ server_options.merge!(
+ :SSLEnable => true,
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
+ :SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read(fixture("127.0.0.1.key"))),
+ :SSLCertificate => OpenSSL::X509::Certificate.new(File.read(fixture("127.0.0.1.crt"))),
+ :SSLCertName => [["CN", "127.0.0.1"]]
+ )
+ end
+
@app_server = fork do
- Kernel.class_eval do
- alias geminabox_old_require require
- def require(*args)
- if geminabox_old_require(*args)
- p args
- end
- end
+ begin
+ Geminabox.data = config.data
+ STDERR.reopen("/dev/null")
+ STDOUT.reopen("/dev/null")
+ Rack::Server.start(server_options)
+ ensure
+ exit
end
- STDERR.reopen("/dev/null")
- STDOUT.reopen("/dev/null")
- Geminabox.data = config.data
- Rack::Server.start(:app => config.to_app, :Port => @test_server_port)
- exit
end
Timeout.timeout(10) do
@@ -0,0 +1,11 @@
+require 'test_helper'
+
+class SSLTest < Geminabox::TestCase
+ url "https://127.0.0.1/"
+ ssl true
+ should_push_gem
+ # test "s" do
+ # puts url_for("/")
+ # sleep 1000
+ # end
+end

0 comments on commit 371e91e

Please sign in to comment.