le_ssl 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75c30d8bdc71fdbeb4e5baa42db1f24b32e2d6b5
4
- data.tar.gz: d4defef5b7aef85efb31091105227f059f4f89fd
3
+ metadata.gz: 93e078bf7f64c2428d94b4079c19a2716c6c0b96
4
+ data.tar.gz: b1539cbbd767a6a1b7e0be7a58c2713345428e0f
5
5
  SHA512:
6
- metadata.gz: 865a7ed925a8da5160a2adaeb91fc03f51a04a5d399043f167ef77e763cec676dcfec7e40a8156a6f64aac4401a04e7140c517a7dffc2a8a5f7c34430714bd70
7
- data.tar.gz: 3ebff137c44622faba396f58f3155f0a4b60e122d9640362d0a899a0a65e1dfd77b41c715a6e1a4c81cf5af0a938b8c7050334ee6a14e9ccfc0f5001adaf9f55
6
+ metadata.gz: aef575b38de268b8a4ab3417b2741de3833e3415336d9084a4a66f625799031d28260b0a722be77b9512add094b36790678a470c43aa5b8a9186933c512134f2
7
+ data.tar.gz: a5f4045cc4be06e84a04bc7bf9d85c7358ecd5e45f10bc32ea9369e8137ca813920b07609a44e447833ac771b7154a22b0625bc2d5804cd5ba79a045be2fc992
@@ -4,7 +4,7 @@ module LeSsl
4
4
  DEVELOPMENT_ENDPOINT = 'https://acme-staging.api.letsencrypt.org/'
5
5
 
6
6
  def initialize(options={})
7
- email = options[:email] || ENV['CERT_ACCOUNT_EMAIL'].presence
7
+ email = options[:email] || email_from_env
8
8
 
9
9
  raise LeSsl::NoContactEmailError if email.nil?
10
10
  raise LeSsl::TermsNotAcceptedError unless options[:agree_terms] == true
@@ -16,23 +16,53 @@ module LeSsl
16
16
  register(email) unless options[:skip_register] == true
17
17
  end
18
18
 
19
- def authorize_for_domain(domain)
19
+ # Authorize the client
20
+ # for a domain name.
21
+ #
22
+ # Challenge options:
23
+ # - HTTP (default and recommended)
24
+ # - DNS (requires manual verification)
25
+ def authorize_for_domain(domain, options={})
20
26
  authorization = client.authorize(domain: domain)
21
- challenge = authorization.http01
22
27
 
23
- file_name = Rails.root.join('public', challenge.filename)
24
- dir = File.dirname(Rails.root.join('public', challenge.filename))
28
+ # Default challenge is via HTTP
29
+ # but the developer can also use
30
+ # a DNS TXT record to authorize.
31
+ if options[:challenge] == :dns
32
+ challenge = authorization.dns01
33
+
34
+ unless options[:skip_puts]
35
+ puts "===================================================================="
36
+ puts "Record:"
37
+ puts
38
+ puts " - Name: #{challenge.record_name}"
39
+ puts " - Type: #{challenge.record_type}"
40
+ puts " - Value: #{challenge.record_content}"
41
+ puts
42
+ puts "Create the record; Wait a minute (or two); Request for verification!"
43
+ puts "===================================================================="
44
+ end
45
+
46
+ return challenge
47
+ else
48
+ challenge = authorization.http01
25
49
 
26
- FileUtils.mkdir_p(dir)
50
+ file_name = Rails.root.join('public', challenge.filename)
51
+ dir = File.dirname(Rails.root.join('public', challenge.filename))
27
52
 
28
- File.write(file_name, challenge.file_content)
53
+ FileUtils.mkdir_p(dir)
29
54
 
30
- challenge.request_verification
55
+ File.write(file_name, challenge.file_content)
56
+
57
+ request_verification(challenge) == 'invalid'
58
+
59
+ return challenge.verify_status
60
+ end
61
+ end
31
62
 
63
+ def request_verification(challenge)
64
+ challenge.request_verification
32
65
  sleep(1)
33
-
34
- File.delete(file_name) if challenge.verify_status == 'invalid'
35
-
36
66
  return challenge.verify_status
37
67
  end
38
68
 
