spec/server_spec.rb in r509-ocsp-responder-0.3.2 vs spec/server_spec.rb in r509-ocsp-responder-0.3.3
- old
+ new
@@ -259,11 +259,11 @@
it "returns caching headers for GET when cache_headers is true and no nonce is present" do
Dependo::Registry[:cache_headers] = true
now = Time.now
- Time.stub!(:now).and_return(now)
+ Time.stub(:now).and_return(now)
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA:773553085290984246110251380739025914079776985795").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA", "773553085290984246110251380739025914079776985795", "VALID")
get '/MFYwVDBSMFAwTjAJBgUrDgMCGgUABBT1kOLWHXbHiKP3sVPVxVziq%2FMqIwQUP8ezIf8yhMLgHnccSKJLQdhDaVkCFQCHf1HsjUAACwcp3qQL4IxclfXSww%3D%3D'
@@ -278,54 +278,54 @@
it "returns no caching headers for GET when cache_headers is false and no nonce is present" do
Dependo::Registry[:cache_headers] = false
now = Time.now
- Time.stub!(:now).and_return(now)
+ Time.stub(:now).and_return(now)
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA:773553085290984246110251380739025914079776985795").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA", "773553085290984246110251380739025914079776985795", "VALID")
get '/MFYwVDBSMFAwTjAJBgUrDgMCGgUABBT1kOLWHXbHiKP3sVPVxVziq%2FMqIwQUP8ezIf8yhMLgHnccSKJLQdhDaVkCFQCHf1HsjUAACwcp3qQL4IxclfXSww%3D%3D'
- ocsp_response = R509::OCSP::Response.parse(last_response.body)
+ R509::OCSP::Response.parse(last_response.body)
last_response.headers.size.should == 2
end
it "returns no caching headers for GET when cache_headers is true and a nonce is present" do
Dependo::Registry[:cache_headers] = true
now = Time.now
- Time.stub!(:now).and_return(now)
+ Time.stub(:now).and_return(now)
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA:872625873161273451176241581705670534707360122361").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA", "872625873161273451176241581705670534707360122361", "VALID")
get '/MHsweTBSMFAwTjAJBgUrDgMCGgUABBQ4ykaMB0SN9IGWx21tTHBRnmCnvQQUeXW7hDrLLN56Cb4xG0O8HCpNU1gCFQCY2eXAtMNzVS33fF0PHrUSjklF%2BaIjMCEwHwYJKwYBBQUHMAECBBIEEDTJniOQonxCRmmHAHCVstw%3D'
- ocsp_response = R509::OCSP::Response.parse(last_response.body)
+ R509::OCSP::Response.parse(last_response.body)
last_response.headers.size.should == 2
end
it "returns no caching headers for GET when cache_headers is false and a nonce is present" do
Dependo::Registry[:cache_headers] = false
now = Time.now
- Time.stub!(:now).and_return(now)
+ Time.stub(:now).and_return(now)
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA:872625873161273451176241581705670534707360122361").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA", "872625873161273451176241581705670534707360122361", "VALID")
get '/MHsweTBSMFAwTjAJBgUrDgMCGgUABBQ4ykaMB0SN9IGWx21tTHBRnmCnvQQUeXW7hDrLLN56Cb4xG0O8HCpNU1gCFQCY2eXAtMNzVS33fF0PHrUSjklF%2BaIjMCEwHwYJKwYBBQUHMAECBBIEEDTJniOQonxCRmmHAHCVstw%3D'
- ocsp_response = R509::OCSP::Response.parse(last_response.body)
+ R509::OCSP::Response.parse(last_response.body)
last_response.headers.size.should == 2
end
it "returns custom max_cache_age when it's set properly" do
Dependo::Registry[:cache_headers] = true
Dependo::Registry[:max_cache_age] = 600
now = Time.now
- Time.stub!(:now).and_return(now)
+ Time.stub(:now).and_return(now)
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA:773553085290984246110251380739025914079776985795").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA", "773553085290984246110251380739025914079776985795", "VALID")
get '/MFYwVDBSMFAwTjAJBgUrDgMCGgUABBT1kOLWHXbHiKP3sVPVxVziq%2FMqIwQUP8ezIf8yhMLgHnccSKJLQdhDaVkCFQCHf1HsjUAACwcp3qQL4IxclfXSww%3D%3D'
@@ -340,11 +340,11 @@
it "returns default max_cache_age if custom age is too large" do
Dependo::Registry[:cache_headers] = true
Dependo::Registry[:max_cache_age] = 950000
now = Time.now
- Time.stub!(:now).and_return(now)
+ Time.stub(:now).and_return(now)
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA:773553085290984246110251380739025914079776985795").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=R509, Ltd/CN=R509 Secondary Test CA", "773553085290984246110251380739025914079776985795", "VALID")
get '/MFYwVDBSMFAwTjAJBgUrDgMCGgUABBT1kOLWHXbHiKP3sVPVxVziq%2FMqIwQUP8ezIf8yhMLgHnccSKJLQdhDaVkCFQCHf1HsjUAACwcp3qQL4IxclfXSww%3D%3D'
@@ -375,11 +375,11 @@
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA:1051177536915098490149656742929223623669143613238").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA", "1051177536915098490149656742929223623669143613238", "VALID")
der = Base64.decode64(URI.decode("MFYwVDBSMFAwTjAJBgUrDgMCGgUABBQ4ykaMB0SN9IGWx21tTHBRnmCnvQQUeXW7hDrLLN56Cb4xG0O8HCpNU1gCFQC4IG5U4zC4RYb4VQ%2B2f0zCoFCvNg%3D%3D"))
post '/', der, "CONTENT_TYPE" => "application/ocsp-request"
- ocsp_response = R509::OCSP::Response.parse(last_response.body)
+ R509::OCSP::Response.parse(last_response.body)
last_response.content_type.should == "application/ocsp-response"
last_response.headers.size.should == 2
last_response.should be_ok
end
@@ -389,20 +389,21 @@
@redis.should_receive(:hgetall).with("cert:/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA:1051177536915098490149656742929223623669143613238").and_return({"status" => R509::Validity::VALID})
@stats.should_receive(:record).with("/C=US/ST=Illinois/L=Chicago/O=Ruby CA Project/CN=Test CA", "1051177536915098490149656742929223623669143613238", "VALID")
der = Base64.decode64(URI.decode("MFYwVDBSMFAwTjAJBgUrDgMCGgUABBQ4ykaMB0SN9IGWx21tTHBRnmCnvQQUeXW7hDrLLN56Cb4xG0O8HCpNU1gCFQC4IG5U4zC4RYb4VQ%2B2f0zCoFCvNg%3D%3D"))
post '/', der, "CONTENT_TYPE" => "application/ocsp-request"
- ocsp_response = R509::OCSP::Response.parse(last_response.body)
+ R509::OCSP::Response.parse(last_response.body)
last_response.content_type.should == "application/ocsp-response"
last_response.headers.size.should == 2
last_response.should be_ok
end
+=begin
+ # this test is disabled because it is unreliable. Signal testing this way is
+ # probably wrong.
it "should reload and print config when receiving a SIGUSR2" do
- config = double("config")
- stub_const("R509::OCSP::Responder::OCSPConfig",config)
- #R509::OCSP::Responder::OCSPConfig = double("config")
R509::OCSP::Responder::OCSPConfig.should_receive(:load_config)
R509::OCSP::Responder::OCSPConfig.should_receive(:print_config)
Process.kill :USR2, Process.pid
end
+=end
end