geocerts 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.document +5 -0
  2. data/.gitignore +6 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +71 -0
  5. data/Rakefile +70 -0
  6. data/VERSION +1 -0
  7. data/autotest/discover.rb +39 -0
  8. data/geocerts.gemspec +144 -0
  9. data/lib/geo_certs.rb +57 -0
  10. data/lib/geo_certs/agreement.rb +18 -0
  11. data/lib/geo_certs/api.rb +29 -0
  12. data/lib/geo_certs/api_object.rb +111 -0
  13. data/lib/geo_certs/certificate.rb +88 -0
  14. data/lib/geo_certs/collection.rb +12 -0
  15. data/lib/geo_certs/csr.rb +31 -0
  16. data/lib/geo_certs/email.rb +8 -0
  17. data/lib/geo_certs/endpoints/agreements.rb +23 -0
  18. data/lib/geo_certs/endpoints/certificates.rb +73 -0
  19. data/lib/geo_certs/endpoints/events.rb +56 -0
  20. data/lib/geo_certs/endpoints/orders.rb +181 -0
  21. data/lib/geo_certs/endpoints/products.rb +30 -0
  22. data/lib/geo_certs/errors.rb +30 -0
  23. data/lib/geo_certs/event.rb +67 -0
  24. data/lib/geo_certs/exceptions.rb +124 -0
  25. data/lib/geo_certs/hash_extension.rb +50 -0
  26. data/lib/geo_certs/order.rb +369 -0
  27. data/lib/geo_certs/order/administrator.rb +23 -0
  28. data/lib/geo_certs/order/contact.rb +30 -0
  29. data/lib/geo_certs/order/extended_validation_approver.rb +23 -0
  30. data/lib/geo_certs/order/organization.rb +39 -0
  31. data/lib/geo_certs/order/renewal_information.rb +31 -0
  32. data/lib/geo_certs/parsers/order_parser.rb +8 -0
  33. data/lib/geo_certs/product.rb +67 -0
  34. data/test/config/initializers/_remote_tests.rb +15 -0
  35. data/test/config/initializers/fakeweb.rb +2 -0
  36. data/test/config/initializers/geocerts.rb +13 -0
  37. data/test/config/initializers/responses.rb +3 -0
  38. data/test/config/test_credentials.example.yml +2 -0
  39. data/test/factories.rb +15 -0
  40. data/test/fixtures/responses.rb +80 -0
  41. data/test/fixtures/responses/agreement.rb +136 -0
  42. data/test/fixtures/responses/certificate.rb +227 -0
  43. data/test/fixtures/responses/event.rb +60 -0
  44. data/test/fixtures/responses/order.rb +272 -0
  45. data/test/fixtures/responses/product.rb +77 -0
  46. data/test/integrations/agreement_test.rb +40 -0
  47. data/test/integrations/api_test.rb +33 -0
  48. data/test/integrations/certificate_test.rb +195 -0
  49. data/test/integrations/event_test.rb +167 -0
  50. data/test/integrations/order_test.rb +510 -0
  51. data/test/integrations/product_test.rb +72 -0
  52. data/test/test_helper.rb +68 -0
  53. data/test/units/certificate_test.rb +21 -0
  54. data/test/units/collection_test.rb +27 -0
  55. data/test/units/csr_test.rb +27 -0
  56. data/test/units/geo_certs_test.rb +19 -0
  57. data/test/units/order/administrator_test.rb +24 -0
  58. data/test/units/order/extended_validation_approver_test.rb +24 -0
  59. data/test/units/order/organization_test.rb +0 -0
  60. data/test/units/order/renewal_information_test.rb +36 -0
  61. data/test/units/order_test.rb +59 -0
  62. data/test/units/product_test.rb +21 -0
  63. metadata +220 -0
