digicert 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.hound.yml +3 -0
- data/.rspec +0 -1
- data/.rubocop.yml +629 -0
- data/.sample.env +4 -0
- data/.sample.pryrc +3 -0
- data/.travis.yml +5 -2
- data/LICENSE.txt +21 -0
- data/README.md +812 -9
- data/bin/console +2 -5
- data/bin/rspec +17 -0
- data/digicert.gemspec +7 -14
- data/lib/digicert.rb +40 -2
- data/lib/digicert/actions.rb +9 -0
- data/lib/digicert/actions/all.rb +27 -0
- data/lib/digicert/actions/base.rb +11 -0
- data/lib/digicert/actions/create.rb +25 -0
- data/lib/digicert/actions/fetch.rb +21 -0
- data/lib/digicert/actions/update.rb +25 -0
- data/lib/digicert/base.rb +35 -0
- data/lib/digicert/base_order.rb +39 -0
- data/lib/digicert/certificate.rb +43 -0
- data/lib/digicert/certificate_downloader.rb +137 -0
- data/lib/digicert/certificate_request.rb +19 -0
- data/lib/digicert/client_certificate/base.rb +17 -0
- data/lib/digicert/client_certificate/digital_signature_plus.rb +13 -0
- data/lib/digicert/client_certificate/email_security_plus.rb +13 -0
- data/lib/digicert/client_certificate/premium.rb +17 -0
- data/lib/digicert/config.rb +21 -0
- data/lib/digicert/configuration.rb +26 -0
- data/lib/digicert/container.rb +35 -0
- data/lib/digicert/container_template.rb +32 -0
- data/lib/digicert/csr_generator.rb +43 -0
- data/lib/digicert/debugger.rb +34 -0
- data/lib/digicert/domain.rb +59 -0
- data/lib/digicert/duplicate_certificate.rb +21 -0
- data/lib/digicert/duplicate_certificate_finder.rb +42 -0
- data/lib/digicert/email_validation.rb +35 -0
- data/lib/digicert/errors.rb +30 -0
- data/lib/digicert/errors/forbidden.rb +9 -0
- data/lib/digicert/errors/request_error.rb +37 -0
- data/lib/digicert/errors/server_error.rb +9 -0
- data/lib/digicert/errors/unauthorized.rb +9 -0
- data/lib/digicert/expiring_order.rb +21 -0
- data/lib/digicert/findable.rb +33 -0
- data/lib/digicert/order.rb +81 -0
- data/lib/digicert/order_cancellation.rb +25 -0
- data/lib/digicert/order_duplicator.rb +11 -0
- data/lib/digicert/order_manager.rb +39 -0
- data/lib/digicert/order_reissuer.rb +11 -0
- data/lib/digicert/organization.rb +43 -0
- data/lib/digicert/product.rb +14 -0
- data/lib/digicert/request.rb +123 -0
- data/lib/digicert/response.rb +30 -0
- data/lib/digicert/ssl_certificate/base.rb +9 -0
- data/lib/digicert/ssl_certificate/ssl_ev_plus.rb +13 -0
- data/lib/digicert/ssl_certificate/ssl_plus.rb +13 -0
- data/lib/digicert/ssl_certificate/ssl_wildcard.rb +13 -0
- data/lib/digicert/version.rb +23 -1
- data/spec/acceptance/certificate_download_spec.rb +68 -0
- data/spec/acceptance/duplicating_certificate_spec.rb +86 -0
- data/spec/acceptance/reissuing_certificate_spec.rb +104 -0
- data/spec/digicert/actions/all_spec.rb +26 -0
- data/spec/digicert/actions/create_spec.rb +47 -0
- data/spec/digicert/actions/fetch_spec.rb +28 -0
- data/spec/digicert/actions/update_spec.rb +39 -0
- data/spec/digicert/certificate_downloader_spec.rb +89 -0
- data/spec/digicert/certificate_request_spec.rb +49 -0
- data/spec/digicert/certificate_spec.rb +93 -0
- data/spec/digicert/client_certificate/digital_signature_plus_spec.rb +32 -0
- data/spec/digicert/client_certificate/email_security_plus_spec.rb +36 -0
- data/spec/digicert/client_certificate/premium_spec.rb +34 -0
- data/spec/digicert/config_spec.rb +39 -0
- data/spec/digicert/container_spec.rb +44 -0
- data/spec/digicert/container_template_spec.rb +32 -0
- data/spec/digicert/csr_generator_spec.rb +31 -0
- data/spec/digicert/domain_spec.rb +89 -0
- data/spec/digicert/duplicate_certificate_finder_spec.rb +27 -0
- data/spec/digicert/duplicate_certificate_spec.rb +15 -0
- data/spec/digicert/email_validation_spec.rb +26 -0
- data/spec/digicert/expiring_order_spec.rb +16 -0
- data/spec/digicert/findable_spec.rb +19 -0
- data/spec/digicert/order_cancellation_spec.rb +24 -0
- data/spec/digicert/order_duplicator_spec.rb +35 -0
- data/spec/digicert/order_reissuer_spec.rb +35 -0
- data/spec/digicert/order_spec.rb +134 -0
- data/spec/digicert/organization_spec.rb +61 -0
- data/spec/digicert/product_spec.rb +28 -0
- data/spec/digicert/request_spec.rb +47 -0
- data/spec/digicert/ssl_certificate/ssl_ev_plus_spec.rb +35 -0
- data/spec/digicert/ssl_certificate/ssl_plus_spec.rb +36 -0
- data/spec/digicert/ssl_certificate/ssl_wildcard_spec.rb +35 -0
- data/spec/fixtures/certificate.pem +79 -0
- data/spec/fixtures/certificate.zip +0 -0
- data/spec/fixtures/certificate_request.json +116 -0
- data/spec/fixtures/certificate_requests.json +59 -0
- data/spec/fixtures/certificate_revoked.json +13 -0
- data/spec/fixtures/container.json +15 -0
- data/spec/fixtures/container_created.json +3 -0
- data/spec/fixtures/container_template.json +15 -0
- data/spec/fixtures/container_templates.json +14 -0
- data/spec/fixtures/containers.json +14 -0
- data/spec/fixtures/domain.json +71 -0
- data/spec/fixtures/domain_created.json +3 -0
- data/spec/fixtures/domains.json +49 -0
- data/spec/fixtures/email_validations.json +17 -0
- data/spec/fixtures/empty.json +0 -0
- data/spec/fixtures/errors.json +6 -0
- data/spec/fixtures/expiring_orders.json +20 -0
- data/spec/fixtures/order.json +107 -0
- data/spec/fixtures/order_created.json +9 -0
- data/spec/fixtures/order_duplicated.json +8 -0
- data/spec/fixtures/order_duplications.json +57 -0
- data/spec/fixtures/order_reissued.json +8 -0
- data/spec/fixtures/orders.json +93 -0
- data/spec/fixtures/organization.json +35 -0
- data/spec/fixtures/organization_created.json +3 -0
- data/spec/fixtures/organizations.json +84 -0
- data/spec/fixtures/ping.json +3 -0
- data/spec/fixtures/product.json +71 -0
- data/spec/fixtures/products.json +100 -0
- data/spec/fixtures/rsa4096.key +51 -0
- data/spec/requests/certificate_duplication_spec.rb +41 -0
- data/spec/requests/certificate_generation_spec.rb +93 -0
- data/spec/requests/certificate_reissuing_spec.rb +38 -0
- data/spec/requests/container_management_spec.rb +36 -0
- data/spec/requests/domain_management_spec.rb +64 -0
- data/spec/requests/order_client_email_security_plus_spec.rb +38 -0
- data/spec/requests/order_management_spec.rb +24 -0
- data/spec/requests/order_ssl_ev_plus_spec.rb +57 -0
- data/spec/requests/order_ssl_wildcard_spec.rb +57 -0
- data/spec/requests/organization_management_spec.rb +22 -0
- data/spec/requests/product_management_spec.rb +24 -0
- data/spec/requests/request_management_spec.rb +24 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/fake_digicert_api.rb +324 -0
- metadata +162 -5
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "digicert/base"
|
3
|
+
|
4
|
+
RSpec.describe "Digicert::Actions::Fetch" do
|
5
|
+
describe ".fetch" do
|
6
|
+
it "fetch a specified resource" do
|
7
|
+
resource_id = 123_456_789
|
8
|
+
|
9
|
+
stub_digicert_container_fetch_api(resource_id)
|
10
|
+
resource = Digicert::TestFetchAction.fetch(resource_id)
|
11
|
+
|
12
|
+
expect(resource.id).not_to be_nil
|
13
|
+
expect(resource.name).not_to be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Digicert
|
18
|
+
class TestFetchAction < Digicert::Base
|
19
|
+
include Digicert::Actions::Fetch
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def resource_path
|
24
|
+
"container"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "digicert/base"
|
3
|
+
require "digicert/actions/update"
|
4
|
+
|
5
|
+
RSpec.describe "Digicert::Actions::Update" do
|
6
|
+
describe ".update" do
|
7
|
+
it "updates the resource attributes" do
|
8
|
+
resource_id = 123_456_789
|
9
|
+
stub_digicert_certificate_request_update_api(
|
10
|
+
resource_id, certificate_status_attributes,
|
11
|
+
)
|
12
|
+
|
13
|
+
resource = Digicert::TestUpdateAction.update(
|
14
|
+
resource_id, certificate_status_attributes,
|
15
|
+
)
|
16
|
+
|
17
|
+
expect(resource.code.to_i).to eq(204)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module Digicert
|
22
|
+
class TestUpdateAction < Digicert::Base
|
23
|
+
include Digicert::Actions::Update
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def resource_update_path
|
28
|
+
["request", resource_id, "status"].join("/")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def certificate_status_attributes
|
34
|
+
{
|
35
|
+
status: "approved",
|
36
|
+
processor_comment: "Your domain is approved",
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::CertificateDownloader do
|
4
|
+
describe ".fetch" do
|
5
|
+
it "retrives the certificate contents" do
|
6
|
+
certificate_id = 123_456_789
|
7
|
+
platform = "apache"
|
8
|
+
stub_digicert_certificate_download_by_platform(certificate_id, platform)
|
9
|
+
|
10
|
+
certificate = Digicert::CertificateDownloader.fetch(
|
11
|
+
certificate_id, platform: platform,
|
12
|
+
)
|
13
|
+
|
14
|
+
expect(certificate.code.to_i).to eq(200)
|
15
|
+
expect_certficate_to_be_a_zip_archieve(certificate)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".fetch_to_path" do
|
20
|
+
it "fetch and write that to a file" do
|
21
|
+
certificate_id = 123_456_789
|
22
|
+
allow(File).to receive(:open)
|
23
|
+
download_path = File.expand_path("../../../tmp", __FILE__)
|
24
|
+
|
25
|
+
stub_digicert_certificate_download_by_platform(certificate_id)
|
26
|
+
Digicert::CertificateDownloader.fetch_to_path(
|
27
|
+
certificate_id, path: download_path, ext: "zip",
|
28
|
+
)
|
29
|
+
|
30
|
+
download_url = [download_path, "certificate.zip"].join("/")
|
31
|
+
expect(File).to have_received(:open).with(download_url, "w")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".fetch_by_platform" do
|
36
|
+
it "retrieves a certificate by specified platform" do
|
37
|
+
platform = "apache"
|
38
|
+
certificate_id = 123_456_789
|
39
|
+
|
40
|
+
stub_digicert_certificate_download_by_platform(certificate_id, platform)
|
41
|
+
certificate = Digicert::CertificateDownloader.fetch_by_platform(
|
42
|
+
certificate_id, platform: platform,
|
43
|
+
)
|
44
|
+
|
45
|
+
expect(certificate.code.to_i).to eq(200)
|
46
|
+
expect_certficate_to_be_a_zip_archieve(certificate)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".fetch_by_format" do
|
51
|
+
it "retrives a certificate by specified format" do
|
52
|
+
format = "pem"
|
53
|
+
certificate_id = 123_456_789
|
54
|
+
|
55
|
+
stub_digicert_certificate_download_by_format(certificate_id, format)
|
56
|
+
certificate = Digicert::CertificateDownloader.fetch_by_format(
|
57
|
+
certificate_id, format: format,
|
58
|
+
)
|
59
|
+
|
60
|
+
expect(certificate.code.to_i).to eq(200)
|
61
|
+
expect_certficate_to_be_a_zip_archieve(certificate)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe ".fetch_content" do
|
66
|
+
it "retrives the certificate and extract the content to hash" do
|
67
|
+
cert_id = 123_456_789
|
68
|
+
|
69
|
+
stub_digicert_certificate_download_by_format(cert_id, "pem_all", "pem")
|
70
|
+
certificate = Digicert::CertificateDownloader.fetch_content(cert_id)
|
71
|
+
|
72
|
+
expect(certificate[:certificate]).not_to be_nil
|
73
|
+
expect(certificate[:root_certificate]).not_to be_nil
|
74
|
+
expect(certificate[:intermediate_certificate]).not_to be_nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def expect_certficate_to_be_a_zip_archieve(certificate)
|
79
|
+
# The response we get from the certificate downloader is
|
80
|
+
# a file, and it's a `.zip` to be more specific. The easiest
|
81
|
+
# way to verify if it's a .zip file or not is not check the
|
82
|
+
# file content, and if it starts with `PK` then it is more
|
83
|
+
# likely a zip archieve
|
84
|
+
#
|
85
|
+
# Source: http://filext.com/faq/look_into_files.php
|
86
|
+
#
|
87
|
+
expect(certificate.body.start_with?("PK")).to eq(true)
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::CertificateRequest do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the lists of certificate requests" do
|
6
|
+
stub_digicert_certificate_request_list_api
|
7
|
+
certificate_requests = Digicert::CertificateRequest.all
|
8
|
+
|
9
|
+
expect(certificate_requests.count).to eq(2)
|
10
|
+
expect(certificate_requests.first.id).not_to be_nil
|
11
|
+
expect(certificate_requests.first.requester.first_name).not_to be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".fetch" do
|
16
|
+
it "retrieves the specified certificate request" do
|
17
|
+
request_id = 123_456_789
|
18
|
+
|
19
|
+
stub_digicert_certificate_request_fetch_api(request_id)
|
20
|
+
certificate_request = Digicert::CertificateRequest.fetch(request_id)
|
21
|
+
|
22
|
+
expect(certificate_request.order.id).not_to be_nil
|
23
|
+
expect(certificate_request.status).to eq("pending")
|
24
|
+
expect(certificate_request.requester.first_name).not_to be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".update" do
|
29
|
+
it "updates the specified ceritfiicate request status" do
|
30
|
+
request_id = 123_456_789
|
31
|
+
stub_digicert_certificate_request_update_api(
|
32
|
+
request_id, request_status_attributes,
|
33
|
+
)
|
34
|
+
|
35
|
+
status_update = Digicert::CertificateRequest.update(
|
36
|
+
request_id, request_status_attributes,
|
37
|
+
)
|
38
|
+
|
39
|
+
expect(status_update.code).to eq("204")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def request_status_attributes
|
44
|
+
{
|
45
|
+
status: "approved",
|
46
|
+
processor_comment: "Your domain is approved",
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::Certificate do
|
4
|
+
describe ".find" do
|
5
|
+
it "creates a certificate instance" do
|
6
|
+
certificate_id = 123_456_789
|
7
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
8
|
+
|
9
|
+
expect(certificate.class).to eq(Digicert::Certificate)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#download" do
|
14
|
+
context "when format specified" do
|
15
|
+
it "fetches the certificate using the format" do
|
16
|
+
certificate_id = 123_456_789
|
17
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
18
|
+
allow(Digicert::CertificateDownloader).to receive(:fetch)
|
19
|
+
|
20
|
+
certificate.download(format: "zip")
|
21
|
+
|
22
|
+
expect(
|
23
|
+
Digicert::CertificateDownloader,
|
24
|
+
).to have_received(:fetch).with(certificate_id, format: "zip")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when platform specified" do
|
29
|
+
it "fetches the certificate using the platform" do
|
30
|
+
certificate_id = 123_456_789
|
31
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
32
|
+
allow(Digicert::CertificateDownloader).to receive(:fetch)
|
33
|
+
|
34
|
+
certificate.download(platform: "apache")
|
35
|
+
|
36
|
+
expect(
|
37
|
+
Digicert::CertificateDownloader,
|
38
|
+
).to have_received(:fetch).with(certificate_id, platform: "apache")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#download_to_path" do
|
44
|
+
it "downloads and wrtites the certificate to the path" do
|
45
|
+
certificate_id = 123_456_789
|
46
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
47
|
+
allow(File).to receive(:open)
|
48
|
+
|
49
|
+
download_to_path_attributes = {
|
50
|
+
ext: "zip",
|
51
|
+
path: File.expand_path("../../../tmp", __FILE__),
|
52
|
+
}
|
53
|
+
|
54
|
+
stub_digicert_certificate_download_by_platform(certificate_id)
|
55
|
+
certificate.download_to_path(download_to_path_attributes)
|
56
|
+
|
57
|
+
download_url =
|
58
|
+
[download_to_path_attributes[:path], "certificate.zip"].join("/")
|
59
|
+
|
60
|
+
expect(File).to have_received(:open).with(download_url, "w")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#download_content" do
|
65
|
+
it "sends fetch_content message to the downloader" do
|
66
|
+
certificate_id = 123_456_789
|
67
|
+
certificate = Digicert::Certificate.find(certificate_id)
|
68
|
+
allow(Digicert::CertificateDownloader).to receive(:fetch_content)
|
69
|
+
|
70
|
+
certificate.download_content
|
71
|
+
|
72
|
+
expect(
|
73
|
+
Digicert::CertificateDownloader,
|
74
|
+
).to have_received(:fetch_content).with(certificate_id)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#revoke" do
|
79
|
+
it "revokes an existing certificate" do
|
80
|
+
certificate_id = 123_456_789
|
81
|
+
comments = "I no longer need this cert."
|
82
|
+
stub_digicert_certificate_revoke_api(certificate_id, comments: comments)
|
83
|
+
|
84
|
+
revocation = Digicert::Certificate.revoke(
|
85
|
+
certificate_id, comments: comments,
|
86
|
+
)
|
87
|
+
|
88
|
+
expect(revocation.id).not_to be_nil
|
89
|
+
expect(revocation.type).to eq("revoke")
|
90
|
+
expect(revocation.status).to eq("pending")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::ClientCertificate::DigitalSignaturePlus do
|
4
|
+
describe ".create" do
|
5
|
+
it "creates a new order for a digital signature plus certificate" do
|
6
|
+
stub_digicert_order_create_api(
|
7
|
+
"client_digital_signature_plus", order_attributes,
|
8
|
+
)
|
9
|
+
|
10
|
+
order = Digicert::ClientCertificate::DigitalSignaturePlus.create(
|
11
|
+
order_attributes,
|
12
|
+
)
|
13
|
+
|
14
|
+
expect(order.id).not_to be_nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def order_attributes
|
19
|
+
{
|
20
|
+
certificate: {
|
21
|
+
# Required for certificate
|
22
|
+
emails: ["email@example.com", "email1@example.com"],
|
23
|
+
common_name: "Full Name",
|
24
|
+
signature_hash: "sha256",
|
25
|
+
},
|
26
|
+
organization: { id: 117483 },
|
27
|
+
validity_years: 3,
|
28
|
+
auto_renew: 10,
|
29
|
+
renewal_of_order_id: 314152,
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::ClientCertificate::EmailSecurityPlus do
|
4
|
+
describe ".create" do
|
5
|
+
it "creates a new order for a email security plus certificate" do
|
6
|
+
stub_digicert_order_create_api(
|
7
|
+
"client_email_security_plus", order_attributes,
|
8
|
+
)
|
9
|
+
|
10
|
+
order = Digicert::ClientCertificate::EmailSecurityPlus.create(
|
11
|
+
order_attributes,
|
12
|
+
)
|
13
|
+
|
14
|
+
expect(order.id).not_to be_nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def order_attributes
|
19
|
+
{
|
20
|
+
certificate: {
|
21
|
+
organization_units: ["Developer Operations"],
|
22
|
+
server_platform: { id: 45 },
|
23
|
+
profile_option: "some_ssl_profile",
|
24
|
+
|
25
|
+
# Required for certificate
|
26
|
+
emails: ["email@example.com", "email1@example.com"],
|
27
|
+
common_name: "Full Name",
|
28
|
+
signature_hash: "sha256",
|
29
|
+
},
|
30
|
+
organization: { id: 117483 },
|
31
|
+
validity_years: 3,
|
32
|
+
auto_renew: 10,
|
33
|
+
renewal_of_order_id: 314152,
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::ClientCertificate::Premium do
|
4
|
+
describe ".create" do
|
5
|
+
it "creates a new order for a client premium certificate" do
|
6
|
+
stub_digicert_order_create_api("client_premium_sha2", order_attributes)
|
7
|
+
order = Digicert::ClientCertificate::Premium.create(order_attributes)
|
8
|
+
|
9
|
+
expect(order.id).not_to be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def order_attributes
|
14
|
+
{
|
15
|
+
certificate: {
|
16
|
+
organization_units: ["Developer Operations"],
|
17
|
+
server_platform: { id: 45 },
|
18
|
+
profile_option: "some_ssl_profile",
|
19
|
+
|
20
|
+
# Required for certificate
|
21
|
+
csr: "------ [CSR HERE] ------",
|
22
|
+
emails: ["email@example.com", "email1@example.com"],
|
23
|
+
common_name: "digicert.com",
|
24
|
+
signature_hash: "sha256",
|
25
|
+
},
|
26
|
+
organization: { id: 117483 },
|
27
|
+
validity_years: 3,
|
28
|
+
custom_expiration_date: "2017-05-18",
|
29
|
+
comments: "Comments for the the approver",
|
30
|
+
disable_renewal_notifications: false,
|
31
|
+
renewal_of_order_id: 314152,
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "digicert/config"
|
3
|
+
|
4
|
+
RSpec.describe Digicert::Config do
|
5
|
+
after { restore_default_config }
|
6
|
+
|
7
|
+
describe ".configuration" do
|
8
|
+
it "returns the current configuration" do
|
9
|
+
configuration = Digicert.configuration
|
10
|
+
|
11
|
+
expect(configuration.api_host).to eq("www.digicert.com")
|
12
|
+
expect(configuration.base_path).to eq("services/v2")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".configure" do
|
17
|
+
it "allows us to set our custom configuration" do
|
18
|
+
api_host = "www.example.com"
|
19
|
+
base_path = "ping"
|
20
|
+
|
21
|
+
Digicert.configure do |config|
|
22
|
+
config.api_host = api_host
|
23
|
+
config.base_path = base_path
|
24
|
+
end
|
25
|
+
|
26
|
+
expect(Digicert.configuration.api_host).to eq(api_host)
|
27
|
+
expect(Digicert.configuration.base_path).to eq(base_path)
|
28
|
+
expect(Digicert.configuration.debug_mode?).to be_falsey
|
29
|
+
expect(
|
30
|
+
Digicert.configuration.response_klass,
|
31
|
+
).to eq(Digicert::ResponseObject)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def restore_default_config
|
36
|
+
Digicert.configuration.api_host = "www.digicert.com"
|
37
|
+
Digicert.configuration.base_path = "services/v2"
|
38
|
+
end
|
39
|
+
end
|