@@ -75,7 +105,7 @@ module LeSsl
75
105
  end
76
106
 
77
107
  def private_key
78
- self.private_key = ENV['CERT_ACCOUNT_PRIVATE_KEY'].presence if @private_key.nil?
108
+ self.private_key = private_key_string_from_env if @private_key.nil?
79
109
  raise(LeSsl::NoPrivateKeyError, "No private key for certificate account found") if @private_key.nil?
80
110
 
81
111
  @private_key
@@ -84,5 +114,15 @@ module LeSsl
84
114
  def client
85
115
  @acme_client ||= Acme::Client.new(private_key: private_key, endpoint: (Rails.env.development? ? DEVELOPMENT_ENDPOINT : PRODUCTION_ENDPOINT))
86
116
  end
117
+
118
+ def private_key_string_from_env
119
+ warn "DEPRECATION WARNING! Use LESSL_CLIENT_PRIVATE_KEY instead of CERT_ACCOUNT_PRIVATE_KEY for environment variable!" if ENV['CERT_ACCOUNT_PRIVATE_KEY'].present?
120
+ return ENV['LESSL_CLIENT_PRIVATE_KEY'] || ENV['CERT_ACCOUNT_PRIVATE_KEY'].presence
121
+ end
122
+
123
+ def email_from_env
124
+ warn "DEPRECATION WARNING! Use LESSL_CONTACT_EMAIL instead of CERT_ACCOUNT_EMAIL for environment variable!" if ENV['CERT_ACCOUNT_EMAIL'].present?
125
+ return ENV['LESSL_CONTACT_EMAIL'].presence || ENV['CERT_ACCOUNT_EMAIL'].presence
126
+ end
87
127
  end
88
128
  end
@@ -1,3 +1,3 @@
1
1
  module LeSsl
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -16,3 +16,474 @@ LeSSLTest: test_truth
16
16
  ---------------------
17
17
  LeSslTest: test_truth
18
18
  ---------------------