@@ -0,0 +1,510 @@
1
+ require 'test_helper'
2
+
3
+ class GeoCerts::OrderTest < Test::Unit::TestCase
4
+
5
+ context 'Order (using the API)' do
6
+
7
+ context 'all' do
8
+
9
+ should 'return a collection of GeoCerts::Orders' do
10
+ managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
11
+ assert GeoCerts::Order.all.all? { |item| item.kind_of?(GeoCerts::Order) }
12
+ end
13
+ end
14
+
15
+ should 'return three orders' do
16
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
17
+ assert_equal(3, GeoCerts::Order.all.size)
18
+ end
19
+ end
20
+
21
+ should 'properly populate the order data' do
22
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
23
+ order = GeoCerts::Order.all.first
24
+ assert_equal(422815, order.id)
25
+ assert_equal('srv02.wavepath.com', order.domain)
26
+ assert_equal('93520', order.geotrust_order_id)
27
+ assert_equal('Complete', order.status_major)
28
+ assert_equal('Order Complete', order.status_minor)
29
+ assert_equal(1, order.years)
30
+ assert_equal(1, order.licenses)
31
+ assert_equal(DateTime.parse('2009-08-12T16:43:02-04:00'), order.created_at)
32
+ assert_equal(DateTime.parse('2009-08-12T16:45:06-04:00'), order.completed_at)
33
+ assert_equal(false, order.trial)
34
+ assert_equal(false, order.renewal)
35
+ assert_equal('', order.sans)
36
+ assert_equal('COMPLETED', order.state)
37
+ assert_equal(69.00, order.total_price)
38
+ assert_equal(false, order.pending_audit)
39
+ end
40
+ end
41
+
42
+ should 'set the end at time' do
43
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
44
+ assert_equal DateTime.parse('2009-09-03T11:56:44-04:00'), GeoCerts::Order.all.end_at
45
+ end
46
+ end
47
+
48
+ should 'set the start at time' do
49
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
50
+ assert_equal DateTime.parse('2009-08-04T11:56:44-04:00'), GeoCerts::Order.all.start_at
51
+ end
52
+ end
53
+
54
+ should 'modify the query range' do
55
+ managed_server_request :get, '/orders.xml?end_at=2009-01-02T00:00:00+00:00&start_at=2009-01-01T00:00:00+00:00', :response => Responses::Order::All do
56
+ GeoCerts::Order.all(:start_at => DateTime.parse('2009-01-01T00:00:00Z'), :end_at => DateTime.parse('2009-01-02T00:00:00Z'))
57
+ end
58
+ end
59
+
60
+ end
61
+
62
+ context 'find' do
63
+
64
+ setup do
65
+ managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
66
+ @order_id = GeoCerts::Order.all.first.id
67
+ end
68
+ end
69
+
70
+ should 'return a GeoCerts::Order' do
71
+ managed_server_request :get, "/orders/#{@order_id}.xml", :response => Responses::Order::Order do
72
+ order = GeoCerts::Order.find(@order_id)
73
+ assert_kind_of(GeoCerts::Order, order)
74
+ assert_equal(@order_id, order.id)
75
+ end
76
+ end
77
+
78
+ should 'properly populate the order data' do
79
+ exclusively_mocked_request :get, "/orders/422815.xml", :response => Responses::Order::Order do
80
+ order = GeoCerts::Order.find(422815)
81
+ assert_equal(422815, order.id)
82
+ assert_equal('srv02.wavepath.com', order.domain)
83
+ assert_equal('93520', order.geotrust_order_id)
84
+ assert_equal('Complete', order.status_major)
85
+ assert_equal('Order Complete', order.status_minor)
86
+ assert_equal(1, order.years)
87
+ assert_equal(1, order.licenses)
88
+ assert_equal(DateTime.parse('2009-08-12T16:43:02-04:00'), order.created_at)
89
+ assert_equal(DateTime.parse('2009-08-12T16:45:06-04:00'), order.completed_at)
90
+ assert_equal(false, order.trial)
91
+ assert_equal(false, order.renewal)
92
+ assert_equal('', order.sans)
93
+ assert_equal('COMPLETED', order.state)
94
+ assert_equal(69.00, order.total_price)
95
+ assert_equal(false, order.pending_audit)
96
+ end
97
+ end
98
+
99
+ should 'raise a ResourceNotFound error' do
100
+ managed_server_request :get, '/orders/999999999.xml', :response => Responses::InvalidOrderId do
101
+ assert_responds_with_exception(GeoCerts::ResourceNotFound, -90004) do
102
+ GeoCerts::Order.find(999999999)
103
+ end
104
+ end
105
+ end
106
+
107
+ end
108
+
109
+ context 'find_by_id' do
110
+
111
+ setup do
112
+ managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
113
+ @order_id = GeoCerts::Order.all.first.id
114
+ end
115
+ end
116
+
117
+ should 'return a GeoCerts::Order' do
118
+ managed_server_request :get, "/orders/#{@order_id}.xml", :response => Responses::Order::Order do
119
+ order = GeoCerts::Order.find_by_id(@order_id)
120
+ assert_kind_of(GeoCerts::Order, order)
121
+ assert_equal(@order_id, order.id)
122
+ end
123
+ end
124
+
125
+ should 'properly populate the order data' do
126
+ exclusively_mocked_request :get, "/orders/422815.xml", :response => Responses::Order::Order do
127
+ order = GeoCerts::Order.find_by_id(422815)
128
+ assert_equal(422815, order.id)
129
+ assert_equal('srv02.wavepath.com', order.domain)
130
+ assert_equal('93520', order.geotrust_order_id)
131
+ assert_equal('Complete', order.status_major)
132
+ assert_equal('Order Complete', order.status_minor)
133
+ assert_equal(1, order.years)
134
+ assert_equal(1, order.licenses)
135
+ assert_equal(DateTime.parse('2009-08-12T16:43:02-04:00'), order.created_at)
136
+ assert_equal(DateTime.parse('2009-08-12T16:45:06-04:00'), order.completed_at)
137
+ assert_equal(false, order.trial)
138
+ assert_equal(false, order.renewal)
139
+ assert_equal('', order.sans)
140
+ assert_equal('COMPLETED', order.state)
141
+ assert_equal(69.00, order.total_price)
142
+ assert_equal(false, order.pending_audit)
143
+ end
144
+ end
145
+
146
+ should 'raise a ResourceNotFound error' do
147
+ managed_server_request :get, '/orders/999999999.xml', :response => Responses::InvalidOrderId do
148
+ assert_responds_without_exception(GeoCerts::ResourceNotFound) do
149
+ assert_nil GeoCerts::Order.find_by_id(999999999)
150
+ end
151
+ end
152
+ end
153
+
154
+ end
155
+
156
+ context 'approvers' do
157
+
158
+ should 'return a collection of GeoCerts::Emails' do
159
+ managed_server_request :get, "/orders/approvers.xml?domain=geocerts.com", :response => Responses::Order::Approvers do
160
+ approvers = GeoCerts::Order.approvers('geocerts.com')
161
+ assert_kind_of(GeoCerts::Collection, approvers)
162
+ assert(approvers.all? { |item| item.kind_of?(GeoCerts::Email) }, approvers.collect { |item| item.class.name }.join(", "))
163
+ end
164
+ end
165
+
166
+ should 'contain expected addresses' do
167
+ managed_server_request :get, "/orders/approvers.xml?domain=geocerts.com", :response => Responses::Order::Approvers do
168
+ approvers = GeoCerts::Order.approvers('geocerts.com')
169
+ %W( blank@geocerts.com
170
+ admin@geocerts.com
171
+ administrator@geocerts.com
172
+ hostmaster@geocerts.com
173
+ root@geocerts.com
174
+ ssladmin@geocerts.com
175
+ sysadmin@geocerts.com
176
+ webmaster@geocerts.com
177
+ info@geocerts.com
178
+ is@geocerts.com
179
+ it@geocerts.com
180
+ mis@geocerts.com
181
+ ssladministrator@geocerts.com
182
+ sslwebmaster@geocerts.com
183
+ postmaster@geocerts.com ).each do |address|
184
+ assert(approvers.any? { |email| email.address == address }, "#{address} was not returned")
185
+ end
186
+ end
187
+ end
188
+
189
+ end
190
+
191
+ context 'modify!' do
192
+
193
+ should 'raise an error with an invalid state given' do
194
+ managed_server_request :get, '/orders.xml', :response => Responses::Order::All do
195
+ order = GeoCerts::Order.all.first
196
+ managed_server_request :put, "/orders/#{order.id}/modify.xml?order[state]=BAD", :response => Responses::Order::BadModifyResponse do
197
+ assert_responds_with_exception(GeoCerts::UnprocessableEntity, -90003) do
198
+ order.modify!('BAD')
199
+ end
200
+ end
201
+ end
202
+ end
203
+
204
+ should 'raise an error when modifying an order which cannot be modified' do
205
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
206
+ order = GeoCerts::Order.all.first
207
+ exclusively_mocked_request :put, "/orders/#{order.id}/modify.xml?order[state]=CANCEL", :response => Responses::Order::WrongState do
208
+ assert_responds_with_exception(GeoCerts::UnprocessableEntity, -90002) do
209
+ order.modify!('CANCEL')
210
+ end
211
+ end
212
+ end
213
+ end
214
+
215
+ should 'return a GeoCerts::Order when successful' do
216
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
217
+ order = GeoCerts::Order.all.first
218
+ exclusively_mocked_request :put, "/orders/#{order.id}/modify.xml?order[state]=CANCEL", :response => Responses::Order::Order do
219
+ order.modify!('CANCEL')
220
+ end
221
+ end
222
+ end
223
+
224
+ end
225
+
226
+ context 'resend_approval_email!' do
227
+
228
+ should 'respond with a GeoCerts::Order' do
229
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
230
+ order = GeoCerts::Order.all.first
231
+ exclusively_mocked_request :post, "/orders/#{order.id}/resend.xml", :response => Responses::Order::Order do
232
+ order.resend_approval_email!
233
+ end
234
+ end
235
+ end
236
+
237
+ should 'fail with errors' do
238
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
239
+ order = GeoCerts::Order.all.first
240
+ exclusively_mocked_request :post, "/orders/#{order.id}/resend.xml", :response => Responses::GenericFailure do
241
+ assert_responds_with_exception(GeoCerts::UnprocessableEntity, -12345) do
242
+ order.resend_approval_email!
243
+ end
244
+ end
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ context 'change_approver_email!' do
251
+
252
+ should 'respond with a GeoCerts::Order' do
253
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
254
+ order = GeoCerts::Order.all.first
255
+ exclusively_mocked_request :put, "/orders/#{order.id}/email.xml?order[approver_email]=admin@example.com", :response => Responses::Order::Order do
256
+ order.change_approver_email!('admin@example.com')
257
+ end
258
+ end
259
+ end
260
+
261
+ should 'fail with errors' do
262
+ exclusively_mocked_request :get, '/orders.xml', :response => Responses::Order::All do
263
+ order = GeoCerts::Order.all.first
264
+ exclusively_mocked_request :put, "/orders/#{order.id}/email.xml?order[approver_email]=admin@example.com", :response => Responses::GenericFailure do
265
+ assert_responds_with_exception(GeoCerts::UnprocessableEntity, -12345) do
266
+ order.change_approver_email!('admin@example.com')
267
+ end
268
+ end
269
+ end
270
+ end
271
+
272
+ end
273
+
274
+ context 'create' do
275
+
276
+ should 'return a GeoCerts::Order on success' do
277
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::Order do
278
+ order = GeoCerts::Order.create(Factory.attributes_for(:order))
279
+ assert_kind_of GeoCerts::Order, order
280
+ end
281
+ end
282
+
283
+ should 'return a GeoCerts::Order on failure' do
284
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
285
+ order = GeoCerts::Order.create(Factory.attributes_for(:order))
286
+ assert_kind_of(GeoCerts::Order, order)
287
+ end
288
+ end
289
+
290
+ should 'be a new_record? on failure' do
291
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
292
+ order = GeoCerts::Order.create(Factory.attributes_for(:order))
293
+ assert order.new_record?
294
+ end
295
+ end
296
+
297
+ should 'populate errors on failure' do
298
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
299
+ order = GeoCerts::Order.create(Factory.attributes_for(:order))
300
+ assert !order.errors.empty?
301
+ end
302
+ end
303
+
304
+ should 'return a GeoCerts::Order with warnings' do
305
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::OrderWithWarnings do
306
+ order = GeoCerts::Order.create(Factory.attributes_for(:order))
307
+ assert_not_nil(order.warnings)
308
+ assert !order.warnings.empty?
309
+ assert order.warnings.all? { |warning| warning.kind_of?(GeoCerts::Warning) }
310
+ end
311
+ end
312
+
313
+ end
314
+
315
+ context 'create!' do
316
+
317
+ should 'return a GeoCerts::Order on success' do
318
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::Order do
319
+ order = GeoCerts::Order.create!(Factory.attributes_for(:order))
320
+ assert_kind_of GeoCerts::Order, order
321
+ end
322
+ end
323
+
324
+ should 'raise GeoCerts::ResourceNotCreated on failure' do
325
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
326
+ assert_responds_with_exception(GeoCerts::ResourceNotCreated) do
327
+ GeoCerts::Order.create!(Factory.attributes_for(:order))
328
+ end
329
+ end
330
+ end
331
+
332
+ end
333
+
334
+ # Instance methods...
335
+
336
+ context 'save' do
337
+
338
+ should 'return a GeoCerts::Order on success' do
339
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::Order do
340
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
341
+ assert_kind_of GeoCerts::Order, order.save
342
+ end
343
+ end
344
+
345
+ should 'return false on failure' do
346
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
347
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
348
+ assert_equal(false, order.save)
349
+ end
350
+ end
351
+
352
+ should 'be a new_record? on failure' do
353
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
354
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
355
+ order.save
356
+ assert order.new_record?
357
+ end
358
+ end
359
+
360
+ should 'populate errors on failure' do
361
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
362
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
363
+ order.save
364
+ assert_not_nil(order.errors)
365
+ assert(!order.errors.empty?)
366
+ end
367
+ end
368
+
369
+ should 'return a GeoCerts::Order with warnings' do
370
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::OrderWithWarnings do
371
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
372
+ order.save
373
+ assert_not_nil(order.warnings)
374
+ assert !order.warnings.empty?
375
+ assert order.warnings.all? { |warning| warning.kind_of?(GeoCerts::Warning) }
376
+ end
377
+ end
378
+
379
+ should 'not raise errors with a full organization given' do
380
+ exclusively_mocked_request :post, %r{https://.*api-test.geocerts.com/1/orders.xml.*}i, :response => Responses::Order::Order do
381
+ order = GeoCerts::Order.new({:organization => {:address => '123 SSL Ave.', :address_2 => 'Suite D', :address_3 => 'tesat', :city => 'Atlanta', :country => 'US', :name => 'Microsoft Inc', :phone => '800-555-1212', :postal_code => '12345', :state => 'Georgia'}}.reverse_merge(Factory.attributes_for(:order)))
382
+ assert_nothing_raised(Exception) { order.save }
383
+ end
384
+ end
385
+
386
+ end
387
+
388
+ context 'save!' do
389
+
390
+ should 'return a GeoCerts::Order on success' do
391
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::Order do
392
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
393
+ assert_kind_of GeoCerts::Order, order.save!
394
+ end
395
+ end
396
+
397
+ should 'raise a GeoCerts::ResourceNotCreated on failure' do
398
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::GenericFailure do
399
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
400
+ assert_responds_with_exception(GeoCerts::ResourceNotCreated) do
401
+ order.save!
402
+ end
403
+ end
404
+ end
405
+
406
+ should 'return a GeoCerts::Order with warnings' do
407
+ exclusively_mocked_request :post, '/orders.xml', :response => Responses::Order::OrderWithWarnings do
408
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
409
+ order.save!
410
+ assert_not_nil(order.warnings)
411
+ assert !order.warnings.empty?
412
+ assert order.warnings.all? { |warning| warning.kind_of?(GeoCerts::Warning) }
413
+ end
414
+ end
415
+
416
+ end
417
+
418
+ context 'validate' do
419
+
420
+ should 'return a GeoCerts::Order on success' do
421
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::Order::Validation do
422
+ order = GeoCerts::Order.new(Factory.attributes_for(:order))
423
+ assert_kind_of GeoCerts::Order, order.validate
424
+ end
425
+ end
426
+
427
+ should 'contain properly decoded CSR information' do
428
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::Order::Validation do
429
+ order = GeoCerts::Order.new.validate
430
+ assert_equal('www.example.com', order.csr.common_name)
431
+ assert_equal('Atlanta', order.csr.city)
432
+ assert_equal('GA', order.csr.state)
433
+ assert_equal('US', order.csr.country)
434
+ assert_equal('GeoCerts Inc', order.csr.organization)
435
+ assert_equal('Internet', order.csr.organizational_unit)
436
+ end
437
+ end
438
+
439
+ should 'contain renewal information' do
440
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::Order::Validation do
441
+ order = GeoCerts::Order.new.validate
442
+ assert_equal(true, order.renewal_information.indicator)
443
+ assert_equal(1, order.renewal_information.months)
444
+ assert_equal('abC12De', order.renewal_information.serial_number)
445
+ assert_equal('1234ab', order.renewal_information.order_id)
446
+ assert_equal(DateTime.parse('2009-01-01T00:00:00Z'), order.renewal_information.expires_at)
447
+ end
448
+ end
449
+
450
+ should 'return false on failure' do
451
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::GenericFailure do
452
+ order = GeoCerts::Order.new
453
+ assert_equal(false, order.validate)
454
+ end
455
+ end
456
+
457
+ should 'populate the order with errors on failure' do
458
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::GenericFailure do
459
+ order = GeoCerts::Order.new
460
+ order.validate
461
+ assert !order.errors.empty?
462
+ end
463
+ end
464
+
465
+ end
466
+
467
+ context 'validate!' do
468
+
469
+ should 'return a GeoCerts::Order on success' do
470
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::Order::Validation do
471
+ assert_kind_of GeoCerts::Order, GeoCerts::Order.validate!
472
+ end
473
+ end
474
+
475
+ should 'contain properly decoded CSR information' do
476
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::Order::Validation do
477
+ order = GeoCerts::Order.validate!
478
+ assert_equal('www.example.com', order.csr.common_name)
479
+ assert_equal('Atlanta', order.csr.city)
480
+ assert_equal('GA', order.csr.state)
481
+ assert_equal('US', order.csr.country)
482
+ assert_equal('GeoCerts Inc', order.csr.organization)
483
+ assert_equal('Internet', order.csr.organizational_unit)
484
+ end
485
+ end
486
+
487
+ should 'contain renewal information' do
488
+ exclusively_mocked_request :post, '/orders/validate.xml', :response => Responses::Order::Validation do
489
+ order = GeoCerts::Order.validate!
490
+ assert_equal(true, order.renewal_information.indicator)
491
+ assert_equal(1, order.renewal_information.months)
492
+ assert_equal('abC12De', order.renewal_information.serial_number)
493
+ assert_equal('1234ab', order.renewal_information.order_id)
494
+ assert_equal(DateTime.parse('2009-01-01T00:00:00Z'), order.renewal_information.expires_at)
495
+ end
496
+ end
497
+
498
+ should 'raise ResourceInvalid on failure' do
499
+ managed_server_request :post, '/orders/validate.xml', :response => Responses::GenericFailure do
500
+ assert_responds_with_exception(GeoCerts::ResourceInvalid, -12345) do
501
+ GeoCerts::Order.validate!
502
+ end
503
+ end
504
+ end
505
+
506
+ end
507
+
508
+ end
509
+
510
+ end