letscert 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,32 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- module LetsCert
4
-
5
- describe Loggable do
6
-
7
- it 'extend a class to add loggability' do
8
- class TestA; include Loggable; end
9
-
10
- expect(TestA.methods).to include(:logger=)
11
-
12
- my_logger = Logger.new(STDERR)
13
- TestA.logger = my_logger
14
- expect(TestA.new.logger).to eq(my_logger)
15
- end
16
-
17
- it 'extend a class and its subclasses to add loggability' do
18
- class TestA; include Loggable; end
19
- class TestB < TestA; end
20
-
21
- expect(TestA.methods).to include(:logger=)
22
- expect(TestB.methods).to include(:logger=)
23
-
24
- my_logger = Logger.new(STDERR)
25
- TestA.logger = my_logger
26
- expect(TestA.new.logger).to eq(my_logger)
27
- expect(TestB.new.logger).to eq(my_logger)
28
- end
29
-
30
- end
31
-
32
- end
data/spec/runner_spec.rb DELETED
@@ -1,127 +0,0 @@
1
- require_relative 'spec_helper'
2
-
3
- module LetsCert
4
-
5
- describe Runner do
6
-
7
- before(:each) { ARGV.clear }
8
-
9
- let(:runner) { Runner.new }
10
-
11
- context '#parse_options' do
12
-
13
- it 'accepts --domain with DOMAIN only' do
14
- ARGV << '--domain' << 'example.com'
15
-
16
- runner.parse_options
17
- expect(runner.options[:domains]).to be_a(Array)
18
- expect(runner.options[:domains].size).to eq(1)
19
- expect(runner.options[:domains]).to include('example.com')
20
- end
21
-
22
- it 'accepts --domain with DOMAIN:PATH' do
23
- ARGV << '--domain' << 'example.com:/var/www/html'
24
-
25
- runner.parse_options
26
- expect(runner.options[:domains]).to be_a(Array)
27
- expect(runner.options[:domains].size).to eq(1)
28
- expect(runner.options[:domains]).to include('example.com:/var/www/html')
29
- end
30
-
31
- it 'accepts multiple domains with --domain option' do
32
- ARGV << '--domain' << 'example.com'
33
- ARGV << '--domain' << 'www.example.com'
34
- ARGV << '--domain' << 'www2.example.com'
35
-
36
- runner.parse_options
37
- expect(runner.options[:domains]).to be_a(Array)
38
- expect(runner.options[:domains].size).to eq(3)
39
- expect(runner.options[:domains]).to include('example.com')
40
- expect(runner.options[:domains]).to include('www.example.com')
41
- expect(runner.options[:domains]).to include('www2.example.com')
42
- end
43
-
44
- it 'sets default root path with --default-root for domains without PATH' do
45
- ARGV << '--domain' << 'example.com'
46
- ARGV << '--domain' << 'another-example.com:/var/www/html'
47
- ARGV << '--default-root' << '/opt/www'
48
-
49
- runner.parse_options
50
- expect(runner.options[:default_root]).to eq('/opt/www')
51
- expect(runner.options[:roots]).to be_a(Hash)
52
- expect(runner.options[:roots]['example.com']).to eq(runner.options[:default_root])
53
- expect(runner.options[:roots]['another-example.com']).to eq('/var/www/html')
54
- end
55
-
56
- it 'accepts multiples files with --file option' do
57
- ARGV << '--file' << 'key.pem'
58
- ARGV << '-f' << 'cert.pem'
59
-
60
- runner.parse_options
61
- expect(runner.options[:files]).to be_a(Array)
62
- expect(runner.options[:files].size).to eq(2)
63
- expect(runner.options[:files]).to include('key.pem')
64
- expect(runner.options[:files]).to include('cert.pem')
65
- end
66
-
67
- it 'sets minimum validity time with --valid-min option' do
68
- ARGV << '--valid-min' << '30000'
69
-
70
- runner.parse_options
71
- expect(runner.options[:valid_min].to_seconds).to eq(30000)
72
- end
73
-
74
- it '--valid-min option accepts minute format' do
75
- minutes = 156
76
- ARGV << '--valid-min' << "#{minutes}m"
77
-
78
- runner.parse_options
79
- expect(runner.options[:valid_min].to_seconds).to eq(minutes * 60)
80
- end
81
-
82
- it '--valid-min option accepts hour format' do
83
- hours = 4
84
- ARGV << '--valid-min' << "#{hours}h"
85
-
86
- runner.parse_options
87
- expect(runner.options[:valid_min].to_seconds).to eq(hours * 3600)
88
- end
89
-
90
- it '--valid-min option accepts day format' do
91
- days = 20
92
- ARGV << '--valid-min' << "#{days}d"
93
-
94
- runner.parse_options
95
- expect(runner.options[:valid_min].to_seconds).to eq(days * 24 * 3600)
96
- end
97
-
98
- end
99
-
100
- it '#check_persisted checks all mandatory components are covered by files' do
101
- expect { runner.check_persisted }.to raise_error(LetsCert::Error)
102
-
103
- all_needed = [%w(account_key.json cert.pem chain.pem key.pem),
104
- %w(account_key.json cert.der chain.pem key.der),
105
- %w(account_key.json fullchain.pem key.pem),
106
- %w(account_key.json fullchain.pem key.der)]
107
- all_needed.each do |needed|
108
- needed.size.times do |nb|
109
- ARGV.clear
110
- runner.options[:files] = []
111
- 0.upto(nb) do |i|
112
- ARGV << '-f' << needed[i]
113
- end
114
- runner.parse_options
115
-
116
- if nb == needed.size - 1
117
- expect { runner.check_persisted }.to_not raise_error
118
- else
119
- expect { runner.check_persisted }.to raise_error(LetsCert::Error)
120
- end
121
- end
122
- end
123
- end
124
-
125
- end
126
-
127
- end
data/spec/spec_helper.rb DELETED
@@ -1,28 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
2
- require 'letscert'
3
-
4
- require 'vcr'
5
- require 'faraday'
6
-
7
- VCR.configure do |config|
8
- config.cassette_library_dir = "fixtures/vcr_cassettes"
9
- config.hook_into :faraday
10
- end
11
-
12
-
13
- # Faraday Middleware to remove HTTP-01 challenge
14
- class RemoveHttp01Middleware < Faraday::Middleware
15
- def call(request_env)
16
- @app.call(request_env).on_complete do |response_env|
17
- body = response_env.response.body
18
- if body['challenges'] and !body['challenges'].empty?
19
- body['challenges'].each_with_index do |challenge, index|
20
- if challenge['type'] == 'http-01'
21
- body['challenges'].delete_at(index)
22
- break
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
data/spec/test.json DELETED
@@ -1 +0,0 @@
1
- {"kty":"RSA","e":"AQAB","n":"ugv1o2Fg5N-RBScXrLpRRoPgDjFgHcM_BD2fHZYzXJ4k1AnspAgS-soaWuoN0WK4mwRsSGwF7cemLEA1zZiCpc6Q3WUxLDsM8oF8P_S0euAEhe8FQPON3vtNqYth2yPqAQ4-me43mZyXS94yzTrCVjowlnZsdaA54uUW0AxOD_0","d":"Qo-6zzwspVXTFYvZ7YMvRtIxnAJQR_Wtmv_M6JHvSEiQFoiCcGEvISijazlnvizarSNU9kgnit2t9xD17tuMidbqdPC0x0mkJ6BszB7lau6Nzfz6ACSqtH8eKmkGDBJTnRqzg45Z6-3-gQ9vlmvc3T029Gv7xfA-XOt_cNgFnGE","p":"7nhrSRbf6FZ6LA2FKzcdFOTSI7UlgEwWsrSC_7pyzYyXJC44crlWUDxxJJXNeC9OyOEJOXlgn-0hShAWkl9-CQ","q":"x7kFmj6GYbh0SaLeg9CFhnY-y_UMO9wFxu0NLi2JgL31gvIDrKGJYiSZ3xESi6FwpmHX_vbtFXpZXBbvMy0_VQ"}
data/tasks/spec.rake DELETED
@@ -1,3 +0,0 @@
1
- require 'rspec/core/rake_task'
2
-
3
- RSpec::Core::RakeTask.new
data/tasks/yard.rake DELETED
@@ -1,6 +0,0 @@
1
- require 'yard'
2
-
3
- YARD::Rake::YardocTask.new do |t|
4
- t.options = ['--no-private']
5
- t.files = ['lib/**/*.rb', '-', 'LICENSE']
6
- end