|
5 | 5 | require 'pathname'
|
6 | 6 | require 'puppet/type/x509_cert'
|
7 | 7 |
|
8 |
| -provider_class = Puppet::Type.type(:x509_cert).provider(:openssl) |
9 | 8 | describe 'The openssl provider for the x509_cert type' do
|
10 | 9 | let(:path) { '/tmp/foo.crt' }
|
11 | 10 | let(:pathname) { Pathname.new(path) }
|
|
31 | 30 | end
|
32 | 31 |
|
33 | 32 | it 'creates a certificate with the proper options' do
|
34 |
| - expect(provider_class).to receive(:openssl).with([ |
35 |
| - 'req', |
36 |
| - '-config', '/tmp/foo.cnf', |
37 |
| - '-new', |
38 |
| - '-x509', |
39 |
| - '-days', 3650, |
40 |
| - '-key', '/tmp/foo.key', |
41 |
| - '-out', '/tmp/foo.crt', |
42 |
| - '-extensions', 'v3_req', |
43 |
| - ]) |
| 33 | + expect(resource.provider).to receive(:execute).with( |
| 34 | + [ |
| 35 | + '/usr/bin/openssl', |
| 36 | + 'req', |
| 37 | + '-config', '/tmp/foo.cnf', |
| 38 | + '-new', |
| 39 | + '-x509', |
| 40 | + '-days', 3650, |
| 41 | + '-key', '/tmp/foo.key', |
| 42 | + '-out', '/tmp/foo.crt', |
| 43 | + '-extensions', 'v3_req', |
| 44 | + ], |
| 45 | + { |
| 46 | + combine: true, |
| 47 | + custom_environment: {}, |
| 48 | + failonfail: true, |
| 49 | + } |
| 50 | + ) |
44 | 51 | resource.provider.create
|
45 | 52 | end
|
46 | 53 |
|
47 | 54 | context 'when using password' do
|
48 | 55 | it 'creates a certificate with the proper options' do
|
49 | 56 | resource[:password] = '2x6${'
|
50 |
| - expect(provider_class).to receive(:openssl).with([ |
51 |
| - 'req', |
52 |
| - '-config', '/tmp/foo.cnf', |
53 |
| - '-new', |
54 |
| - '-x509', |
55 |
| - '-days', 3650, |
56 |
| - '-key', '/tmp/foo.key', |
57 |
| - '-out', '/tmp/foo.crt', |
58 |
| - '-passin', 'pass:2x6${', |
59 |
| - '-extensions', 'v3_req', |
60 |
| - ]) |
| 57 | + expect(resource.provider).to receive(:execute).with( |
| 58 | + [ |
| 59 | + '/usr/bin/openssl', |
| 60 | + 'req', |
| 61 | + '-config', '/tmp/foo.cnf', |
| 62 | + '-new', |
| 63 | + '-x509', |
| 64 | + '-days', 3650, |
| 65 | + '-key', '/tmp/foo.key', |
| 66 | + '-out', '/tmp/foo.crt', |
| 67 | + '-passin', 'env:CERTIFICATE_PASSIN', |
| 68 | + '-extensions', 'v3_req', |
| 69 | + ], |
| 70 | + { |
| 71 | + combine: true, |
| 72 | + custom_environment: { 'CERTIFICATE_PASSIN' => '2x6${' }, |
| 73 | + failonfail: true, |
| 74 | + } |
| 75 | + ) |
61 | 76 | resource.provider.create
|
62 | 77 | end
|
63 | 78 | end
|
|
68 | 83 | resource[:csr] = '/tmp/foo.csr'
|
69 | 84 | resource[:ca] = '/tmp/foo-ca.crt'
|
70 | 85 | resource[:cakey] = '/tmp/foo-ca.key'
|
71 |
| - expect(provider_class).to receive(:openssl).with([ |
72 |
| - 'x509', |
73 |
| - '-req', |
74 |
| - '-days', 3650, |
75 |
| - '-in', '/tmp/foo.csr', |
76 |
| - '-out', '/tmp/foo.crt', |
77 |
| - '-extfile', '/tmp/foo.cnf', |
78 |
| - '-CAcreateserial', |
79 |
| - '-CA', '/tmp/foo-ca.crt', |
80 |
| - '-CAkey', '/tmp/foo-ca.key', |
81 |
| - '-extensions', 'v3_req', |
82 |
| - ]) |
| 86 | + expect(resource.provider).to receive(:execute).with( |
| 87 | + [ |
| 88 | + '/usr/bin/openssl', |
| 89 | + 'x509', |
| 90 | + '-req', |
| 91 | + '-days', 3650, |
| 92 | + '-in', '/tmp/foo.csr', |
| 93 | + '-out', '/tmp/foo.crt', |
| 94 | + '-extfile', '/tmp/foo.cnf', |
| 95 | + '-CAcreateserial', |
| 96 | + '-CA', '/tmp/foo-ca.crt', |
| 97 | + '-CAkey', '/tmp/foo-ca.key', |
| 98 | + '-extensions', 'v3_req', |
| 99 | + ], |
| 100 | + { |
| 101 | + combine: true, |
| 102 | + custom_environment: {}, |
| 103 | + failonfail: true, |
| 104 | + } |
| 105 | + ) |
83 | 106 | resource.provider.create
|
84 | 107 | end
|
85 | 108 | end
|
|
90 | 113 | resource[:ca] = '/tmp/foo-ca.crt'
|
91 | 114 | resource[:cakey] = '/tmp/foo-ca.key'
|
92 | 115 | resource[:cakey_password] = '5i;6%'
|
93 |
| - expect(provider_class).to receive(:openssl).with([ |
94 |
| - 'x509', |
95 |
| - '-req', |
96 |
| - '-days', 3650, |
97 |
| - '-in', '/tmp/foo.csr', |
98 |
| - '-out', '/tmp/foo.crt', |
99 |
| - '-extfile', '/tmp/foo.cnf', |
100 |
| - '-CAcreateserial', |
101 |
| - '-CA', '/tmp/foo-ca.crt', |
102 |
| - '-CAkey', '/tmp/foo-ca.key', |
103 |
| - '-passin', 'pass:5i;6%', |
104 |
| - '-extensions', 'v3_req', |
105 |
| - ]) |
| 116 | + expect(resource.provider).to receive(:execute).with( |
| 117 | + [ |
| 118 | + '/usr/bin/openssl', |
| 119 | + 'x509', |
| 120 | + '-req', |
| 121 | + '-days', 3650, |
| 122 | + '-in', '/tmp/foo.csr', |
| 123 | + '-out', '/tmp/foo.crt', |
| 124 | + '-extfile', '/tmp/foo.cnf', |
| 125 | + '-CAcreateserial', |
| 126 | + '-CA', '/tmp/foo-ca.crt', |
| 127 | + '-CAkey', '/tmp/foo-ca.key', |
| 128 | + '-passin', 'env:CERTIFICATE_PASSIN', |
| 129 | + '-extensions', 'v3_req', |
| 130 | + ], |
| 131 | + { |
| 132 | + combine: true, |
| 133 | + custom_environment: { 'CERTIFICATE_PASSIN' => '5i;6%' }, |
| 134 | + failonfail: true, |
| 135 | + } |
| 136 | + ) |
106 | 137 | resource.provider.create
|
107 | 138 | end
|
108 | 139 | end
|
|
0 commit comments