test/integrations/certificate_test.rb in geocerts-0.0.25 vs test/integrations/certificate_test.rb in geocerts-1.0.0
- old
+ new
@@ -1,83 +1,164 @@
require 'test_helper'
class GeoCerts::CertificateTest < Test::Unit::TestCase
-
+
context 'Certificate (using the API)' do
-
+
context 'all' do
-
- should 'return a collection of GeoCerts::Certificates' do
- managed_server_request :get, '/certificates.xml', :response => Responses::Certificate::All do
- assert GeoCerts::Certificate.all.all? { |item| item.kind_of?(GeoCerts::Certificate) }
+ subject do
+ @_subject ||= VCR.use_cassette('certificates') do
+ GeoCerts::Certificate.all
end
end
-
- should 'return two certificates' do
- exclusively_mocked_request :get, '/certificates.xml', :response => Responses::Certificate::All do
- assert_equal(2, GeoCerts::Certificate.all.size)
- end
+
+ should 'return a collection of GeoCerts::Certificates' do
+ assert subject.all? { |item| item.kind_of?(GeoCerts::Certificate) }
end
-
+
+ should 'return a certificate' do
+ assert_equal 1, subject.size
+ end
+
should 'properly populate the certificate data' do
- exclusively_mocked_request :get, '/certificates.xml', :response => Responses::Certificate::All do
- certificate = GeoCerts::Certificate.all.first
- assert_equal('422815', certificate.order_id)
- assert_equal('93520', certificate.geotrust_order_id)
- assert_equal('Renewed', certificate.status)
- assert_equal('www.example.com', certificate.common_name)
- assert_equal('1E08', certificate.serial_number)
- assert_equal('Atlanta', certificate.city)
- assert_equal('Georgia', certificate.state)
- assert_equal('US', certificate.country)
- assert_equal('GeoCerts', certificate.organization)
- assert_equal('Internet', certificate.organizational_unit)
- assert_equal(DateTime.parse('2009-08-11T19:28:18-04:00'), certificate.start_at)
- assert_equal(DateTime.parse('2009-08-20T00:59:16-04:00'), certificate.end_at)
- assert_match(%r{/orders/422815/certificate\.xml$}, certificate.url)
- assert_equal("-----BEGIN CERTIFICATE-----\nMIIDATCCAmqgAwIBAgICHwkwDQYJKoZIhvcNAQEEBQAwSzELMAkGA1UEBhMCVVMx\nFTATBgNVBAoTDEdlb1RydXN0IEluYzElMCMGA1UEAxMcR2VvVHJ1c3QgUHJlLV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ca_root)
- assert !certificate.trial?
- end
+ certificate = subject.first
+ assert_equal('R6FQJ89F', certificate.order_id)
+ assert_equal('173141', certificate.geotrust_order_id)
+ assert_equal('Active', certificate.status)
+ assert_equal('envylabs.com', certificate.common_name)
+ assert_equal('5A43', certificate.serial_number)
+ assert_equal('', certificate.city)
+ assert_equal('', certificate.state)
+ assert_equal('US', certificate.country)
+ assert_equal('envylabs.com', certificate.organization)
+ assert_equal('Domain Control Validated - GeoTrust(R) SSL Trial', certificate.organizational_unit)
+ assert_equal(DateTime.parse('2011-01-11T07:06:37+00:00'), certificate.start_at)
+ assert_equal(DateTime.parse('2011-01-20T15:23:06+00:00'), certificate.end_at)
+ assert_match(%r{/orders/432866/certificate\.xml$}, certificate.url)
+ assert_equal(<<-_certificate_, certificate.certificate)
+-----BEGIN CERTIFICATE-----
+MIIEYDCCA0igAwIBAgICWkMwDQYJKoZIhvcNAQEFBQAwTzELMAkGA1UEBhMCVVMx
+FTATBgNVBAoTDEdlb1RydXN0IEluYzEpMCcGA1UEAxMgR2VvVHJ1c3QgUHJlLVBy
+b2R1Y3Rpb24gU1VCIENBIDMwHhcNMTEwMTExMDcwNjM3WhcNMTEwMTIwMTUyMzA2
+WjCBtDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDGVudnlsYWJzLmNvbTETMBEGA1UE
+CxMKR1Q4Nzg5NDQwNDEnMCUGA1UECxMed3d3Lmdlb3RydXN0LmNvbS9yZXNvdXJj
+ZXMvY3BzMTkwNwYDVQQLEzBEb21haW4gQ29udHJvbCBWYWxpZGF0ZWQgLSBHZW9U
+cnVzdChSKSBTU0wgVHJpYWwxFTATBgNVBAMTDGVudnlsYWJzLmNvbTCCASIwDQYJ
+KoZIhvcNAQEBBQADggEPADCCAQoCggEBALlhCULQ4sdyrB48Fz7+FZ8c7IYJAXpJ
+U/bnsTeRvf2je5xD9ZOpQbLAlprXaDWWd28LJOenQ7zxPGNGhcsdSnZ/zZautNVh
+9hgTmqfOCqZO6UV3atmrR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5j
+b20vY3Jscy9ndGdsb2JhbC5jcmwwNAYIKwYBBQUHAQEEKDAmMCQGCCsGAQUFBzAB
+hhhodHRwOi8vb2NzcC5nZW90cnVzdC5jb20wDQYJKoZIhvcNAQEFBQADggEBADOR
+NxHbQPnejLICiHevYyHBrbAN+qB4VqOC/btJXxRtyNxflNoRZnwekcW22G1PqvK/
+ISh+UqKSeAhhaSH+LeyCGIT0043FiruKzF3mo7bMbq1vsw5h7onOEzRPSVX1ObuZ
+lvD16lo8nBa9AlPwKg5BbuvvnvdwNs2AKnbIh+PrI7OWLOYdlF8cpOLNJDErBjgy
+YWE5XIlMSB1CyWee0r9Y9/k3MbBn3Y0mNhp4GgkZPJMHcCrhfCn13mZXCxJeFu1e
+vTezMGnGkqX2Gdgd+DYSuUuVlZzQzmwwpxb79k1ktl8qFJymyFWOIPllByTMOAVM
+IIi0tWeUz12OYjf+xLQ=
+-----END CERTIFICATE-----
+_certificate_
+
+ assert certificate.trial?
end
-
+
should 'set the end at time' do
- exclusively_mocked_request :get, '/certificates.xml', :response => Responses::Certificate::All do
- assert_equal DateTime.parse('2009-09-08T12:57:10-04:00'), GeoCerts::Certificate.all.end_at
- end
+ assert_equal DateTime.parse('2011-01-12T19:53:05+00:00'),
+ subject.end_at
end
-
+
should 'set the start at time' do
- exclusively_mocked_request :get, '/certificates.xml', :response => Responses::Certificate::All do
- assert_equal DateTime.parse('2009-08-09T12:57:10-04:00'), GeoCerts::Certificate.all.start_at
- end
+ assert_equal DateTime.parse('2010-12-12T19:53:05+00:00'),
+ subject.start_at
end
-
- should 'modify the queried window of time' do
- managed_server_request :get, '/certificates.xml?start_at=2009-01-01T00:00:00+00:00&end_at=2009-01-02T00:00:00+00:00', :response => Responses::Certificate::All do
- GeoCerts::Certificate.all(:start_at => DateTime.parse('2009-01-01T00:00:00Z'), :end_at => DateTime.parse('2009-01-02T00:00:00Z'))
+
+ should_eventually 'modify the queried window of time' do
+ VCR.use_cassette('certificates_query_window') do
+ result = GeoCerts::Certificate.all({
+ :start_at => DateTime.parse('2009-01-01T00:00:00Z'),
+ :end_at => DateTime.parse('2009-01-02T00:00:00Z')
+ })
+ assert_equal DateTime.parse('2009-01-01T00:00:00Z'),
+ subject.start_at.to_s
+ assert_equal DateTime.parse('2009-01-02T00:00:00Z'),
+ subject.end_at.to_s
end
end
-
+
end
-
+
context 'find' do
-
+
setup do
managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
@order_id = GeoCerts::Order.all.first.id
end
end
-
+
should 'return a GeoCerts::Certificate' do
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
certificate = GeoCerts::Certificate.find(@order_id)
assert_kind_of(GeoCerts::Certificate, certificate)
assert_equal(@order_id, certificate.order_id)
end
end
-
+
should 'properly populate the certificate data' do
exclusively_mocked_request :get, '/orders/422815/certificate.xml', :response => Responses::Certificate::Certificate do
certificate = GeoCerts::Certificate.find(422815)
assert_equal('422815', certificate.order_id)
assert_equal('93520', certificate.geotrust_order_id)
@@ -95,37 +176,37 @@
assert_equal("-----BEGIN CERTIFICATE-----\nMIIDATCCAmqgAwIBAgICHwkwDQYJKoZIhvcNAQEEBQAwSzELMAkGA1UEBhMCVVMx\nFTATBgNVBAoTDEdlb1RydXN0IEluYzElMCMGA1UEAxMcR2VvVHJ1c3QgUHJlLVBy\nb2R1Y3Rpb24gQ0EgMTAeFw0wOTA4MTEyMzI4MThaFw0wOTA4MjAwNDU5MTZaMIHI\nMQswCQYDVQQGEwJVUzEbMBkGA1UEChMSc3J2MDIud2F2ZXBhdGguY29tMRMwEQYD\nVQQLEwpHVDAzMTIzMjc1MTEwLwYDVQQLEyhTZWUgd3d3Lmdlb3RydXN0LmNvbS9y\nZXNvdXJjZXMvY3BzIChjKTA5MTcwNQYDVQQLEy5Eb21haW4gQ29udHJvbCBWYWxp\nZGF0ZWQgLSBRdWlja1NTTCBQcmVtaXVtKFIpMRswGQYDVQQDExJzcnYwMi53YXZl\ncGF0aC5jb20wgZ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fBbPLZ4C/QgKO/t0BCezhABRP/PvwDN1Dulsr4R+A\ncJkVV5MW8Q+XarfCaCMczE1ZMKxRHjuvK9buY0V7xdlfUNLjUA86iOe/FP3gx7kC\nAwEAAaOCAQkwggEFMHAGA1UdHwRpMGcwZaBjoGGkXzBdMQswCQYDVQQGEwJVUzEQ\nMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm\naWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw\nODIyMTY0MTUxWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAUSOZo+SvSspXXR9gj\nIBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF\nMAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA\nMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm\naWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw\n1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4\n-----END CERTIFICATE-----", certificate.ca_root)
assert !certificate.trial?
end
end
-
+
should 'raise a ResourceNotFound error' do
managed_server_request :get, '/orders/999999999/certificate.xml', :response => Responses::InvalidOrderId do
assert_responds_with_exception(GeoCerts::ResourceNotFound, -90004) do
GeoCerts::Certificate.find(999999999)
end
end
end
-
+
end
-
+
context 'find_by_order_id' do
-
+
setup do
managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
@order_id = GeoCerts::Order.all.first.id
end
end
-
+
should 'return a GeoCerts::Certificate' do
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
certificate = GeoCerts::Certificate.find_by_order_id(@order_id)
assert_kind_of(GeoCerts::Certificate, certificate)
assert_equal(@order_id, certificate.order_id)
end
end
-
+
should 'properly populate the certificate data' do
exclusively_mocked_request :get, '/orders/422815/certificate.xml', :response => Responses::Certificate::Certificate do
certificate = GeoCerts::Certificate.find_by_order_id(422815)
assert_equal('422815', certificate.order_id)
assert_equal('93520', certificate.geotrust_order_id)
@@ -143,47 +224,47 @@
assert_equal("-----BEGIN CERTIFICATE-----\nMIIDATCCAmqgAwIBAgICHwkwDQYJKoZIhvcNAQEEBQAwSzELMAkGA1UEBhMCVVMx\nFTATBgNVBAoTDEdlb1RydXN0IEluYzElMCMGA1UEAxMcR2VvVHJ1c3QgUHJlLVBy\nb2R1Y3Rpb24gQ0EgMTAeFw0wOTA4MTEyMzI4MThaFw0wOTA4MjAwNDU5MTZaMIHI\nMQswCQYDVQQGEwJVUzEbMBkGA1UEChMSc3J2MDIud2F2ZXBhdGguY29tMRMwEQYD\nVQQLEwpHVDAzMTIzMjc1MTEwLwYDVQQLEyhTZWUgd3d3Lmdlb3RydXN0LmNvbS9y\nZXNvdXJjZXMvY3BzIChjKTA5MTcwNQYDVQQLEy5Eb21haW4gQ29udHJvbCBWYWxp\nZGF0ZWQgLSBRdWlja1NTTCBQcmVtaXVtKFIpMRswGQYDVQQDExJzcnYwMi53YXZl\ncGF0aC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOfnRzNL60aJdLL7\nSyJ7OFJPINg4yjLDLUJA7moeerN7QupUeJm68LHQ7juTRJ7lqkwTNK1hDRZuH7+6\nsM3ohFOjWv9D9hEWqR1tKAUBnhTJlTr8rYmvqbSNCWhUJZy53NqntiyDpg8kNOTM\nUVsY0cAn9e4vJHvh49t2AsMMAjtjAgMBAAGjdjB0MA4GA1UdDwEB/wQEAwIE8DBB\nBgNVHR8EOjA4MDagNKAyhjBodHRwOi8vdGVzdC1jcmwuZ2VvdHJ1c3QuY29tL2Ny\nbHMvcHJlcHJvZGNhMS5jcmwwHwYDVR0jBBgwFoAUSu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+SvSspXXR9gj\nIBBPM5iQn9QwHQYDVR0OBBYEFEjmaPkr0rKV10fYIyAQTzOYkJ/UMAwGA1UdEwQF\nMAMBAf8wGgYJKoZIhvZ9B0EABA0wCxsFVjMuMGMDAgbAMA0GCSqGSIb3DQEBBQUA\nMA4GA1UEChMHRXF1aWZheDEtMCsGA1UECxMkRXF1aWZheCBTZWN1cmUgQ2VydGlm\naWNhdGUgQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMBoGA1UdEAQTMBGBDzIwMTgw\n1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4\n-----END CERTIFICATE-----", certificate.ca_root)
assert !certificate.trial?
end
end
-
+
should 'not raise a ResourceNotFound error, instead returning nil' do
managed_server_request :get, '/orders/999999999/certificate.xml', :response => Responses::InvalidOrderId do
assert_responds_without_exception(GeoCerts::ResourceNotFound, -90004) do
assert_nil GeoCerts::Certificate.find_by_order_id(999999999)
end
end
end
-
+
end
-
+
context 'reissue' do
-
+
setup do
managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
@order_id = GeoCerts::Order.all.first.id
end
end
-
+
should 'return a GeoCerts::Certificate when successful' do
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
managed_server_request :post, "/orders/422815/certificate/reissue.xml?certificate[csr][body]=testbody", :response => Responses::Certificate::Certificate do
assert_kind_of(GeoCerts::Certificate, GeoCerts::Certificate.find(@order_id).reissue!(GeoCerts::CSR.new(:body => 'testbody')))
end
end
end
-
+
should 'raise an error with no CSR body provided' do
managed_server_request :get, "/orders/#{@order_id}/certificate.xml", :response => Responses::Certificate::Certificate do
managed_server_request :post, "/orders/#{@order_id}/certificate/reissue.xml?certificate[csr][body]=", :response => Responses::Certificate::MissingCSRBody do
assert_responds_with_exception(GeoCerts::UnprocessableEntity, -90010) do
GeoCerts::Certificate.find(@order_id).reissue!(GeoCerts::CSR.new(:body => nil))
end
end
end
end
-
+
end
-
+
end
-
+
end