digicert 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd07d0672b7d9440725cbdc1156f2ed227d5a8cc
4
- data.tar.gz: 3dcc363333f577e065de67969432da97c22f25fd
3
+ metadata.gz: e2099a3dbed371814f946054f72c991ca11b8327
4
+ data.tar.gz: 14593dbf7ac9ef432fb80fdf1314d6dfc790b81e
5
5
  SHA512:
6
- metadata.gz: 05c814b1d75b31baee08750aba853d8516c218f45ca67767b772157447f68fc51956eb10864b83277c033d9f5a1774b25498f028748fb8a8ad23e5724a699da8
7
- data.tar.gz: 2f4691a607f4a97a459212a00ef1d407593019f581abe204ba32d062702ac0359f313200f17948dae6c277b4bb06aef6838767429280d69bd74b27369a9627fb
6
+ metadata.gz: 9914c23d6e411677f84f8d926408d85a6487f4d050d573106c3e3b23b0df6380acd914b670e59c777650f9330e3ea6fcb68f7a9b63632a77158f70721a9203bf
7
+ data.tar.gz: d970af1cb439d97d7c9a35f70ebae5b813149b208922641983e3c0c4120d32c8c5075db0344d385b260d75ad0cb4cac2fdf419d10fb882bbaec5387368cd5e1c
@@ -1,9 +1,4 @@
1
1
  AllCops:
2
- Include:
3
- - "**/*.rake"
4
- - "**/Gemfile"
5
- - "**/Rakefile"
6
-
7
2
  Exclude:
8
3
  - db/schema.rb
9
4
 
@@ -357,8 +352,18 @@ Style/TrailingCommaInArguments:
357
352
  - no_comma
358
353
  Enabled: true
359
354
 
360
- Style/TrailingCommaInLiteral:
361
- Description: 'Checks for trailing comma in array and hash literals.'
355
+ Style/TrailingCommaInArrayLiteral:
356
+ Description: 'Checks for trailing comma in array literals.'
357
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
358
+ EnforcedStyleForMultiline: comma
359
+ SupportedStylesForMultiline:
360
+ - comma
361
+ - consistent_comma
362
+ - no_comma
363
+ Enabled: true
364
+
365
+ Style/TrailingCommaInHashLiteral:
366
+ Description: 'Checks for trailing comma in hash literals.'
362
367
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
363
368
  EnforcedStyleForMultiline: comma
364
369
  SupportedStylesForMultiline:
@@ -403,6 +408,13 @@ Layout/AlignParameters:
403
408
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent'
404
409
  Enabled: false
405
410
 
411
+ Layout/ConditionPosition:
412
+ Description: >-
413
+ Checks for condition placed in a confusing position relative to
414
+ the keyword.
415
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
416
+ Enabled: false
417
+
406
418
  Layout/DotPosition:
407
419
  Description: 'Checks the position of the dot in multi-line method calls.'
408
420
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
@@ -455,13 +467,6 @@ Lint/CircularArgumentReference:
455
467
  Description: "Don't refer to the keyword argument in the default value."
456
468
  Enabled: false
457
469
 
458
- Lint/ConditionPosition:
459
- Description: >-
460
- Checks for condition placed in a confusing position relative to
461
- the keyword.
462
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
463
- Enabled: false
464
-
465
470
  Lint/DeprecatedClassMethods:
466
471
  Description: 'Check for deprecated class method calls.'
467
472
  Enabled: false
@@ -487,7 +492,7 @@ Lint/HandleExceptions:
487
492
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
488
493
  Enabled: false
489
494
 
490
- Lint/LiteralInCondition:
495
+ Lint/LiteralAsCondition:
491
496
  Description: 'Checks of literals used in conditions.'
492
497
  Enabled: false
493
498
 
@@ -528,7 +533,7 @@ Lint/UnderscorePrefixedVariableName:
528
533
  Description: 'Do not use prefix `_` for a variable that is used.'
