geocerts 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ test/config/test_credentials.yml
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 GeoCerts Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ = GeoCerts
2
+
3
+ The GeoCerts library provides a Ruby interface to the GeoCerts REST API. This API allows
4
+ you to manage (lookup, create, and verify) your GeoCerts orders, events, certificates, and
5
+ more.
6
+
7
+ == Simple example
8
+
9
+ require 'geo_certs'
10
+
11
+ GeoCerts.login = 'example'
12
+ GeoCerts.api_token = 'abd123DEfg.....'
13
+
14
+ begin
15
+ GeoCerts::Order.all # => [ GeoCerts::Order, GeoCerts::Order, ... ]
16
+ GeoCerts::Order.find(12345).certificate # => GeoCerts::Certificate
17
+ GeoCerts::Product.all # => [ GeoCerts::Product, GeoCerts::Product, ... ]
18
+
19
+ product = GeoCerts::Product.find('Q')
20
+ product.user_agreement # => GeoCerts::Agreement
21
+ puts product.user_agreement.text # => "...."
22
+
23
+ # Validate the requested order details
24
+ validated_order = GeoCerts::Order.validate({
25
+ :csr => GeoCerts::CSR.new(:body => "-----BEGIN CERTIFICATE REQUEST-----\n...."),
26
+ :product => product
27
+ })
28
+ validated_order.renewal_information.indicator # => true
29
+ validated_order.renewal_information.months # => 1
30
+ validated_order.csr.common_name # => 'www.example.com'
31
+ validated_order.csr.state # => 'Georgia'
32
+ validated_order.total_price # => 99.00
33
+
34
+ # Create a new Order
35
+ order = GeoCerts::Order.new({
36
+ :csr => GeoCerts::CSR.new(:body => "-----BEGIN CERTIFICATE REQUEST-----\n...."),
37
+ :product => product,
38
+ :years => 3,
39
+ :licenses => 1
40
+ }).save
41
+
42
+ rescue GeoCerts::Exception
43
+ puts $!.to_s
44
+ end
45
+
46
+ == Exceptions
47
+
48
+ Since this library does interface with an external system, there is a much greater risk of
49
+ exceptional situations. As such, this library attempts to wrap all raised exceptions (due
50
+ to authorization, connection, or other unforeseen issues) in the GeoCerts::Exception object.
51
+ All exceptions raised from within this library should inherit from this class.
52
+
53
+ Exceptions which are raised after successful connections, due to server or request issues,
54
+ will be derived from GeoCerts::ExceptionWithResponse. This object also inherits from
55
+ GeoCerts::Exception, but contains the actual response details (including HTTP status code,
56
+ headers, and response body).
57
+
58
+ == Note on Patches/Pull Requests
59
+
60
+ * Fork the project.
61
+ * Make your feature addition or bug fix.
62
+ * Add tests for it. This is important so I don't break it in a
63
+ future version unintentionally.
64
+ * Commit, do not mess with Rakefile, version, or history.
65
+ (if you want to have your own version, that is fine but
66
+ bump version in a commit by itself so it can be easily ignored when pulled)
67
+ * Send a pull request. Bonus points for topic branches.
68
+
69
+ == Copyright
70
+
71
+ Copyright (c) 2009 {GeoCerts Inc.}[http://www.geocerts.com/]. See LICENSE for details.
@@ -0,0 +1,70 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "geocerts"
8
+ gem.summary = %Q{A Ruby library for interfacing with the GeoCerts REST API}
9
+ gem.description = %Q{A Ruby library for interfacing with the GeoCerts REST API}
10
+ gem.email = "sslsupport@geocerts.com"
11
+ gem.homepage = "http://www.geocerts.com/"
12
+ gem.authors = ["GeoCerts, Inc."]
13
+
14
+ gem.add_dependency('relax', '>=0.1.2')
15
+
16
+ gem.add_development_dependency('shoulda', '>=2.10.2')
17
+ gem.add_development_dependency('factory_girl', '>=1.2.2')
18
+ gem.add_development_dependency('mocha', '>=0.9.5')
19
+ gem.add_development_dependency('fakeweb', '>=1.2.2')
20
+
21
+ end
22
+
23
+ rescue LoadError
24
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |test|
29
+ test.libs << 'lib' << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/*_test.rb'
39
+ test.verbose = true
40
+ end
41
+ rescue LoadError
42
+ task :rcov do
43
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
44
+ end
45
+ end
46
+
47
+
48
+
49
+
50
+ task :default => :test
51
+
52
+ require 'rake/rdoctask'
53
+ Rake::RDocTask.new do |rdoc|
54
+ if File.exist?('VERSION.yml')
55
+ config = YAML.load(File.read('VERSION.yml'))
56
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
57
+ elsif File.exist?('VERSION')
58
+ version = File.read('VERSION')
59
+ else
60
+ version = ""
61
+ end
62
+
63
+ rdoc.rdoc_dir = 'rdoc'
64
+ rdoc.title = "geocerts #{version}"
65
+ rdoc.main = "README.rdoc"
66
+ rdoc.rdoc_files.include('README*')
67
+ rdoc.rdoc_files.include('LICENSE*')
68
+ rdoc.rdoc_files.include('lib/**/*.rb')
69
+ end
70
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.11
@@ -0,0 +1,39 @@
1
+ Autotest.add_hook :initialize do |at|
2
+ at.clear_mappings
3
+
4
+ %W( coverage rdoc .git .svn pkg ).each do |exception|
5
+ at.add_exception(exception)
6
+ end
7
+
8
+ at.add_mapping(%r%\Alib/geo_certs\.rb\Z%) { |filename, match|
9
+ at.files_matching %r%test/(units|integrations)/geo_certs_test\.rb\Z%
10
+ }
11
+
12
+ at.add_mapping(%r%\Alib/geo_certs/(.*)\.rb\Z%) { |filename, match|
13
+ at.files_matching %r%test/(units|integrations)/#{match[1]}_test\.rb\Z%
14
+ }
15
+
16
+ at.add_mapping(%r%\Atest/.*_test\.rb\Z%) { |filename, match|
17
+ filename
18
+ }
19
+
20
+ ##
21
+ # force a re-run of all tests for any of the following:
22
+ #
23
+ at.add_mapping(%r%\Atest/factories\.rb\Z%) { |filename, match|
24
+ at.files_matching %r%\Atest/(units|integrations)/.*_test\.rb\Z%
25
+ }
26
+
27
+ at.add_mapping(%r%\Atest/test_helper\.rb\Z%) { |filename, match|
28
+ at.files_matching %r%\Atest/(units|integrations)/.*_test\.rb\Z%
29
+ }
30
+
31
+ at.add_mapping(%r%\Atest/fixtures/.*%) { |filename, match|
32
+ at.files_matching %r%\Atest/(units|integrations)/.*_test\.rb\Z%
33
+ }
34
+
35
+ at.add_mapping(%r%\Atest/config/.*\.(yml|rb)\Z%) { |filename, match|
36
+ at.files_matching %r%\Atest/(units|integrations)/.*_test\.rb\Z%
37
+ }
38
+
39
+ end
@@ -0,0 +1,144 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{geocerts}
8
+ s.version = "0.0.11"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["GeoCerts, Inc."]
12
+ s.date = %q{2010-04-14}
13
+ s.description = %q{A Ruby library for interfacing with the GeoCerts REST API}
14
+ s.email = %q{sslsupport@geocerts.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "autotest/discover.rb",
27
+ "geocerts.gemspec",
28
+ "lib/geo_certs.rb",
29
+ "lib/geo_certs/agreement.rb",
30
+ "lib/geo_certs/api.rb",
31
+ "lib/geo_certs/api_object.rb",
32
+ "lib/geo_certs/certificate.rb",
33
+ "lib/geo_certs/collection.rb",
34
+ "lib/geo_certs/csr.rb",
35
+ "lib/geo_certs/email.rb",
36
+ "lib/geo_certs/endpoints/agreements.rb",
37
+ "lib/geo_certs/endpoints/certificates.rb",
38
+ "lib/geo_certs/endpoints/events.rb",
39
+ "lib/geo_certs/endpoints/orders.rb",
40
+ "lib/geo_certs/endpoints/products.rb",
41
+ "lib/geo_certs/errors.rb",
42
+ "lib/geo_certs/event.rb",
43
+ "lib/geo_certs/exceptions.rb",
44
+ "lib/geo_certs/hash_extension.rb",
45
+ "lib/geo_certs/order.rb",
46
+ "lib/geo_certs/order/administrator.rb",
47
+ "lib/geo_certs/order/contact.rb",
48
+ "lib/geo_certs/order/extended_validation_approver.rb",
49
+ "lib/geo_certs/order/organization.rb",
50
+ "lib/geo_certs/order/renewal_information.rb",
51
+ "lib/geo_certs/parsers/order_parser.rb",
52
+ "lib/geo_certs/product.rb",
53
+ "test/config/initializers/_remote_tests.rb",
54
+ "test/config/initializers/fakeweb.rb",
55
+ "test/config/initializers/geocerts.rb",
56
+ "test/config/initializers/responses.rb",
57
+ "test/config/test_credentials.example.yml",
58
+ "test/factories.rb",
59
+ "test/fixtures/responses.rb",
60
+ "test/fixtures/responses/agreement.rb",
61
+ "test/fixtures/responses/certificate.rb",
62
+ "test/fixtures/responses/event.rb",
63
+ "test/fixtures/responses/order.rb",
64
+ "test/fixtures/responses/product.rb",
65
+ "test/integrations/agreement_test.rb",
66
+ "test/integrations/api_test.rb",
67
+ "test/integrations/certificate_test.rb",
68
+ "test/integrations/event_test.rb",
69
+ "test/integrations/order_test.rb",
70
+ "test/integrations/product_test.rb",
71
+ "test/test_helper.rb",
72
+ "test/units/certificate_test.rb",
73
+ "test/units/collection_test.rb",
74
+ "test/units/csr_test.rb",
75
+ "test/units/geo_certs_test.rb",
76
+ "test/units/order/administrator_test.rb",
77
+ "test/units/order/extended_validation_approver_test.rb",
78
+ "test/units/order/organization_test.rb",
79
+ "test/units/order/renewal_information_test.rb",
80
+ "test/units/order_test.rb",
81
+ "test/units/product_test.rb"
82
+ ]
83
+ s.homepage = %q{http://www.geocerts.com/}
84
+ s.rdoc_options = ["--charset=UTF-8"]
85
+ s.require_paths = ["lib"]
86
+ s.rubygems_version = %q{1.3.6}
87
+ s.summary = %q{A Ruby library for interfacing with the GeoCerts REST API}
88
+ s.test_files = [
89
+ "test/config/initializers/_remote_tests.rb",
90
+ "test/config/initializers/fakeweb.rb",
91
+ "test/config/initializers/geocerts.rb",
92
+ "test/config/initializers/responses.rb",
93
+ "test/factories.rb",
94
+ "test/fixtures/responses/agreement.rb",
95
+ "test/fixtures/responses/certificate.rb",
96
+ "test/fixtures/responses/event.rb",
97
+ "test/fixtures/responses/order.rb",
98
+ "test/fixtures/responses/product.rb",
99
+ "test/fixtures/responses.rb",
100
+ "test/integrations/agreement_test.rb",
101
+ "test/integrations/api_test.rb",
102
+ "test/integrations/certificate_test.rb",
103
+ "test/integrations/event_test.rb",
104
+ "test/integrations/order_test.rb",
105
+ "test/integrations/product_test.rb",
106
+ "test/test_helper.rb",
107
+ "test/units/certificate_test.rb",
108
+ "test/units/collection_test.rb",
109
+ "test/units/csr_test.rb",
110
+ "test/units/geo_certs_test.rb",
111
+ "test/units/order/administrator_test.rb",
112
+ "test/units/order/extended_validation_approver_test.rb",
113
+ "test/units/order/organization_test.rb",
114
+ "test/units/order/renewal_information_test.rb",
115
+ "test/units/order_test.rb",
116
+ "test/units/product_test.rb"
117
+ ]
118
+
119
+ if s.respond_to? :specification_version then
120
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
121
+ s.specification_version = 3
122
+
123
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
124
+ s.add_runtime_dependency(%q<relax>, [">= 0.1.2"])
125
+ s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
126
+ s.add_development_dependency(%q<factory_girl>, [">= 1.2.2"])
127
+ s.add_development_dependency(%q<mocha>, [">= 0.9.5"])
128
+ s.add_development_dependency(%q<fakeweb>, [">= 1.2.2"])
129
+ else
130
+ s.add_dependency(%q<relax>, [">= 0.1.2"])
131
+ s.add_dependency(%q<shoulda>, [">= 2.10.2"])
132
+ s.add_dependency(%q<factory_girl>, [">= 1.2.2"])
133
+ s.add_dependency(%q<mocha>, [">= 0.9.5"])
134
+ s.add_dependency(%q<fakeweb>, [">= 1.2.2"])
135
+ end
136
+ else
137
+ s.add_dependency(%q<relax>, [">= 0.1.2"])
138
+ s.add_dependency(%q<shoulda>, [">= 2.10.2"])
139
+ s.add_dependency(%q<factory_girl>, [">= 1.2.2"])
140
+ s.add_dependency(%q<mocha>, [">= 0.9.5"])
141
+ s.add_dependency(%q<fakeweb>, [">= 1.2.2"])
142
+ end
143
+ end
144
+
@@ -0,0 +1,57 @@
1
+ require 'relax'
2
+ require 'cgi'
3
+
4
+ ##
5
+ # To properly configure the GeoCerts library, you must provide your partner ID and api token:
6
+ #
7
+ # GeoCerts.partner_id = 'ex4Mpl3'
8
+ # GeoCerts.api_token = 'abc123DEF456gHi...'
9
+ #
10
+ # After that, most interaction is performed through other objects within the library, such
11
+ # as GeoCerts::Order, GeoCerts::Certificate, GeoCerts::CSR, etc.
12
+ #
13
+ module GeoCerts
14
+
15
+ def self.api_token
16
+ @api_token
17
+ end
18
+
19
+ def self.api_token=(token)
20
+ @api_token = token
21
+ end
22
+
23
+ def self.partner_id
24
+ @partner_id
25
+ end
26
+
27
+ def self.partner_id=(partner_id)
28
+ @partner_id = partner_id
29
+ end
30
+
31
+ def self.api # :nodoc:
32
+ @api = API.new({
33
+ :version => 1
34
+ }, {
35
+ :credentials => [partner_id, api_token]
36
+ })
37
+ end
38
+
39
+ def self.escape(value) # :nodoc:
40
+ value ? CGI.escape(value.to_s) : nil
41
+ end
42
+
43
+ def self.sandbox=(value)
44
+ @sandbox = value
45
+ end
46
+
47
+ def self.sandbox?
48
+ @sandbox
49
+ end
50
+
51
+ def self.host
52
+ sandbox? ? 'sandbox.geocerts.com' : 'www.geocerts.com'
53
+ end
54
+
55
+ end
56
+
57
+ require 'geo_certs/api'
@@ -0,0 +1,18 @@
1
+ module GeoCerts
2
+
3
+ ##
4
+ # Very simple class which contains the text of a User Agreement for a particular
5
+ # GeoCerts::Product. The primary interface to this class is via
6
+ # GeoCerts::Product.user_agreement.
7
+ #
8
+ class Agreement < ApiObject
9
+
10
+ attr_accessor :text
11
+
12
+ def initialize(attributes = {})
13
+ self.text = attributes[:agreement]
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,29 @@
1
+ require 'geo_certs/exceptions'
2
+ require 'geo_certs/collection'
3
+ require 'geo_certs/email'
4
+ require 'geo_certs/csr'
5
+ require 'geo_certs/product'
6
+ require 'geo_certs/order'
7
+ require 'geo_certs/certificate'
8
+ require 'geo_certs/agreement'
9
+ require 'geo_certs/event'
10
+ require 'geo_certs/endpoints/orders'
11
+ require 'geo_certs/endpoints/certificates'
12
+ require 'geo_certs/endpoints/agreements'
13
+ require 'geo_certs/endpoints/products'
14
+ require 'geo_certs/endpoints/events'
15
+
16
+ module GeoCerts
17
+
18
+ class API < Relax::Service # :nodoc:
19
+
20
+ ENDPOINT = "https://#{GeoCerts.host}/:version"
21
+
22
+ include Endpoints::Orders
23
+ include Endpoints::Certificates
24
+ include Endpoints::Products
25
+ include Endpoints::Agreements
26
+ include Endpoints::Events
27
+ end
28
+
29
+ end