19
+ -------------------------------------------------------------------
20
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
21
+ -------------------------------------------------------------------
22
+ --------------------------------------------------------------------------------------------------
23
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
24
+ --------------------------------------------------------------------------------------------------
25
+ -------------------------------------------------------------
26
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
27
+ -------------------------------------------------------------
28
+ ----------------------------------------------------------------------
29
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
30
+ ----------------------------------------------------------------------
31
+ -----------------------------------------------
32
+ LeSsl::ManagerTest: test_authorization_with_DNS
33
+ -----------------------------------------------
34
+ -------------------------------
35
+ LeSsl::ManagerTest: test_client
36
+ -------------------------------
37
+ -------------------------------------------------------------------
38
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
39
+ -------------------------------------------------------------------
40
+ -------------------------------------------------------------------
41
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
42
+ -------------------------------------------------------------------
43
+ -------------------------------
44
+ LeSsl::ManagerTest: test_client
45
+ -------------------------------
46
+ -------------------------------------------------------------------
47
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
48
+ -------------------------------------------------------------------
49
+ ----------------------------------------------------------------------
50
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
51
+ ----------------------------------------------------------------------
52
+ -----------------------------------------------
53
+ LeSsl::ManagerTest: test_authorization_with_DNS
54
+ -----------------------------------------------
55
+ --------------------------------------------------------------------------------------------------
56
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
57
+ --------------------------------------------------------------------------------------------------
58
+ -------------------------------------------------------------
59
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
60
+ -------------------------------------------------------------
61
+ -----------------------------------------------
62
+ LeSsl::ManagerTest: test_authorization_with_DNS
63
+ -----------------------------------------------
64
+ ---------------------------------------------------------------------
65
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
66
+ ---------------------------------------------------------------------
67
+ ----------------------------------------------------------------------------------
68
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
69
+ ----------------------------------------------------------------------------------
70
+ --------------------------------------------------------------------------
71
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
72
+ --------------------------------------------------------------------------
73
+ --------------------------------------------------------------------------------------------------
74
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
75
+ --------------------------------------------------------------------------------------------------
76
+ ----------------------------------------------------------------------
77
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
78
+ ----------------------------------------------------------------------
79
+ ---------------------------------------------------------------------------------------
80
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
81
+ ---------------------------------------------------------------------------------------
82
+ ------------------------------------------------------------------------------------------
83
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
84
+ ------------------------------------------------------------------------------------------
85
+ -------------------------------------------------------------
86
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
87
+ -------------------------------------------------------------
88
+ -------------------------------
89
+ LeSsl::ManagerTest: test_client
90
+ -------------------------------
91
+ -------------------------------------------------------------------
92
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
93
+ -------------------------------------------------------------------
94
+ -----------------------------------------------------------------------------
95
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
96
+ -----------------------------------------------------------------------------
97
+ -------------------------------------------------------------------
98
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
99
+ -------------------------------------------------------------------
100
+ -------------------------------------------------------------------
101
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
102
+ -------------------------------------------------------------------
103
+ ---------------------------------------------------------------------------------------
104
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
105
+ ---------------------------------------------------------------------------------------
106
+ ---------------------------------------------------------------------
107
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
108
+ ---------------------------------------------------------------------
109
+ --------------------------------------------------------------------------
110
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
111
+ --------------------------------------------------------------------------
112
+ --------------------------------------------------------------------------------------------------
113
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
114
+ --------------------------------------------------------------------------------------------------
115
+ -----------------------------------------------------------------------------
116
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
117
+ -----------------------------------------------------------------------------
118
+ -------------------------------------------------------------------
119
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
120
+ -------------------------------------------------------------------
121
+ ----------------------------------------------------------------------------------
122
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
123
+ ----------------------------------------------------------------------------------
124
+ -----------------------------------------------
125
+ LeSsl::ManagerTest: test_authorization_with_DNS
126
+ -----------------------------------------------
127
+ ------------------------------------------------------------------------------------------
128
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
129
+ ------------------------------------------------------------------------------------------
130
+ -------------------------------
131
+ LeSsl::ManagerTest: test_client
132
+ -------------------------------
133
+ ----------------------------------------------------------------------
134
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
135
+ ----------------------------------------------------------------------
136
+ -------------------------------------------------------------
137
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
138
+ -------------------------------------------------------------
139
+ ----------------------------------------------------------------------
140
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
141
+ ----------------------------------------------------------------------
142
+ ---------------------------------------------------------------------
143
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
144
+ ---------------------------------------------------------------------
145
+ -------------------------------------------------------------------
146
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
147
+ -------------------------------------------------------------------
148
+ -----------------------------------------------------------------------------
149
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
150
+ -----------------------------------------------------------------------------
151
+ -------------------------------------------------------------
152
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
153
+ -------------------------------------------------------------
154
+ ----------------------------------------------------------------------------------
155
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
156
+ ----------------------------------------------------------------------------------
157
+ --------------------------------------------------------------------------------------------------
158
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
159
+ --------------------------------------------------------------------------------------------------
160
+ ------------------------------------------------------------------------------------------
161
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
162
+ ------------------------------------------------------------------------------------------
163
+ ---------------------------------------------------------------------------------------
164
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
165
+ ---------------------------------------------------------------------------------------
166
+ -----------------------------------------------
167
+ LeSsl::ManagerTest: test_authorization_with_DNS
168
+ -----------------------------------------------
169
+ --------------------------------------------------------------------------
170
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
171
+ --------------------------------------------------------------------------
172
+ -------------------------------------------------------------------
173
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
174
+ -------------------------------------------------------------------
175
+ -------------------------------
176
+ LeSsl::ManagerTest: test_client
177
+ -------------------------------
178
+ -------------------------------
179
+ LeSsl::ManagerTest: test_client
180
+ -------------------------------
181
+ --------------------------------------------------------------------------
182
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
183
+ --------------------------------------------------------------------------
184
+ -------------------------------------------------------------------
185
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
186
+ -------------------------------------------------------------------
187
+ ---------------------------------------------------------------------------------------
188
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
189
+ ---------------------------------------------------------------------------------------
190
+ -----------------------------------------------------------------------------
191
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
192
+ -----------------------------------------------------------------------------
193
+ ----------------------------------------------------------------------------------
194
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
195
+ ----------------------------------------------------------------------------------
196
+ ------------------------------------------------------------------------------------------
197
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
198
+ ------------------------------------------------------------------------------------------
199
+ ---------------------------------------------------------------------
200
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
201
+ ---------------------------------------------------------------------
202
+ -------------------------------------------------------------------
203
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
204
+ -------------------------------------------------------------------
205
+ -------------------------------------------------------------
206
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
207
+ -------------------------------------------------------------
208
+ -----------------------------------------------
209
+ LeSsl::ManagerTest: test_authorization_with_DNS
210
+ -----------------------------------------------
211
+ ----------------------------------------------------------------------
212
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
213
+ ----------------------------------------------------------------------
214
+ --------------------------------------------------------------------------------------------------
215
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
216
+ --------------------------------------------------------------------------------------------------
217
+ -------------------------------------------------------------
218
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
219
+ -------------------------------------------------------------
220
+ ----------------------------------------------------------------------------------
221
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
222
+ ----------------------------------------------------------------------------------
223
+ -----------------------------------------------------------------------------
224
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
225
+ -----------------------------------------------------------------------------
226
+ ---------------------------------------------------------------------------------------
227
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
228
+ ---------------------------------------------------------------------------------------
229
+ ----------------------------------------------------------------------
230
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
231
+ ----------------------------------------------------------------------
232
+ -------------------------------------------------------------------
233
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
234
+ -------------------------------------------------------------------
235
+ -------------------------------------------------------------------
236
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
237
+ -------------------------------------------------------------------
238
+ ---------------------------------------------------------------------
239
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
240
+ ---------------------------------------------------------------------
241
+ -------------------------------
242
+ LeSsl::ManagerTest: test_client
243
+ -------------------------------
244
+ --------------------------------------------------------------------------
245
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
246
+ --------------------------------------------------------------------------
247
+ --------------------------------------------------------------------------------------------------
248
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
249
+ --------------------------------------------------------------------------------------------------
250
+ -----------------------------------------------
251
+ LeSsl::ManagerTest: test_authorization_with_DNS
252
+ -----------------------------------------------
253
+ ------------------------------------------------------------------------------------------
254
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
255
+ ------------------------------------------------------------------------------------------
256
+ ----------------------------------------------------------------------------------
257
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
258
+ ----------------------------------------------------------------------------------
259
+ -------------------------------------------------------------------
260
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
261
+ -------------------------------------------------------------------
262
+ --------------------------------------------------------------------------
263
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
264
+ --------------------------------------------------------------------------
265
+ -------------------------------------------------------------------
266
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
267
+ -------------------------------------------------------------------
268
+ ----------------------------------------------------------------------
269
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
270
+ ----------------------------------------------------------------------
271
+ -------------------------------
272
+ LeSsl::ManagerTest: test_client
273
+ -------------------------------
274
+ -----------------------------------------------------------------------------
275
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
276
+ -----------------------------------------------------------------------------
277
+ ---------------------------------------------------------------------
278
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
279
+ ---------------------------------------------------------------------
280
+ -------------------------------------------------------------
281
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
282
+ -------------------------------------------------------------
283
+ ------------------------------------------------------------------------------------------
284
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
285
+ ------------------------------------------------------------------------------------------
286
+ -----------------------------------------------
287
+ LeSsl::ManagerTest: test_authorization_with_DNS
288
+ -----------------------------------------------
289
+ ---------------------------------------------------------------------------------------
290
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
291
+ ---------------------------------------------------------------------------------------
292
+ --------------------------------------------------------------------------------------------------
293
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
294
+ --------------------------------------------------------------------------------------------------
295
+ ---------------------------------------------------------------------------------------
296
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
297
+ ---------------------------------------------------------------------------------------
298
+ ----------------------------------------------------------------------------------
299
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
300
+ ----------------------------------------------------------------------------------
301
+ -------------------------------------------------------------------
302
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
303
+ -------------------------------------------------------------------
304
+ -------------------------------------------------------------------
305
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
306
+ -------------------------------------------------------------------
307
+ ----------------------------------------------------------------------
308
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
309
+ ----------------------------------------------------------------------
310
+ -------------------------------------------------------------
311
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
312
+ -------------------------------------------------------------
313
+ -----------------------------------------------
314
+ LeSsl::ManagerTest: test_authorization_with_DNS
315
+ -----------------------------------------------
316
+ --------------------------------------------------------------------------
317
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
318
+ --------------------------------------------------------------------------
319
+ ---------------------------------------------------------------------
320
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
321
+ ---------------------------------------------------------------------
322
+ ------------------------------------------------------------------------------------------
323
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
324
+ ------------------------------------------------------------------------------------------
325
+ --------------------------------------------------------------------------------------------------
326
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
327
+ --------------------------------------------------------------------------------------------------
328
+ -------------------------------
329
+ LeSsl::ManagerTest: test_client
330
+ -------------------------------
331
+ -----------------------------------------------------------------------------
332
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
333
+ -----------------------------------------------------------------------------
334
+ -------------------------------------------------------------------
335
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
336
+ -------------------------------------------------------------------
337
+ ----------------------------------------------------------------------
338
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
339
+ ----------------------------------------------------------------------
340
+ -------------------------------
341
+ LeSsl::ManagerTest: test_client
342
+ -------------------------------
343
+ -------------------------------------------------------------------
344
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
345
+ -------------------------------------------------------------------
346
+ ---------------------------------------------------------------------
347
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
348
+ ---------------------------------------------------------------------
349
+ -----------------------------------------------------------------------------
350
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
351
+ -----------------------------------------------------------------------------
352
+ ----------------------------------------------------------------------------------
353
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
354
+ ----------------------------------------------------------------------------------
355
+ --------------------------------------------------------------------------------------------------
356
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
357
+ --------------------------------------------------------------------------------------------------
358
+ -----------------------------------------------
359
+ LeSsl::ManagerTest: test_authorization_with_DNS
360
+ -----------------------------------------------
361
+ -------------------------------------------------------------
362
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
363
+ -------------------------------------------------------------
364
+ ------------------------------------------------------------------------------------------
365
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
366
+ ------------------------------------------------------------------------------------------
367
+ ---------------------------------------------------------------------------------------
368
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
369
+ ---------------------------------------------------------------------------------------
370
+ --------------------------------------------------------------------------
371
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
372
+ --------------------------------------------------------------------------
373
+ --------------------------------------------------------------------------------------------------
374
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
375
+ --------------------------------------------------------------------------------------------------
376
+ ----------------------------------------------------------------------
377
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
378
+ ----------------------------------------------------------------------
379
+ -------------------------------
380
+ LeSsl::ManagerTest: test_client
381
+ -------------------------------
382
+ --------------------------------------------------------------------------
383
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
384
+ --------------------------------------------------------------------------
385
+ ------------------------------------------------------------------------------------------
386
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
387
+ ------------------------------------------------------------------------------------------
388
+ ----------------------------------------------------------------------------------
389
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
390
+ ----------------------------------------------------------------------------------
391
+ -------------------------------------------------------------------
392
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
393
+ -------------------------------------------------------------------
394
+ -------------------------------------------------------------------
395
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
396
+ -------------------------------------------------------------------
397
+ ---------------------------------------------------------------------------------------
398
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
399
+ ---------------------------------------------------------------------------------------
400
+ ---------------------------------------------------------------------
401
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
402
+ ---------------------------------------------------------------------
403
+ -----------------------------------------------------------------------------
404
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
405
+ -----------------------------------------------------------------------------
406
+ -------------------------------------------------------------
407
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
408
+ -------------------------------------------------------------
409
+ -----------------------------------------------
410
+ LeSsl::ManagerTest: test_authorization_with_DNS
411
+ -----------------------------------------------
412
+ -------------------------------
413
+ LeSsl::ManagerTest: test_client
414
+ -------------------------------
415
+ ------------------------------------------------------------------------------------------
416
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
417
+ ------------------------------------------------------------------------------------------
418
+ -----------------------------------------------------------------------------
419
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
420
+ -----------------------------------------------------------------------------
421
+ ---------------------------------------------------------------------
422
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
423
+ ---------------------------------------------------------------------
424
+ -------------------------------------------------------------------
425
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
426
+ -------------------------------------------------------------------
427
+ ---------------------------------------------------------------------------------------
428
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
429
+ ---------------------------------------------------------------------------------------
430
+ --------------------------------------------------------------------------------------------------
431
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
432
+ --------------------------------------------------------------------------------------------------
433
+ ----------------------------------------------------------------------------------
434
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
435
+ ----------------------------------------------------------------------------------
436
+ -------------------------------------------------------------------
437
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
438
+ -------------------------------------------------------------------
439
+ -------------------------------------------------------------
440
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
441
+ -------------------------------------------------------------
442
+ --------------------------------------------------------------------------
443
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
444
+ --------------------------------------------------------------------------
445
+ ----------------------------------------------------------------------
446
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
447
+ ----------------------------------------------------------------------
448
+ -----------------------------------------------
449
+ LeSsl::ManagerTest: test_authorization_with_DNS
450
+ -----------------------------------------------
451
+ --------------------------------------------------------------------------------------------------
452
+ LeSsl::ManagerTest: test_valid_initialization_with_environment_variables_(but_without_registering)
453
+ --------------------------------------------------------------------------------------------------
454
+ -----------------------------------------------------------------------------
455
+ LeSsl::ManagerTest: test_#email_from_env_with_deprecated_environment_variable
456
+ -----------------------------------------------------------------------------
457
+ ---------------------------------------------------------------------
458
+ LeSsl::ManagerTest: test_#email_from_env_without_environment_variable
459
+ ---------------------------------------------------------------------
460
+ ----------------------------------------------------------------------
461
+ LeSsl::ManagerTest: test_invalid_initialization_without_agreeing_terms
462
+ ----------------------------------------------------------------------
463
+ -------------------------------------------------------------
464
+ LeSsl::ManagerTest: test_invalid_initialization_without_email
465
+ -------------------------------------------------------------
466
+ --------------------------------------------------------------------------
467
+ LeSsl::ManagerTest: test_#email_from_env_with_current_environment_variable
468
+ --------------------------------------------------------------------------
469
+ -----------------------------------------------
470
+ LeSsl::ManagerTest: test_authorization_with_DNS
471
+ -----------------------------------------------
472
+ -------------------------------------------------------------------
473
+ LeSsl::ManagerTest: test_valid_initialization_(without_registering)
474
+ -------------------------------------------------------------------
475
+ ----------------------------------------------------------------------------------
476
+ LeSsl::ManagerTest: test_#private_key_string_from_env_without_environment_variable
477
+ ----------------------------------------------------------------------------------
478
+ ------------------------------------------------------------------------------------------
479
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_deprecated_environment_variable
480
+ ------------------------------------------------------------------------------------------
481
+ -------------------------------
482
+ LeSsl::ManagerTest: test_client
483
+ -------------------------------
484
+ ---------------------------------------------------------------------------------------
485
+ LeSsl::ManagerTest: test_#private_key_string_from_env_with_current_environment_variable
486
+ ---------------------------------------------------------------------------------------
487
+ -------------------------------------------------------------------
488
+ LeSsl::ManagerTest: test_invalid_initialization_without_private_key
489
+ -------------------------------------------------------------------
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class LeSsl::ManagerTest < ActiveSupport::TestCase
4
4
  def private_key; @private_key ||= OpenSSL::PKey::RSA.new(2048); end