529
534
  Enabled: false
530
535
 
531
- Lint/UnneededDisable:
536
+ Lint/UnneededCopDisableDirective:
532
537
  Description: >-
533
538
  Checks for rubocop:disable comments that can be removed.
534
539
  Note: this cop is not disabled when disabling all cops.
@@ -1,3 +1,10 @@
1
+ ## 0.4.0 (2018-07-22)
2
+
3
+ * Add option support on certificate duplication
4
+ * Fix duplicate certificate finder related issue
5
+ * Fix duplication issue for `EV Plus` certificate
6
+ * Fix server platform id issue from order manager
7
+
1
8
  ## 0.3.0 (2017-12-08)
2
9
 
3
10
  * Minor updates in the readme and `rubocop` configuration
@@ -5,7 +5,11 @@ module Digicert
5
5
  end
6
6
 
7
7
  def find
8
- certificate_by_date_created
8
+ certificate_by_date_created || raise(
9
+ Digicert::Errors::RequestError.new(
10
+ request: "The request is still pending, needs an approval first!",
11
+ ),
12
+ )
9
13
  end
10
14
 
11
15
  def self.find_by(request_id:)
@@ -17,7 +21,9 @@ module Digicert
17
21
  attr_reader :request_id
18
22
 
19
23
  def certificate_by_date_created
20
- certificates_by_date_created.first
24
+ if request.status == "approved"
25
+ certificates_by_date_created.first
26
+ end
21
27
  end
22
28
 
23
29
  def certificates_by_date_created
@@ -33,8 +33,8 @@ module Digicert
33
33
  Digicert::OrderDuplicator.create(order_id: resource_id, **attributes)
34
34
  end
35
35
 
36
- def duplicate_certificates
37
- Digicert::DuplicateCertificate.all(order_id: resource_id)
36
+ def duplicate_certificates(attributes = {})
37
+ Digicert::DuplicateCertificate.all(order_id: resource_id, **attributes)
38
38
  end
39
39
 
40
40
  def email_validations
@@ -17,10 +17,16 @@ module Digicert
17
17
  def order_attributes
18
18
  {
19
19
  common_name: order.certificate.common_name,
20
- dns_names: order.certificate.dns_names,
20
+ dns_names: simplified_certificate_dns_names,
21
21
  csr: order.certificate.csr,
22
22
  signature_hash: order.certificate.signature_hash,
23
- server_platform: { id: order.certificate.server_platform.id },
23
+
24
+ # In a recent changes, the order response does not seem
25
+ # to have the paltform id in it, so let's not try to fetch
26
+ # the platform id for now, and once confirmed then we can
27
+ # also adjust this as necessary.
28
+ #
29
+ # server_platform: { id: order.certificate.server_platform.id },
24
30
  }
25
31
  end
26
32
 
@@ -28,6 +34,19 @@ module Digicert
28
34
  @order ||= Digicert::Order.fetch(order_id)
29
35
  end
30
36
 
37
+ def simplified_certificate_dns_names
38
+ if order.product.name_id == "ssl_ev_plus"
39
+ simplify_dns_name_to_duplicate_ev_plus
40
+ else
41
+ order.certificate.dns_names
42
+ end
43
+ end
44
+
45
+ def simplify_dns_name_to_duplicate_ev_plus
46
+ dns_names = order.certificate.dns_names
47
+ dns_names.select { |dns_name| dns_name.match(/.+\..+\..+/) }.uniq
48
+ end
49
+
31
50
  # Expose the resource_id as order_id, as it sounds
32
51
  # more readable and all of it's subclasses are only
33
52
  # gonna deal with order.
@@ -21,5 +21,5 @@
21
21
  # ++
22
22
 
23
23
  module Digicert
24
- VERSION = "0.3.1".freeze
24
+ VERSION = "0.4.0".freeze
25
25
  end
