File tree 2 files changed +11
-2
lines changed
lib/pact_broker/certificates
spec/lib/pact_broker/certificates
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def cert_store
25
25
26
26
def find_all_certificates
27
27
Certificate . collect do | certificate |
28
- cert_arr = certificate . content . split ( /(-----END [^\- ]+-----)/ ) . each_slice ( 2 ) . map ( &:join )
28
+ cert_arr = certificate . content . split ( /(-----END [^\- ]+-----)/ ) . each_slice ( 2 ) . map ( &:join ) . map ( & :strip ) . select { | s | ! s . empty? }
29
29
cert_arr . collect do |c |
30
30
begin
31
31
OpenSSL ::X509 ::Certificate . new ( c )
Original file line number Diff line number Diff line change @@ -36,12 +36,21 @@ module Certificates
36
36
37
37
subject { Service . find_all_certificates }
38
38
39
- context "with a valid certificate file " do
39
+ context "with a valid certificate chain " do
40
40
it "returns all the X509 Certificate objects" do
41
41
expect ( subject . size ) . to eq 2
42
42
end
43
43
end
44
44
45
+ context "with a valid CA file" do
46
+ let ( :certificate_content ) { File . read ( 'spec/fixtures/certificates/cacert.pem' ) }
47
+
48
+ it "returns all the X509 Certificate objects" do
49
+ expect ( PactBroker . logger ) . to_not receive ( :error ) . with ( /Error.*1234/ )
50
+ expect ( subject . size ) . to eq 1
51
+ end
52
+ end
53
+
45
54
context "with an invalid certificate file" do
46
55
let ( :certificate_content ) { File . read ( 'spec/fixtures/certificate-invalid.pem' ) }
47
56
You can’t perform that action at this time.
0 commit comments