digicert 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.hound.yml +3 -0
  4. data/.rspec +0 -1
  5. data/.rubocop.yml +629 -0
  6. data/.sample.env +4 -0
  7. data/.sample.pryrc +3 -0
  8. data/.travis.yml +5 -2
  9. data/LICENSE.txt +21 -0
  10. data/README.md +812 -9
  11. data/bin/console +2 -5
  12. data/bin/rspec +17 -0
  13. data/digicert.gemspec +7 -14
  14. data/lib/digicert.rb +40 -2
  15. data/lib/digicert/actions.rb +9 -0
  16. data/lib/digicert/actions/all.rb +27 -0
  17. data/lib/digicert/actions/base.rb +11 -0
  18. data/lib/digicert/actions/create.rb +25 -0
  19. data/lib/digicert/actions/fetch.rb +21 -0
  20. data/lib/digicert/actions/update.rb +25 -0
  21. data/lib/digicert/base.rb +35 -0
  22. data/lib/digicert/base_order.rb +39 -0
  23. data/lib/digicert/certificate.rb +43 -0
  24. data/lib/digicert/certificate_downloader.rb +137 -0
  25. data/lib/digicert/certificate_request.rb +19 -0
  26. data/lib/digicert/client_certificate/base.rb +17 -0
  27. data/lib/digicert/client_certificate/digital_signature_plus.rb +13 -0
  28. data/lib/digicert/client_certificate/email_security_plus.rb +13 -0
  29. data/lib/digicert/client_certificate/premium.rb +17 -0
  30. data/lib/digicert/config.rb +21 -0
  31. data/lib/digicert/configuration.rb +26 -0
  32. data/lib/digicert/container.rb +35 -0
  33. data/lib/digicert/container_template.rb +32 -0
  34. data/lib/digicert/csr_generator.rb +43 -0
  35. data/lib/digicert/debugger.rb +34 -0
  36. data/lib/digicert/domain.rb +59 -0
  37. data/lib/digicert/duplicate_certificate.rb +21 -0
  38. data/lib/digicert/duplicate_certificate_finder.rb +42 -0
  39. data/lib/digicert/email_validation.rb +35 -0
  40. data/lib/digicert/errors.rb +30 -0
  41. data/lib/digicert/errors/forbidden.rb +9 -0
  42. data/lib/digicert/errors/request_error.rb +37 -0
  43. data/lib/digicert/errors/server_error.rb +9 -0
  44. data/lib/digicert/errors/unauthorized.rb +9 -0
  45. data/lib/digicert/expiring_order.rb +21 -0
  46. data/lib/digicert/findable.rb +33 -0
  47. data/lib/digicert/order.rb +81 -0
  48. data/lib/digicert/order_cancellation.rb +25 -0
  49. data/lib/digicert/order_duplicator.rb +11 -0
  50. data/lib/digicert/order_manager.rb +39 -0
  51. data/lib/digicert/order_reissuer.rb +11 -0
  52. data/lib/digicert/organization.rb +43 -0
  53. data/lib/digicert/product.rb +14 -0
  54. data/lib/digicert/request.rb +123 -0
  55. data/lib/digicert/response.rb +30 -0
  56. data/lib/digicert/ssl_certificate/base.rb +9 -0
  57. data/lib/digicert/ssl_certificate/ssl_ev_plus.rb +13 -0
  58. data/lib/digicert/ssl_certificate/ssl_plus.rb +13 -0
  59. data/lib/digicert/ssl_certificate/ssl_wildcard.rb +13 -0
  60. data/lib/digicert/version.rb +23 -1
  61. data/spec/acceptance/certificate_download_spec.rb +68 -0
  62. data/spec/acceptance/duplicating_certificate_spec.rb +86 -0
  63. data/spec/acceptance/reissuing_certificate_spec.rb +104 -0
  64. data/spec/digicert/actions/all_spec.rb +26 -0
  65. data/spec/digicert/actions/create_spec.rb +47 -0
  66. data/spec/digicert/actions/fetch_spec.rb +28 -0
  67. data/spec/digicert/actions/update_spec.rb +39 -0
  68. data/spec/digicert/certificate_downloader_spec.rb +89 -0
  69. data/spec/digicert/certificate_request_spec.rb +49 -0
  70. data/spec/digicert/certificate_spec.rb +93 -0
  71. data/spec/digicert/client_certificate/digital_signature_plus_spec.rb +32 -0
  72. data/spec/digicert/client_certificate/email_security_plus_spec.rb +36 -0
  73. data/spec/digicert/client_certificate/premium_spec.rb +34 -0
  74. data/spec/digicert/config_spec.rb +39 -0
  75. data/spec/digicert/container_spec.rb +44 -0
  76. data/spec/digicert/container_template_spec.rb +32 -0
  77. data/spec/digicert/csr_generator_spec.rb +31 -0
  78. data/spec/digicert/domain_spec.rb +89 -0
  79. data/spec/digicert/duplicate_certificate_finder_spec.rb +27 -0
  80. data/spec/digicert/duplicate_certificate_spec.rb +15 -0
  81. data/spec/digicert/email_validation_spec.rb +26 -0
  82. data/spec/digicert/expiring_order_spec.rb +16 -0
  83. data/spec/digicert/findable_spec.rb +19 -0
  84. data/spec/digicert/order_cancellation_spec.rb +24 -0
  85. data/spec/digicert/order_duplicator_spec.rb +35 -0
  86. data/spec/digicert/order_reissuer_spec.rb +35 -0
  87. data/spec/digicert/order_spec.rb +134 -0
  88. data/spec/digicert/organization_spec.rb +61 -0
  89. data/spec/digicert/product_spec.rb +28 -0
  90. data/spec/digicert/request_spec.rb +47 -0
  91. data/spec/digicert/ssl_certificate/ssl_ev_plus_spec.rb +35 -0
  92. data/spec/digicert/ssl_certificate/ssl_plus_spec.rb +36 -0
  93. data/spec/digicert/ssl_certificate/ssl_wildcard_spec.rb +35 -0
  94. data/spec/fixtures/certificate.pem +79 -0
  95. data/spec/fixtures/certificate.zip +0 -0
  96. data/spec/fixtures/certificate_request.json +116 -0
  97. data/spec/fixtures/certificate_requests.json +59 -0
  98. data/spec/fixtures/certificate_revoked.json +13 -0
  99. data/spec/fixtures/container.json +15 -0
  100. data/spec/fixtures/container_created.json +3 -0
  101. data/spec/fixtures/container_template.json +15 -0
  102. data/spec/fixtures/container_templates.json +14 -0
  103. data/spec/fixtures/containers.json +14 -0
  104. data/spec/fixtures/domain.json +71 -0
  105. data/spec/fixtures/domain_created.json +3 -0
  106. data/spec/fixtures/domains.json +49 -0
  107. data/spec/fixtures/email_validations.json +17 -0
  108. data/spec/fixtures/empty.json +0 -0
  109. data/spec/fixtures/errors.json +6 -0
  110. data/spec/fixtures/expiring_orders.json +20 -0
  111. data/spec/fixtures/order.json +107 -0
  112. data/spec/fixtures/order_created.json +9 -0
  113. data/spec/fixtures/order_duplicated.json +8 -0
  114. data/spec/fixtures/order_duplications.json +57 -0
  115. data/spec/fixtures/order_reissued.json +8 -0
  116. data/spec/fixtures/orders.json +93 -0
  117. data/spec/fixtures/organization.json +35 -0
  118. data/spec/fixtures/organization_created.json +3 -0
  119. data/spec/fixtures/organizations.json +84 -0
  120. data/spec/fixtures/ping.json +3 -0
  121. data/spec/fixtures/product.json +71 -0
  122. data/spec/fixtures/products.json +100 -0
  123. data/spec/fixtures/rsa4096.key +51 -0
  124. data/spec/requests/certificate_duplication_spec.rb +41 -0
  125. data/spec/requests/certificate_generation_spec.rb +93 -0
  126. data/spec/requests/certificate_reissuing_spec.rb +38 -0
  127. data/spec/requests/container_management_spec.rb +36 -0
  128. data/spec/requests/domain_management_spec.rb +64 -0
  129. data/spec/requests/order_client_email_security_plus_spec.rb +38 -0
  130. data/spec/requests/order_management_spec.rb +24 -0
  131. data/spec/requests/order_ssl_ev_plus_spec.rb +57 -0
  132. data/spec/requests/order_ssl_wildcard_spec.rb +57 -0
  133. data/spec/requests/organization_management_spec.rb +22 -0
  134. data/spec/requests/product_management_spec.rb +24 -0
  135. data/spec/requests/request_management_spec.rb +24 -0
  136. data/spec/spec_helper.rb +35 -0
  137. data/spec/support/fake_digicert_api.rb +324 -0
  138. metadata +162 -5