@@ -20,7 +20,7 @@ RSpec.describe Digicert::CertificateRequest do
20
20
  certificate_request = Digicert::CertificateRequest.fetch(request_id)
21
21
 
22
22
  expect(certificate_request.order.id).not_to be_nil
23
- expect(certificate_request.status).to eq("pending")
23
+ expect(certificate_request.status).to eq("approved")
24
24
  expect(certificate_request.requester.first_name).not_to be_nil
25
25
  end
26
26
  end
@@ -2,17 +2,32 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe Digicert::DuplicateCertificateFinder do
4
4
  describe ".find" do
5
- it "finds the duplicate certificate" do
6
- request_id = 123_456_789
5
+ context "approved request" do
6
+ it "finds the duplicate certificate" do
7
+ request_id = 123_456_789
7
8
 
8
- stub_digicert_certificate_request_fetch_api(request_id)
9
- stub_digicert_order_duplications_api(order_id)
9
+ stub_digicert_certificate_request_fetch_api(request_id)
10
+ stub_digicert_order_duplications_api(order_id)
10
11
 
11
- certificate = Digicert::DuplicateCertificateFinder.find_by(
12
- request_id: request_id,
13
- )
12
+ certificate = Digicert::DuplicateCertificateFinder.find_by(
13
+ request_id: request_id,
14
+ )
14
15
 
15
- expect(certificate.id).not_to be_nil
16
+ expect(certificate.id).not_to be_nil
17
+ end
18
+ end
19
+
20
+ context "pending request" do
21
+ it "returns RequestError with a message" do
22
+ request_id = 456_789_012
23
+ stub_digicert_certificate_request_fetch_api(
24
+ request_id, "certificate_request_pending"
25
+ )
26
+
27
+ expect do
28
+ Digicert::DuplicateCertificateFinder.find_by(request_id: request_id)
29
+ end.to raise_error(Digicert::Errors::RequestError)
30
+ end
16
31
  end
17
32
  end
18
33
 
@@ -11,6 +11,17 @@ RSpec.describe Digicert::OrderDuplicator do
11
11
  expect(order.id).not_to be_nil
12
12
  expect(order.requests.first.id).not_to be_nil
13
13
  end
14
+
15
+ context "ev plus certificate" do
16
+ it "cleanup data and duplicates an order" do
17
+ stub_digicert_order_fetch_api(order_id, "ssl_ev_order")
18
+
19
+ stub_digicert_ev_plus_duplicate_api
20
+ order = Digicert::OrderDuplicator.create(order_id: order_id)
21
+
22
+ expect(order.id).not_to be_nil
23
+ end
24
+ end
14
25
  end
15
26
 
16
27
  def order_id
@@ -23,10 +34,16 @@ RSpec.describe Digicert::OrderDuplicator do
23
34
  dns_names: order.certificate.dns_names,
24
35
  csr: order.certificate.csr,
25
36
  signature_hash: order.certificate.signature_hash,
26
- server_platform: { id: order.certificate.server_platform.id },
37
+ # server_platform: { id: order.certificate.server_platform.id },
27
38
  }
28
39
  end
29
40
 
41
+ def stub_digicert_ev_plus_duplicate_api
42
+ attributes = certificate_attributes
43
+ attributes[:dns_names] = [attributes[:dns_names].last]
44
+ stub_digicert_order_duplicate_api(order_id, attributes)
45
+ end
46
+
30
47
  def order
31
48
  @order ||= Digicert::Order.fetch(order_id)
32
49
  end
@@ -43,7 +43,7 @@ RSpec.describe Digicert::OrderReissuer do
43
43
  dns_names: order.certificate.dns_names,
44
44
  csr: order.certificate.csr,
45
45
  signature_hash: order.certificate.signature_hash,
46
- server_platform: { id: order.certificate.server_platform.id },
46
+ # server_platform: { id: order.certificate.server_platform.id },
47
47
  }