5
- def manager; @manager ||= LeSsl::Manager.new(skip_register: true, email: FFaker::Internet.email, private_key: private_key, agree_terms: true); end
5
+ def manager(skip_register=true); @manager ||= LeSsl::Manager.new(skip_register: skip_register, email: FFaker::Internet.free_email, private_key: private_key, agree_terms: true); end
6
6
 
7
7
  test 'valid initialization (without registering)' do
8
8
  assert_nothing_raised do
@@ -13,8 +13,8 @@ class LeSsl::ManagerTest < ActiveSupport::TestCase
13
13
  end
14
14
 
15
15
  test 'valid initialization with environment variables (but without registering)' do
16
- ENV['CERT_ACCOUNT_EMAIL'] = FFaker::Internet.email
17
- ENV['CERT_ACCOUNT_PRIVATE_KEY'] = private_key.to_s
16
+ ENV['LESSL_CONTACT_EMAIL'] = FFaker::Internet.email
17
+ ENV['LESSL_CLIENT_PRIVATE_KEY'] = private_key.to_s
18
18
 
19
19
  m = nil # Scope
20
20
 
@@ -25,8 +25,8 @@ class LeSsl::ManagerTest < ActiveSupport::TestCase
25
25
  assert_equal_private_keys private_key, m.send(:private_key)
