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,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::Container do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of containers" do
|
6
|
+
stub_digicert_container_list_api
|
7
|
+
containers = Digicert::Container.all
|
8
|
+
|
9
|
+
expect(containers.first.id).not_to be_nil
|
10
|
+
expect(containers.first.name).to eq("Ribose Inc.")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".create" do
|
15
|
+
it "creates a new sub container" do
|
16
|
+
stub_digicert_container_create_api(container_attributes)
|
17
|
+
container = Digicert::Container.create(container_attributes)
|
18
|
+
|
19
|
+
expect(container.id).not_to be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".fetch" do
|
24
|
+
it "retrieves the details for a container" do
|
25
|
+
container_id = 123_456_789
|
26
|
+
|
27
|
+
stub_digicert_container_fetch_api(container_id)
|
28
|
+
container = Digicert::Container.fetch(container_id)
|
29
|
+
|
30
|
+
expect(container.name).not_to be_nil
|
31
|
+
expect(container.parent_id).not_to be_nil
|
32
|
+
expect(container.allowed_domain_names.first).to eq("abc.xyz")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def container_attributes
|
37
|
+
{
|
38
|
+
container_id: 123_456_789,
|
39
|
+
name: "History Department",
|
40
|
+
template_id: 5,
|
41
|
+
description: "History, Civ, Ancient Languages",
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::ContainerTemplate do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of all container tempaltes" do
|
6
|
+
container_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_container_template_list_api(container_id)
|
9
|
+
container_templates = Digicert::ContainerTemplate.all(container_id)
|
10
|
+
|
11
|
+
expect(container_templates.count).to eq(2)
|
12
|
+
expect(container_templates.first.id).not_to be_nil
|
13
|
+
expect(container_templates.first.name).not_to be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".fetch" do
|
18
|
+
it "retrieves the specific container tempalte" do
|
19
|
+
template_id = 987_654_321
|
20
|
+
container_id = 123_456_789
|
21
|
+
stub_digicert_container_template_fetch_api(template_id, container_id)
|
22
|
+
|
23
|
+
container_template = Digicert::ContainerTemplate.fetch(
|
24
|
+
container_id: container_id, template_id: template_id,
|
25
|
+
)
|
26
|
+
|
27
|
+
expect(container_template.id).not_to be_nil
|
28
|
+
expect(container_template.name).not_to be_nil
|
29
|
+
expect(container_template.access_roles.first.name).to eq("Administrator")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::CSRGenerator do
|
4
|
+
describe ".generate" do
|
5
|
+
it "returns the generated csr content" do
|
6
|
+
csr = Digicert::CSRGenerator.generate(
|
7
|
+
rsa_key: rsa_key_content,
|
8
|
+
organization: ribose_inc,
|
9
|
+
common_name: "ribosetest.com",
|
10
|
+
)
|
11
|
+
|
12
|
+
expect(csr.start_with?("-----BEGIN CERTIFICATE REQUEST")).to be_truthy
|
13
|
+
expect(csr.end_with?("--END CERTIFICATE REQUEST-----\n")).to be_truthy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def rsa_key_content
|
18
|
+
rsa_key_path = "../../fixtures/rsa4096.key"
|
19
|
+
File.read(File.expand_path(rsa_key_path, __FILE__))
|
20
|
+
end
|
21
|
+
|
22
|
+
def ribose_inc
|
23
|
+
double(
|
24
|
+
"Digicert::Organization",
|
25
|
+
name: "Ribose Inc.",
|
26
|
+
city: "Wilmington",
|
27
|
+
state: "Delaware",
|
28
|
+
country: "us",
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::Domain do
|
4
|
+
describe ".create" do
|
5
|
+
it "creates a new domain for an organization" do
|
6
|
+
stub_digicert_domain_create_api(domain_attributes)
|
7
|
+
domain = Digicert::Domain.create(domain_attributes)
|
8
|
+
|
9
|
+
expect(domain.id).not_to be_nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".all" do
|
14
|
+
context "without any filters" do
|
15
|
+
it "retrieves the list of domains" do
|
16
|
+
stub_digicert_domain_list_api
|
17
|
+
domains = Digicert::Domain.all
|
18
|
+
|
19
|
+
expect(domains.count).to eq(2)
|
20
|
+
expect(domains.first.id).not_to be_nil
|
21
|
+
expect(domains.first.name).not_to be_nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with custom filters" do
|
26
|
+
it "retrieves the filtered list" do
|
27
|
+
filter_params = { container_id: 123 }
|
28
|
+
stub_digicert_domain_list_api(filter_params)
|
29
|
+
domains = Digicert::Domain.all(filter_params)
|
30
|
+
|
31
|
+
expect(domains.count).to eq(2)
|
32
|
+
expect(domains.first.id).not_to be_nil
|
33
|
+
expect(domains.first.name).not_to be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".fetch" do
|
39
|
+
it "retrieves the specific domain" do
|
40
|
+
domain_id = 123_456_789
|
41
|
+
filters = { include_dcv: true, include_validation: true}
|
42
|
+
|
43
|
+
stub_digicert_domain_fetch_api(domain_id, filters)
|
44
|
+
domain = Digicert::Domain.fetch(domain_id, filters)
|
45
|
+
|
46
|
+
expect(domain.id).not_to be_nil
|
47
|
+
expect(domain.dcv.name_scope).not_to be_nil
|
48
|
+
expect(domain.validations.first.type).to eq("ev")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#activate" do
|
53
|
+
it "activates a specific domain" do
|
54
|
+
domain_id = 123_456_789
|
55
|
+
domain = Digicert::Domain.find(domain_id)
|
56
|
+
|
57
|
+
stub_digicert_domain_activate_api(domain_id)
|
58
|
+
domain_activation = domain.activate
|
59
|
+
|
60
|
+
expect(domain_activation.code).to eq("204")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#deactivate" do
|
65
|
+
it "deactivates a specific domain" do
|
66
|
+
domain_id = 123_456_789
|
67
|
+
domain = Digicert::Domain.find(domain_id)
|
68
|
+
|
69
|
+
stub_digicert_domain_deactivate_api(domain_id)
|
70
|
+
domain_deactivation = domain.deactivate
|
71
|
+
|
72
|
+
expect(domain_deactivation.code).to eq("204")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def domain_attributes
|
77
|
+
{
|
78
|
+
name: "digicert.com",
|
79
|
+
organization: { id: 117483 },
|
80
|
+
validations: [
|
81
|
+
{
|
82
|
+
type: "ev",
|
83
|
+
user: { id: 12 }
|
84
|
+
},
|
85
|
+
],
|
86
|
+
dcv: { method: "email" },
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::DuplicateCertificateFinder do
|
4
|
+
describe ".find" do
|
5
|
+
it "finds the duplicate certificate" do
|
6
|
+
request_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_certificate_request_fetch_api(request_id)
|
9
|
+
stub_digicert_order_duplications_api(order_id)
|
10
|
+
|
11
|
+
certificate = Digicert::DuplicateCertificateFinder.find_by(
|
12
|
+
request_id: request_id,
|
13
|
+
)
|
14
|
+
|
15
|
+
expect(certificate.id).not_to be_nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def order_id
|
20
|
+
# Fetching an existing request returns the fixtures file we
|
21
|
+
# wrote as certificate_request.json, and that order_id is
|
22
|
+
# being used to fetched the duplications, so for this use
|
23
|
+
# case let's keep it simple and hardcode the value for now
|
24
|
+
#
|
25
|
+
@order_id ||= 542757
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::DuplicateCertificate do
|
4
|
+
describe ".all" do
|
5
|
+
it "list all duplicate certificates" do
|
6
|
+
order_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_order_duplications_api(order_id)
|
9
|
+
certificates = Digicert::DuplicateCertificate.all(order_id: order_id)
|
10
|
+
|
11
|
+
expect(certificates.first.id).not_to be_nil
|
12
|
+
expect(certificates.first.status).to eq("approved")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::EmailValidation do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves the list of email with validation status" do
|
6
|
+
order_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_email_validations_api(order_id)
|
9
|
+
email_validations = Digicert::EmailValidation.all(order_id: order_id)
|
10
|
+
|
11
|
+
expect(email_validations.first.status).to eq("validated")
|
12
|
+
expect(email_validations.first.email).to eq("email@example.com")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".valid?" do
|
17
|
+
it "validates the email through digicert" do
|
18
|
+
validation_attributes = { token: "token", email: "email@example.com" }
|
19
|
+
stub_digicert_email_validations_validate_api(validation_attributes)
|
20
|
+
|
21
|
+
expect(
|
22
|
+
Digicert::EmailValidation.valid?(validation_attributes),
|
23
|
+
).to eq(true)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::ExpiringOrder do
|
4
|
+
describe ".all" do
|
5
|
+
it "retrieves all the expiring orders" do
|
6
|
+
container_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_order_expiring_api(container_id)
|
9
|
+
expiring_orders = Digicert::ExpiringOrder.all(container_id: container_id)
|
10
|
+
|
11
|
+
expect(expiring_orders.count).to eq(4)
|
12
|
+
expect(expiring_orders.first.order_count).to eq(10)
|
13
|
+
expect(expiring_orders.first.days_expiring).to eq(90)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "digicert/base"
|
3
|
+
|
4
|
+
RSpec.describe "Digicert::TestFindable" do
|
5
|
+
describe ".find_by_object" do
|
6
|
+
it "initialize an instnace using the object" do
|
7
|
+
findable_object = double("order", id: 123_456_789)
|
8
|
+
new_object = Digicert::TestFindable.find_by_object(findable_object)
|
9
|
+
|
10
|
+
expect(new_object.class).to eq(Digicert::TestFindable)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Digicert
|
15
|
+
class TestFindable < Digicert::Base
|
16
|
+
extend Digicert::Findable
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::OrderCancellation do
|
4
|
+
describe ".create" do
|
5
|
+
it "cancels an existing order" do
|
6
|
+
order_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_order_cancellation_api(order_id, cancellation_attributes)
|
9
|
+
order_cancellation = Digicert::OrderCancellation.create(
|
10
|
+
order_id: order_id, **cancellation_attributes,
|
11
|
+
)
|
12
|
+
|
13
|
+
expect(order_cancellation.code.to_i).to eq(204)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def cancellation_attributes
|
18
|
+
{
|
19
|
+
status: "CANCELED",
|
20
|
+
send_emails: true,
|
21
|
+
note: "This is a cancellation note",
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::OrderDuplicator do
|
4
|
+
describe ".create" do
|
5
|
+
it "creates a duplicate of an existing order" do
|
6
|
+
stub_digicert_order_fetch_api(order_id)
|
7
|
+
|
8
|
+
stub_digicert_order_duplicate_api(order_id, order_attributes)
|
9
|
+
order = Digicert::OrderDuplicator.create(order_id: order_id)
|
10
|
+
|
11
|
+
expect(order.id).not_to be_nil
|
12
|
+
expect(order.requests.first.id).not_to be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def order_id
|
17
|
+
123_456_789
|
18
|
+
end
|
19
|
+
|
20
|
+
def order_attributes
|
21
|
+
{
|
22
|
+
certificate: {
|
23
|
+
common_name: order.certificate.common_name,
|
24
|
+
dns_names: order.certificate.dns_names,
|
25
|
+
csr: order.certificate.csr,
|
26
|
+
signature_hash: order.certificate.signature_hash,
|
27
|
+
server_platform: { id: order.certificate.server_platform.id },
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def order
|
33
|
+
@order ||= Digicert::Order.fetch(order_id)
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::OrderReissuer do
|
4
|
+
describe ".create" do
|
5
|
+
it "reissue an existing order" do
|
6
|
+
stub_digicert_order_fetch_api(order_id)
|
7
|
+
|
8
|
+
stub_digicert_order_reissue_api(order_id, order_attributes)
|
9
|
+
order = Digicert::OrderReissuer.create(order_id: order_id)
|
10
|
+
|
11
|
+
expect(order.id).not_to be_nil
|
12
|
+
expect(order.requests.first.id).not_to be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def order_id
|
17
|
+
123_456_789
|
18
|
+
end
|
19
|
+
|
20
|
+
def order
|
21
|
+
@order ||= Digicert::Order.fetch(order_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def order_attributes
|
25
|
+
{
|
26
|
+
certificate: {
|
27
|
+
common_name: order.certificate.common_name,
|
28
|
+
dns_names: order.certificate.dns_names,
|
29
|
+
csr: order.certificate.csr,
|
30
|
+
signature_hash: order.certificate.signature_hash,
|
31
|
+
server_platform: { id: order.certificate.server_platform.id },
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe Digicert::Order do
|
4
|
+
describe ".fetch" do
|
5
|
+
it "retrieves a specific certificate order" do
|
6
|
+
order_id = 123_456_789
|
7
|
+
|
8
|
+
stub_digicert_order_fetch_api(order_id)
|
9
|
+
order = Digicert::Order.fetch(order_id)
|
10
|
+
|
11
|
+
expect(order.id).not_to be_nil
|
12
|
+
expect(order.status).to eq("approved")
|
13
|
+
expect(order.certificate.common_name).to eq("digicert.com")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".all" do
|
18
|
+
it "retrieves the list of all certificate orders" do
|
19
|
+
stub_digicert_order_list_api
|
20
|
+
orders = Digicert::Order.all
|
21
|
+
|
22
|
+
expect(orders.first.id).not_to be_nil
|
23
|
+
expect(orders.first.status).to eq("issued")
|
24
|
+
expect(orders.first.certificate.common_name).to eq("digicert.com")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".create" do
|
29
|
+
it "sends create message to certificate klass" do
|
30
|
+
name_id = "ssl_plus"
|
31
|
+
allow(Digicert::SSLCertificate::SSLPlus).to receive(:create)
|
32
|
+
|
33
|
+
Digicert::Order.create(name_id, order_attributes)
|
34
|
+
|
35
|
+
expect(
|
36
|
+
Digicert::SSLCertificate::SSLPlus,
|
37
|
+
).to have_received(:create).with(order_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#email_validations" do
|
42
|
+
it "sends all message to EmailValidation" do
|
43
|
+
order_id = 123_456_789
|
44
|
+
order = Digicert::Order.find(order_id)
|
45
|
+
allow(Digicert::EmailValidation).to receive(:all)
|
46
|
+
|
47
|
+
order.email_validations
|
48
|
+
|
49
|
+
expect(
|
50
|
+
Digicert::EmailValidation,
|
51
|
+
).to have_received(:all).with(order_id: order_id)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#reissue" do
|
56
|
+
it "sends Reissuer a create message" do
|
57
|
+
order_id = 123_456_789
|
58
|
+
order = Digicert::Order.find(order_id)
|
59
|
+
allow(Digicert::OrderReissuer).to receive(:create)
|
60
|
+
|
61
|
+
order.reissue
|
62
|
+
|
63
|
+
expect(
|
64
|
+
Digicert::OrderReissuer
|
65
|
+
).to have_received(:create).with(order_id: order_id)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#duplicate" do
|
70
|
+
it "sends the duplicator a create message" do
|
71
|
+
order_id = 123_456_789
|
72
|
+
order = Digicert::Order.find(order_id)
|
73
|
+
allow(Digicert::OrderDuplicator).to receive(:create)
|
74
|
+
|
75
|
+
order.duplicate
|
76
|
+
|
77
|
+
expect(
|
78
|
+
Digicert::OrderDuplicator
|
79
|
+
).to have_received(:create).with(order_id: order_id)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "#duplicate_certificates" do
|
84
|
+
it "sends all message to order duplication" do
|
85
|
+
order_id = 123_456_789
|
86
|
+
order = Digicert::Order.find(order_id)
|
87
|
+
allow(Digicert::DuplicateCertificate).to receive(:all)
|
88
|
+
|
89
|
+
order.duplicate_certificates
|
90
|
+
|
91
|
+
expect(
|
92
|
+
Digicert::DuplicateCertificate
|
93
|
+
).to have_received(:all).with(order_id: order_id)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#cancel" do
|
98
|
+
it "sends the create methods to order cancellation" do
|
99
|
+
order_id = 123_456_789
|
100
|
+
note = "This is the cancellation note"
|
101
|
+
|
102
|
+
order = Digicert::Order.find(order_id)
|
103
|
+
allow(Digicert::OrderCancellation).to receive(:create)
|
104
|
+
|
105
|
+
order.cancel(note: note)
|
106
|
+
|
107
|
+
expect(
|
108
|
+
Digicert::OrderCancellation
|
109
|
+
).to have_received(:create).with(order_id: order_id, note: note)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def order_attributes
|
114
|
+
{
|
115
|
+
certificate: {
|
116
|
+
organization_units: ["Developer Operations"],
|
117
|
+
server_platform: { id: 45 },
|
118
|
+
profile_option: "some_ssl_profile",
|
119
|
+
|
120
|
+
# Required for certificate
|
121
|
+
csr: "------ [CSR HERE] ------",
|
122
|
+
common_name: "digicert.com",
|
123
|
+
signature_hash: "sha256",
|
124
|
+
},
|
125
|
+
organization: { id: 117483 },
|
126
|
+
validity_years: 3,
|
127
|
+
custom_expiration_date: "2017-05-18",
|
128
|
+
comments: "Comments for the the approver",
|
129
|
+
disable_renewal_notifications: false,
|
130
|
+
renewal_of_order_id: 314152,
|
131
|
+
payment_method: "balance",
|
132
|
+
}
|
133
|
+
end
|
134
|
+
end
|