48
48
  end
49
49
 
@@ -100,11 +100,11 @@ RSpec.describe Digicert::Order do
100
100
  order = Digicert::Order.find(order_id)
101
101
  allow(Digicert::DuplicateCertificate).to receive(:all)
102
102
 
103
- order.duplicate_certificates
103
+ order.duplicate_certificates(sort: "date_created")
104
104
 
105
105
  expect(
106
106
  Digicert::DuplicateCertificate,
107
- ).to have_received(:all).with(order_id: order_id)
107
+ ).to have_received(:all).with(order_id: order_id, sort: "date_created")
108
108
  end
109
109
  end
110
110
 
@@ -2,7 +2,7 @@
2
2
  "id": 123456789,
3
3
  "date": "2014-08-19T18:16:07+00:00",
4
4
  "type": "new_request",
5
- "status": "pending",
5
+ "status": "approved",
6
6
  "date_processed": "2014-08-19T18:17:07+00:00",
7
7
  "requester": {
8
8
  "id": 151435,
@@ -0,0 +1,116 @@
1
+ {
2
+ "id": 456789012,
3
+ "date": "2014-08-19T18:16:07+00:00",
4
+ "type": "new_request",
5
+ "status": "pending",
6
+ "date_processed": "2014-08-19T18:17:07+00:00",
7
+ "requester": {
8
+ "id": 151435,
9
+ "first_name": "Clive",
10
+ "last_name": "Collegedean",
11
+ "email": "clivecollegedean@digicert.com"
12
+ },
13
+ "processor": {
14
+ "id": 154478,
15
+ "first_name": "John",
16
+ "last_name": "Smith",
17
+ "email": "john.smith@digicert.com"
18
+ },
19
+ "order": {
20
+ "id": 542757,
21
+ "certificate": {
22
+ "common_name": "www.example.com",
23
+ "dns_names": [
24
+ "www.example.com"
25
+ ],
26
+ "date_created": "2014-12-04T20:32:59+00:00",
27
+ "csr": "------ [CSR HERE] ------",
28
+ "organization": {
29
+ "id": 123456,
30
+ "name": "DigiCert Inc",
31
+ "city": "Lehi",
32
+ "state": "Utah",
33
+ "country": "US"
34
+ },
35
+ "server_platform": {
36
+ "id": 31,
37
+ "name": "nginx",
38
+ "install_url": "https:\/\/www.digicert.com\/ssl-certificate-installation-nginx.htm",
39
+ "csr_url": "https:\/\/www.digicert.com\/csr-creation-nginx.htm"
40
+ },
41
+ "signature_hash": "sha256",
42
+ "key_size": 2048,
43
+ "ca_cert": {
44
+ "id": "1E2F5A55FEA1A",
45
+ "name": "DigiCert High Assurance SHA2"
46
+ }
47
+ },
48
+ "status": "issued",
49
+ "is_renewal": true,
50
+ "date_created": "2014-04-10T19:32:59+00:00",
51
+ "organization": {
52
+ "id": 123456,
53
+ "name": "DigiCert Inc",
54
+ "city": "Lehi",
55
+ "state": "Utah",
56
+ "country": "US"
57
+ },
58
+ "validity_years": 2,
59
+ "disable_renewal_notifications": false,
60
+ "auto_renew": 0,
61
+ "container": {
62
+ "id": 5,
63
+ "name": "College of Science"
64
+ },
65
+ "product": {
66
+ "name_id": "ssl_plus",
67
+ "name": "SSL Plus",
68
+ "type": "ssl_certificate",
69
+ "validation_type": "code_signing_certificate",
70
+ "validation_name": "EV CS",
71
+ "validation_description": "Code Signing Organization Extended Validation (EV CS)"
72
+ },
73
+ "organization_contact": {
74
+ "first_name": "Jay",
75
+ "last_name": "Smith",
76
+ "email": "Jay.Smith@digicert.com",
77
+ "job_title": "VP",
78
+ "telephone": "8015555555"
79
+ },
80
+ "technical_contact": {
81
+ "first_name": "Jay",
82
+ "last_name": "Smith",
83
+ "email": "Jay.Smith@digicert.com",
84
+ "job_title": "VP",
85
+ "telephone": "8015555555"
86
+ },
87
+ "user": {
88
+ "id": 4564312,
89
+ "first_name": "first",
90
+ "last_name": "name",
91
+ "email": "first.name@digicert.com"
92
+ },
93
+ "requests": [
94
+ {
95
+ "id": 4321,
96
+ "date": "2014-04-10T19:32:59+00:00",
97
+ "type": "new request",
98
+ "status": "pending",
99
+ "comments": "request comments"
100
+ }
101
+ ],
102
+ "cs_provisioning_method": "ship_token",
103
+ "ship_info": {
104
+ "name": "Some Guy",
105
+ "addr1": "333 S 520 W",
106
+ "addr2": "Suite 500",
107
+ "city": "Lindon",
108
+ "state": "Utah",
109
+ "zip": 84042,
110
+ "country": "US",
111
+ "method": "STANDARD"
112
+ }
113
+ },
114
+ "comments": "Comments for the approver",
115
+ "processor_comment": "Comment left by the person who approved\/rejected the request."
116
+ }
@@ -0,0 +1,108 @@
1
+ {
2
+ "id": 123456789,
3
+ "certificate": {
4
+ "id": 112358,
5
+ "thumbprint": "7D236B54D19D5EACF0881FAF24D51DFE5D23E945",
6
+ "serial_number": "0669D46CAE79EF684A69777490602485",
7
+ "common_name": "digicert.com",
8
+ "dns_names": [
9
+ "digicert.com",
10
+ "www.digicert.com"
11
+ ],
12
+ "date_created": "2014-08-19T18:16:07+00:00",
13
+ "valid_from": "2014-08-19",
14
+ "valid_till": "2015-08-19",
15
+ "csr": "------ [CSR HERE] ------",
16
+ "organization": {
17
+ "id": 117483
18
+ },
19
+ "organization_units": [
20
+ "Digicert"
21
+ ],
22
+ "server_platform": {
23
+ "id": 45,
24
+ "name": "nginx",
25
+ "install_url": "https:\/\/www.digicert.com\/ssl-certificate-installation-nginx.htm",
26
+ "csr_url": "https:\/\/www.digicert.com\/csr-creation-nginx.htm"
27
+ },
28
+ "signature_hash": "sha256",
29
+ "key_size": 2048,
30
+ "ca_cert": {
31
+ "id": "f7slk4shv9s2wr3",
32
+ "name": "DCert Private CA"
33
+ }
34
+ },
35
+ "status": "approved",
36
+ "is_renewal": true,
37
+ "is_renewed": false,
38
+ "renewed_order_id": 0,
39
+ "business_unit": "Some Unit",
40
+ "date_created": "2014-08-19T18:16:07+00:00",
41
+ "organization": {
42
+ "name": "DigiCert, Inc.",
43
+ "display_name": "DigiCert, Inc.",
44
+ "is_active": true,
45
+ "city": "Lindon",
46
+ "state": "Utah",
47
+ "country": "us"
48
+ },
49
+ "disable_renewal_notifications": false,
50
+ "container": {
51
+ "id": 5,
52
+ "name": "College of Science"
53
+ },
54
+ "product": {
55
+ "name_id": "ssl_ev_plus",
56
+ "name": "SSL EV Plus",
57
+ "type": "ssl_certificate",
58
+ "validation_type": "ov",
59
+ "validation_name": "OV",
60
+ "validation_description": "Normal Organization Validation"
61
+ },
62
+ "organization_contact": {
63
+ "first_name": "Some",
64
+ "last_name": "Guy",
65
+ "email": "someguy@digicert.com",
66
+ "telephone": "8015551212"
67
+ },
68
+ "technical_contact": {
69
+ "first_name": "Some",
70
+ "last_name": "Guy",
71
+ "email": "someguy@digicert.com",
72
+ "telephone": "8015551212"
73
+ },
74
+ "user": {
75
+ "id": 153208,
76
+ "first_name": "Clive",
77
+ "last_name": "Collegedean",
78
+ "email": "clivecollegedean@digicert.com"
79
+ },
80
+ "requests": [
81
+ {
82
+ "id": 1,
83
+ "date": "2015-01-01T18:20:00+00:00",
84
+ "type": "new_request",
85
+ "status": "approved",
86
+ "comments": "Form autofill"
87
+ }
88
+ ],
89
+ "receipt_id": 123892,
90
+ "cs_provisioning_method": "none",
91
+ "send_minus_90": true,
92
+ "send_minus_60": true,
93
+ "send_minus_30": true,
94
+ "send_minus_7": true,
95
+ "send_minus_3": true,
96
+ "send_plus_7": true,
97
+ "public_id": "MZv8RhHDVl9R3Ieko3iMX89wvYT3bYPA",
98
+ "allow_duplicates": false,
99
+ "user_assignments": [
100
+ {
101
+ "id": 153208,
102
+ "first_name": "Clive",
103
+ "last_name": "Collegedean",
104
+ "email": "clivecollegedean@digicert.com"
105
+ }
106
+ ],
107
+ "payment_method": "balance"
108
+ }
@@ -18,11 +18,13 @@ module Digicert
18
18
  )
19
19
  end
20
20
 
21
- def stub_digicert_certificate_request_fetch_api(request_id)
21
+ def stub_digicert_certificate_request_fetch_api(request_id, json_file = nil)
22
+ json_file ||= "certificate_request"
23
+
22
24
  stub_api_response(
23
25
  :get,
24
26
  ["request", request_id].join("/"),
25
- filename: "certificate_request",
27
+ filename: json_file,
26
28
  status: 200,
27
29
  )
28
30
  end
@@ -56,9 +58,9 @@ module Digicert
56
58
  )
57
59
  end
58
60
 
59
- def stub_digicert_order_fetch_api(order_id)
61
+ def stub_digicert_order_fetch_api(order_id, file = "order")
60
62
  stub_api_response(
61
- :get, ["order/certificate", order_id].join("/"), filename: "order"
63
+ :get, ["order/certificate", order_id].join("/"), filename: file
62
64
  )
63
65
  end
64
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digicert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-18 00:00:00.000000000 Z
11
+ date: 2018-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: r509
@@ -220,6 +220,7 @@ files:
220
220
  - spec/fixtures/certificate.pem
221
221
  - spec/fixtures/certificate.zip
222
222
  - spec/fixtures/certificate_request.json
223
+ - spec/fixtures/certificate_request_pending.json
223
224
  - spec/fixtures/certificate_requests.json
224
225
  - spec/fixtures/certificate_revoked.json
225
226
  - spec/fixtures/container.json
@@ -248,6 +249,7 @@ files:
248
249
  - spec/fixtures/product.json
249
250
  - spec/fixtures/products.json
250
251
  - spec/fixtures/rsa4096.key
252
+ - spec/fixtures/ssl_ev_order.json
251
253
  - spec/requests/certificate_duplication_spec.rb
252
254
  - spec/requests/certificate_generation_spec.rb
253
255
  - spec/requests/certificate_reissuing_spec.rb
@@ -283,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
285
  version: '0'
284
286
  requirements: []
285
287
  rubyforge_project:
286
- rubygems_version: 2.6.14
288
+ rubygems_version: 2.6.8
287
289
  signing_key:
288
290
  specification_version: 4
289
291
  summary: Digicert Ruby API.