@@ -0,0 +1,51 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIJKgIBAAKCAgEA519E1L4i5vF3bKwrZGDYcqAn9KGJLdazcuh4Sj98Wss1Viuz
3
+ g+K+9wgcvpskre6Z2lSFK3Qb1sm58DF+Be+acqTnj/Tuc6p0AxgrvlE29/pxaMmC
4
+ huBO8wJMJz9EjCFOecFyIrC4S+VnT+Qh72r+GpvQvful+RwLsOpXEL7HQ+ADO4TW
5
+ Zf+jPz7u4foR+b6njOfu9CTBw7w7HopSST1nMUga4cPJnNRJ9ZJt+bQR0lWM74hs
6
+ dUmxWKjxJI73i1fJV9HSjwcsDU8xvTNRsDejJPpCgvF49PnjVvioYr6kEHwd+khT
7
+ ouxfXbxG7AzNH8CJJ8PdXvLGZ9qDmENX68Vt4fyAGiZQxQzeqvlffoDXIdDEAAVP
8
+ ZT34dIpnZmCKDL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dO9bLkCG/3v111QVlaIjTx+/lbMVTFWcZ7vxGta+/
40
+ bKkGqQKCAQEAzvwu3C2njkRS9R+v7TyuOavoKR7LBwCwTMdyksXqjWRtMzdoEiXT
41
+ DHwMU62QcO2ftEK5MnLUtvg+ez+QC1SooSJhV8H4mq1+wbD/YBEQycyWEDzElt81
42
+ /QaWTnIEEtQXh48WIMfJ+NiVKH4/pYdirK5xacuP/ly+34F5Rj2zVtIG8pY5qHUW
43
+ ZrK5+BnE8+P0eR0LyENeqHcERikW/swjURrPCKv2HMFjqM0muA/0Nkn5t2SvGtSF
44
+ H4uTsOBO0WAR+zzXwZtB914gdjIaH1pfouapbuG8A9NZYRTNifd9nLJCuJ2IGr5g
45
+ N6gaW0z8z6NH/frPxM/fNXr3i1PAXFG2gwKCAQEA4sDQgMNHpTkWu4MZgDU7oX86
46
+ tkdVtM8SIoBodlwyfG+bOWYebyNi3044y8VEK7Jrt+koIS4tz9rP7u2dDGfGSGTq
47
+ DwKue6Iyv2zbozL+a0Ojf5hK+nErqB9map3qVljf1RgR72WYcQORNVeYk0eyUc6x
48
+ jTzepiWrA5KjyiGIRoRtABmHiT2L//sJ/4PiZ0Rq42rlo0lylBCB8wVLqC64RR8l
49
+ /Yi8yfHggUtNnIiXzWJYAJtgn5DC5LZEcyjLmI0EUOIv66MuZmlyvl+nt6U/+Z/B
50
+ x28HsgOJm/ybHlEZ6sUzLX/T2qeLWbII05IqFs4YLMKqPUpvL9JOC2D2hI3ylA==
51
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Certificate Duplication" do
4
+ describe "duplicate an existing certificate", api_call: true do
5
+ it "duplicates an existing nonexpired certificate order" do
6
+ duplication = Digicert::OrderDuplicator.create(order_id: recent_order.id)
7
+ duplicate_certificate = Digicert::DuplicateCertificateFinder.find_by(
8
+ request_id: duplication.requests.first.id,
9
+ )
10
+
11
+ expect(
12
+ order.duplicate_certificates.map(&:id),
13
+ ).to include(duplicate_certificate.id)
14
+ end
15
+ end
16
+
17
+ # Create a order class instance
18
+ #
19
+ # This helper create an instance for the order, so we can invoke the
20
+ # order's instance method to access the duplicate certificates
21
+ #
22
+ def order
23
+ @order ||= Digicert::Order.find(recent_order.id)
24
+ end
25
+
26
+ # Recent order
27
+ #
28
+ # All of the certifacate are not duplicable, from the test we can say
29
+ # for sure that the wilcard certifacate are duplicable. This spec assume
30
+ # the last order to be a ssl wildcard, if it fails then please run the
31
+ # `order_ssl_wildcard` request specs to create one and then re-run this
32
+ # spec again.
33
+ #
34
+ def recent_order
35
+ @recent_order ||= orders.first
36
+ end
37
+
38
+ def orders
39
+ Digicert::Order.all
40
+ end
41
+ end
@@ -0,0 +1,93 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Certificate Generation" do
4
+ describe "generation process", api_call: true do
5
+ it "creates and download a certificate" do
6
+ product_name_id = "ssl_plus"
7
+
8
+ # Retrieve the product details uisng the
9
+ # name id specificed for that specific one
10
+ #
11
+ product = Digicert::Product.fetch(product_name_id)
12
+
13
+ # Reqeust a new certificate using the order creation
14
+ # interface by providing t`name_id` and required attributes
15
+ #
16
+ order_request = Digicert::Order.create(
17
+ product.name_id, order_attributes
18
+ )
19
+
20
+ # Retrieve order details using the order_request id as
21
+ # it should contains the `certifcate`, so we then can
22
+ # download the generated certificate
23
+ #
24
+ order = Digicert::Order.fetch(order_request.id)
25
+
26
+ # Digicert requires some time to issue the certificate, but it's
27
+ # pretty quick in the development environment and typilcally it
28
+ # issues within couple of seconds. Let's order status and if that
29
+ # has not been issued yet then let's wait 10 seconds in dev env.
30
+ #
31
+ # In the production use please use the `Digicert::Reqeust` incase
32
+ # you need to do anything related to the request.
33
+ #
34
+ if order.status != "issued"
35
+ sleep 10
36
+ end
37
+
38
+ # Now that we have the certicate orders detials with
39
+ # the certificate id and the order status, so let's assume
40
+ # all requiremetns are meet and let's fetch the certificate
41
+ #
42
+ certificate_id = order.certificate.id
43
+ certificate = Digicert::Certificate.find(certificate_id)
44
+ certificate_content = certificate.download
45
+
46
+ # Let's also cleanup the certifcate by requesting and approving
47
+ # the revocation for the certificate.
48
+ certifcate.revoke
49
+
50
+ # Normally zip archieves content starts with `PK` and then
51
+ # the content of the files inside the zip folder
52
+ #
53
+ # Source: http://filext.com/faq/look_into_files.php
54
+ #
55
+ expect(certificate_content.body.start_with?("PK")).to be_truthy
56
+ end
57
+ end
58
+
59
+ def common_name
60
+ "test.ribosetest.com"
61
+ end
62
+
63
+ def ribose_inc
64
+ @ribose_inc ||= organizations.first
65
+ end
66
+
67
+ def order_attributes
68
+ {
69
+ validity_years: 1,
70
+ certificate: certificate_attributes,
71
+ organization: { id: ribose_inc.id },
72
+ }
73
+ end
74
+
75
+ def certificate_attributes
76
+ {
77
+ common_name: common_name,
78
+ csr: csr_content_for_ribosetest.to_s,
79
+ signature_hash: "sha256",
80
+ server_platform: { id: 2 },
81
+ }
82
+ end
83
+
84
+ def csr_content_for_ribosetest
85
+ @csr_content ||= Digicert::CSRGenerator.generate(
86
+ common_name: common_name, organization: ribose_inc,
87
+ )
88
+ end
89
+
90
+ def organizations
91
+ Digicert::Organization.all
92
+ end
93
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Reissuing Certificate" do
4
+ describe "reissue" do
5
+ it "reissues an existing nonexpired certificate", api_call: true do
6
+
7
+ # This tests will find the last created certificate order and
8
+ # then will try to reissue that, but one important thing to note
9
+ # that digicert only allows expects active certificate to reissue
10
+ # and normally every certificate in test environment gets expired
11
+ # in 3 days.
12
+ #
13
+ # So, if this fails, then please to run the certificate generation
14
+ # test first, which will create a new order and then try this agian
15
+ # and it should work like a charm
16
+ #
17
+ reissue = Digicert::OrderReissuer.create(order_id: recent_order.id)
18
+
19
+ # Let's fetch the details for the new request and that way we can
20
+ # verify that this reissues has the proper request type and then
21
+ # we can do the further tasks on it.
22
+ #
23
+ request_id = reissue.requests.first.id
24
+ certificate_request = Digicert::CertificateRequest.fetch(request_id)
25
+
26
+ expect(reissue.id).to eq(recent_order.id)
27
+ expect(certificate_request.type).to eq("reissue")
28
+ end
29
+ end
30
+
31
+ def recent_order
32
+ @recent_order ||= orders.first
33
+ end
34
+
35
+ def orders
36
+ @orders ||= Digicert::Order.all
37
+ end
38
+ end
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Container Management" do
4
+ describe "fetching a container template", api_call: true do
5
+ it "fetches the first container template details" do
6
+ templates = Digicert::ContainerTemplate.all(container_id)
7
+ template = Digicert::ContainerTemplate.fetch(
8
+ template_id: templates.first.id, container_id: container_id,
9
+ )
10
+
11
+ expect(template.name).to eq("Business Unit")
12
+ expect(template.access_roles.first.name).to eq("Administrator")
13
+ end
14
+ end
15
+
16
+ describe "fetching a container details", api_call: true do
17
+ it "retrieves the details for a container" do
18
+ container = Digicert::Container.fetch(container_id)
19
+
20
+ expect(container.is_active).to eq(true)
21
+ expect(container.name).to eq("Ribose Inc.")
22
+ end
23
+ end
24
+
25
+ def container_id
26
+ @container_id ||= containers.first.id
27
+ end
28
+
29
+ def containers
30
+ # We are making this API call intentionally, this
31
+ # ensures the listing containers API is working as
32
+ # it should have as long as there are no errors.
33
+ #
34
+ @containers ||= Digicert::Container.all
35
+ end
36
+ end
@@ -0,0 +1,64 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Domain Management" do
4
+ describe "managing a domains", api_call: true do
5
+ it "create, activate and deactives a domain" do
6
+ # Create a new domain using the `.create` interface,
7
+ # please remember if the domain is already exists then
8
+ # it will return that domain object, but if not then it
9
+ # will create add a new domain to your organization.
10
+ #
11
+ domain = Digicert::Domain.create(domain_attributes)
12
+
13
+ # Let's play with the domain, let's try to deactivate
14
+ # first and then reactivate it.
15
+ domain = Digicert::Domain.find(domain.id)
16
+
17
+ # Deactivate the domain
18
+ domain.deactivate
19
+
20
+ # Reactivate the domain
21
+ domain.activate
22
+
23
+ # Refresh the doamin we have been dealing with, and this
24
+ # call will also ensures the `fetch` api is working as
25
+ # expcted as long as it does not fails
26
+ #
27
+ domain = domain.fetch
28
+
29
+ expect(domain.is_active).to eq(true)
30
+ expect(domain.id).to eq(domains.last.id)
31
+ expect(domain.name).to eq(ribose_test_domain)
32
+ expect(domain.organization.name).to eq("Ribose Inc.")
33
+ end
34
+ end
35
+
36
+ def ribose_test_domain
37
+ @ribose_test_domain ||= "ribose.test"
38
+ end
39
+
40
+ def domain_attributes
41
+ {
42
+ dcv: { method: "email" },
43
+ name: ribose_test_domain,
44
+ organization: { id: organization_id },
45
+ validations: [{ type: "OV", user: { id: administrator_id }}],
46
+ }
47
+ end
48
+
49
+ def domains
50
+ # Call to this method will peform an actual API call
51
+ # to list all the existing domains, so returning the
52
+ # correct response ensures the `.all` interface is ok.
53
+ #
54
+ @domains ||= Digicert::Domain.all
55
+ end
56
+
57
+ def organization_id
58
+ ENV["DIGICERT_ORGANIZATION_ID"]
59
+ end
60
+
61
+ def administrator_id
62
+ ENV["DIGICERT_ADMINISTRATOR_ID"]
63
+ end
64
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Order client email security plus" do
4
+ describe "ordering client email security plus", api_call: true do
5
+ it "creates a new order for client email security plus" do
6
+ product_name_id = "email_security_plus"
7
+
8
+ # Reqeust a new email security plus using the order creation
9
+ # interface with `product_name_id` and required attributes
10
+ #
11
+ order_request = Digicert::Order.create(
12
+ product_name_id, order_attributes,
13
+ )
14
+
15
+ puts order_request
16
+ end
17
+ end
18
+
19
+ def ribose_inc
20
+ @ribose_inc ||= Digicert::Organization.all.first
21
+ end
22
+
23
+ def order_attributes
24
+ {
25
+ validity_years: 3,
26
+ certificate: certificate_attributes,
27
+ organization: { id: ribose_inc.id },
28
+ }
29
+ end
30
+
31
+ def certificate_attributes
32
+ {
33
+ common_name: "John Doe",
34
+ signature_hash: "sha256",
35
+ emails: ["johndoe@ribosetest.com"],
36
+ }
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Order Management" do
4
+ describe "retrieving a certificate order", api_call: true do
5
+ it "retrieves the details for a specific certificate order" do
6
+ order = Digicert::Order.fetch(order_id)
7
+
8
+ expect(order.product_name_id).to eq("ssl_plus")
9
+ expect(order.certificate.common_name).to eq("ribosetest.com")
10
+ expect(order.organization.display_name).to eq("Ribose Inc.")
11
+ end
12
+ end
13
+
14
+ def order_id
15
+ @order_id ||= orders.first.id
16
+ end
17
+
18
+ def orders
19
+ # We are intentionally making this API call to ensure
20
+ # the `Order.all` interface is working as it should have.
21
+ #
22
+ @orders ||= Digicert::Order.all
23
+ end
24
+ end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Order SSl EV Plus" do
4
+ describe "ording ssl ev plus certificate", api_call: true do
5
+ it "creates a new order fro ssl ev plus certificate" do
6
+ product_name_id = "ssl_ev_plus"
7
+
8
+ # Reqeust a new certificate using the order creation
9
+ # interface by providing t`name_id` and required attributes
10
+ #
11
+ order_request = Digicert::Order.create(
12
+ product_name_id, order_attributes,
13
+ )
14
+
15
+ # Retrieve order details using the order_request id as
16
+ # it should contains the `certifcate`, so we then can
17
+ # download the generated certificate
18
+ #
19
+ order = Digicert::Order.fetch(order_request.id)
20
+
21
+ expect(order.product.name).to eq("EV SSL Plus")
22
+ expect(order.certificate.common_name).to eq(common_name)
23
+ expect(order.organization.display_name).to eq(ribose_inc.display_name)
24
+ end
25
+ end
26
+
27
+ def common_name
28
+ "ribosetest.com"
29
+ end
30
+
31
+ def order_attributes
32
+ {
33
+ validity_years: 1,
34
+ certificate: certificate_attributes,
35
+ organization: { id: ribose_inc.id },
36
+ }
37
+ end
38
+
39
+ def ribose_inc
40
+ @ribose_inc ||= Digicert::Organization.all.first
41
+ end
42
+
43
+ def certificate_attributes
44
+ {
45
+ common_name: common_name,
46
+ signature_hash: "sha256",
47
+ csr: csr_content_for_ribosetest,
48
+ server_platform: { id: 2 }
49
+ }
50
+ end
51
+
52
+ def csr_content_for_ribosetest
53
+ @csr_content ||= Digicert::CSRGenerator.generate(
54
+ common_name: common_name, organization: ribose_inc,
55
+ )
56
+ end
57
+ end