26
26
 
27
27
  # Global variables!
28
- ENV['CERT_ACCOUNT_EMAIL'] = nil
29
- ENV['CERT_ACCOUNT_PRIVATE_KEY'] = nil
28
+ ENV.delete('LESSL_CONTACT_EMAIL')
29
+ ENV.delete('LESSL_CLIENT_PRIVATE_KEY')
30
30
  end
31
31
 
32
32
  test 'invalid initialization without email' do
@@ -51,6 +51,68 @@ class LeSsl::ManagerTest < ActiveSupport::TestCase
51
51
  assert_kind_of Acme::Client, manager.send(:client)
52
52
  end
53
53
 
54
+ test 'authorization with DNS' do
55
+ challenge = manager(false).authorize_for_domain('example.org', challenge: :dns, skip_puts: true)
56
+
57
+ assert_kind_of Acme::Client::Resources::Challenges::DNS01, challenge
58
+ end
59
+
60
+ test '#private_key_string_from_env with deprecated environment variable' do
61
+ ENV['CERT_ACCOUNT_PRIVATE_KEY'] = private_key.to_s
62
+ pk = nil
63
+
64
+ out, err = capture_io do
65
+ pk = manager.send(:private_key_string_from_env)
66
+ end
67
+
68
+ assert_match "DEPRECATION WARNING! Use LESSL_CLIENT_PRIVATE_KEY instead of CERT_ACCOUNT_PRIVATE_KEY for environment variable!", err
69
+
70
+ assert_not_nil pk
71
+ assert_equal ENV['CERT_ACCOUNT_PRIVATE_KEY'], pk
72
+ ENV.delete('CERT_ACCOUNT_PRIVATE_KEY')
73
+ end
74
+
75
+ test '#private_key_string_from_env with current environment variable' do
76
+ ENV['LESSL_CLIENT_PRIVATE_KEY'] = private_key.to_s
77
+ pk = manager.send(:private_key_string_from_env)
78
+ assert_not_nil pk
79
+ assert_equal ENV['LESSL_CLIENT_PRIVATE_KEY'], pk
80
+ ENV.delete('LESSL_CLIENT_PRIVATE_KEY')
81
+ end
82
+
83
+ test '#private_key_string_from_env without environment variable' do
84
+ ENV['LESSL_CLIENT_PRIVATE_KEY'] = ENV['CERT_ACCOUNT_PRIVATE_KEY'] = nil
85
+ assert_nil manager.send(:private_key_string_from_env)
86
+ end
87
+
88
+ test '#email_from_env with deprecated environment variable' do
89
+ ENV['CERT_ACCOUNT_EMAIL'] = FFaker::Internet.email
90
+ email = nil
91
+
92
+ out, err = capture_io do
93
+ email = manager.send(:email_from_env)
94
+ end
95
+
96
+ assert_match "DEPRECATION WARNING! Use LESSL_CONTACT_EMAIL instead of CERT_ACCOUNT_EMAIL for environment variable!", err
97
+
98
+ assert_not_nil email
99
+ assert_equal ENV['CERT_ACCOUNT_EMAIL'], email
100
+ ENV.delete('CERT_ACCOUNT_EMAIL')
101
+ end
102
+
103
+ test '#email_from_env with current environment variable' do
104
+ ENV['LESSL_CONTACT_EMAIL'] = FFaker::Internet.email
105
+ email = manager.send(:email_from_env)
106
+ assert_not_nil email
107
+ assert_equal ENV['LESSL_CONTACT_EMAIL'], email
108
+ ENV.delete('LESSL_CONTACT_EMAIL')
109
+ end
110
+
111
+ test '#email_from_env without environment variable' do
112
+ ENV['LESSL_CONTACT_EMAIL'] = ENV['CERT_ACCOUNT_EMAIL'] = nil
113
+ assert_nil manager.send(:email_from_env)
114
+ end
115
+
54
116
  private
55
117
 
56
118
  def assert_equal_private_keys(a, b)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: le_ssl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Feistmantl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails