letsencrypt_plugin 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -5
- data/app/controllers/letsencrypt_plugin/application_controller.rb +20 -15
- data/app/models/letsencrypt_plugin/challenge.rb +14 -1
- data/lib/letsencrypt_plugin.rb +138 -1
- data/lib/letsencrypt_plugin/certificate_output.rb +17 -0
- data/lib/letsencrypt_plugin/challenge_store.rb +18 -0
- data/lib/letsencrypt_plugin/database_store.rb +11 -0
- data/lib/letsencrypt_plugin/file_output.rb +18 -0
- data/lib/letsencrypt_plugin/file_store.rb +16 -0
- data/lib/letsencrypt_plugin/heroku_output.rb +19 -0
- data/lib/letsencrypt_plugin/version.rb +2 -1
- data/lib/tasks/letsencrypt_plugin_tasks.rake +4 -97
- data/test/cassettes/letsencrypt.log +0 -0
- data/test/cassettes/registration_agree_terms.yml +326 -0
- data/test/controllers/application_controller_test.rb +9 -4
- data/test/dummy/bin/setup +11 -11
- data/test/dummy/config/application.rb +1 -3
- data/test/dummy/config/letsencrypt_plugin.yml +7 -7
- data/test/dummy/config/routes.rb +1 -2
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/key/test_keyfile_1024.pem +15 -0
- data/test/dummy/key/test_keyfile_2048.pem +27 -0
- data/test/dummy/key/test_keyfile_4096.pem +51 -0
- data/test/dummy/key/test_keyfile_8192.pem +99 -0
- data/test/dummy/log/test.log +7718 -0
- data/test/le.sublime-project +8 -0
- data/test/le.sublime-workspace +686 -0
- data/test/letsencrypt_plugin_test.rb +79 -1
- data/test/test_helper.rb +27 -6
- metadata +126 -8
@@ -1,7 +1,85 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class LetsencryptPluginTest < ActiveSupport::TestCase
|
4
|
-
|
4
|
+
include Mocha::Integration::MiniTest
|
5
|
+
|
6
|
+
test 'truth' do
|
5
7
|
assert_kind_of Module, LetsencryptPlugin
|
6
8
|
end
|
9
|
+
|
10
|
+
test 'if_fail_when_private_key_is_nil' do
|
11
|
+
exception = assert_raises RuntimeError do
|
12
|
+
cg = LetsencryptPlugin::CertGenerator.new(private_key: nil)
|
13
|
+
cg.create_client
|
14
|
+
end
|
15
|
+
assert_equal 'Private key is not set, please check your config/letsencrypt_plugin.yml file!', exception.message
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'if_fail_when_private_key_is_empty' do
|
19
|
+
exception = assert_raises RuntimeError do
|
20
|
+
cg = LetsencryptPlugin::CertGenerator.new(private_key: '')
|
21
|
+
cg.create_client
|
22
|
+
end
|
23
|
+
assert_equal 'Private key is not set, please check your config/letsencrypt_plugin.yml file!', exception.message
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'if_fail_when_private_key_is_directory' do
|
27
|
+
options = { private_key: 'public' }
|
28
|
+
exception = assert_raises RuntimeError do
|
29
|
+
cg = LetsencryptPlugin::CertGenerator.new(options)
|
30
|
+
cg.create_client
|
31
|
+
end
|
32
|
+
assert_equal "Can not open private key: #{File.join(Rails.root, options[:private_key])}", exception.message
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'if_keysize_smaller_than_2048_is_invalid' do
|
36
|
+
exception = assert_raises RuntimeError do
|
37
|
+
cg = LetsencryptPlugin::CertGenerator.new(private_key: 'key/test_keyfile_1024.pem')
|
38
|
+
cg.create_client
|
39
|
+
end
|
40
|
+
assert_equal 'Invalid key size: 1024. Required size is between 2048 - 4096 bits', exception.message
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'if_keysize_greater_than_4096_is_invalid' do
|
44
|
+
exception = assert_raises RuntimeError do
|
45
|
+
cg = LetsencryptPlugin::CertGenerator.new(private_key: 'key/test_keyfile_8192.pem')
|
46
|
+
cg.create_client
|
47
|
+
end
|
48
|
+
assert_equal 'Invalid key size: 8192. Required size is between 2048 - 4096 bits', exception.message
|
49
|
+
end
|
50
|
+
|
51
|
+
test 'if_keysize_equal_4096_is_valid' do
|
52
|
+
assert_nothing_raised do
|
53
|
+
cg = LetsencryptPlugin::CertGenerator.new(private_key: 'key/test_keyfile_4096.pem')
|
54
|
+
assert !cg.nil?
|
55
|
+
cg.create_client
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'if_keysize_equal_2048_is_valid' do
|
60
|
+
assert_nothing_raised do
|
61
|
+
cg = LetsencryptPlugin::CertGenerator.new(private_key: 'key/test_keyfile_2048.pem')
|
62
|
+
assert !cg.nil?
|
63
|
+
cg.create_client
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# test 'register' do
|
68
|
+
# VCR.use_cassette('registration_agree_terms') do
|
69
|
+
# cg = LetsencryptPlugin::CertGenerator.new(private_key: 'key/test_keyfile_4096.pem',
|
70
|
+
# endpoint: 'https://acme-staging.api.letsencrypt.org',
|
71
|
+
# domain: 'example.com',
|
72
|
+
# email: 'foobarbaz@example.com')
|
73
|
+
# acme_client_mock = Acme::Client.new(private_key: cg.load_private_key, endpoint: cg.options[:endpoint])
|
74
|
+
# acme_client_auth_mock = Acme::Client::Resources::Authorization.new
|
75
|
+
# acme_client_auth_mock.stubs(:http01).returns(Acme::Client::Resources::Challenges::HTTP01)
|
76
|
+
# acme_client_cer_mock = Acme::Client::CertificateRequest.new
|
77
|
+
# acme_client_mock.stubs(:register).returns(Acme::Client::Resources::Registration)
|
78
|
+
# acme_client_mock.stubs(:new_certificate).with(acme_client_cer_mock).returns(nil)
|
79
|
+
# acme_client_mock.stubs(:authorize).returns(acme_client_auth_mock)
|
80
|
+
# cg.client = acme_client_mock
|
81
|
+
# assert !cg.nil?
|
82
|
+
# cg.generate_certificate
|
83
|
+
# end
|
84
|
+
# end
|
7
85
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require 'codeclimate-test-reporter'
|
2
2
|
CodeClimate::TestReporter.start
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
3
5
|
|
4
6
|
# Configure Rails Environment
|
5
|
-
ENV[
|
7
|
+
ENV['RAILS_ENV'] = 'test'
|
6
8
|
|
7
|
-
require File.expand_path(
|
8
|
-
ActiveRecord::Migrator.migrations_paths = [File.expand_path(
|
9
|
+
require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
|
10
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
|
9
11
|
ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
10
|
-
require
|
12
|
+
require 'rails/test_help'
|
13
|
+
require 'minitest/rails'
|
14
|
+
require 'minitest/reporters'
|
15
|
+
Minitest::Reporters.use!
|
11
16
|
|
12
17
|
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
13
18
|
# to be shown.
|
@@ -18,7 +23,23 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
18
23
|
|
19
24
|
# Load fixtures from the engine
|
20
25
|
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
21
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path(
|
26
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
|
22
27
|
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
23
28
|
ActiveSupport::TestCase.fixtures :all
|
24
29
|
end
|
30
|
+
|
31
|
+
# require 'webmock/minitest'
|
32
|
+
# MinitestVcr::Spec.configure!
|
33
|
+
|
34
|
+
# require 'vcr'
|
35
|
+
# VCR.configure do |c|
|
36
|
+
# c.cassette_library_dir = File.expand_path('../../test/cassettes', __FILE__)
|
37
|
+
# # c.configure_rspec_metadata!
|
38
|
+
# c.hook_into :webmock
|
39
|
+
# c.ignore_localhost = false
|
40
|
+
# c.default_cassette_options = { record: :once, match_requests_on: [:method, :host, :path] }
|
41
|
+
# c.allow_http_connections_when_no_cassette = false
|
42
|
+
# c.debug_logger = File.open(File.join(File.expand_path('../../test/cassettes', __FILE__), 'letsencrypt.log'), 'w')
|
43
|
+
# end
|
44
|
+
|
45
|
+
require 'mocha/mini_test'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: letsencrypt_plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukasz Gromanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: sqlite3
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,11 +108,79 @@ dependencies:
|
|
80
108
|
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
|
-
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: minitest-vcr
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: mocha
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: simplecov
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: 'letsencrypt-plugin is a Ruby on Rails helper for Let''s Encrypt service
|
84
182
|
for retrieving SSL certificates (without using sudo, like original letsencrypt client
|
85
|
-
does). It uses acme-client gem for communication with Let's Encrypt server.
|
86
|
-
gem requires database for storing challenge response - it could be any DB supported
|
87
|
-
by Ruby on Rails **
|
183
|
+
does). It uses acme-client gem for communication with Let''s Encrypt server. '
|
88
184
|
email:
|
89
185
|
- lgromanowski@gmail.com
|
90
186
|
executables: []
|
@@ -103,9 +199,17 @@ files:
|
|
103
199
|
- config/routes.rb
|
104
200
|
- db/migrate/20151206135029_create_letsencrypt_plugin_challenges.rb
|
105
201
|
- lib/letsencrypt_plugin.rb
|
202
|
+
- lib/letsencrypt_plugin/certificate_output.rb
|
203
|
+
- lib/letsencrypt_plugin/challenge_store.rb
|
204
|
+
- lib/letsencrypt_plugin/database_store.rb
|
106
205
|
- lib/letsencrypt_plugin/engine.rb
|
206
|
+
- lib/letsencrypt_plugin/file_output.rb
|
207
|
+
- lib/letsencrypt_plugin/file_store.rb
|
208
|
+
- lib/letsencrypt_plugin/heroku_output.rb
|
107
209
|
- lib/letsencrypt_plugin/version.rb
|
108
210
|
- lib/tasks/letsencrypt_plugin_tasks.rake
|
211
|
+
- test/cassettes/letsencrypt.log
|
212
|
+
- test/cassettes/registration_agree_terms.yml
|
109
213
|
- test/controllers/application_controller_test.rb
|
110
214
|
- test/dummy/README.rdoc
|
111
215
|
- test/dummy/Rakefile
|
@@ -140,6 +244,10 @@ files:
|
|
140
244
|
- test/dummy/config/secrets.yml
|
141
245
|
- test/dummy/db/schema.rb
|
142
246
|
- test/dummy/db/test.sqlite3
|
247
|
+
- test/dummy/key/test_keyfile_1024.pem
|
248
|
+
- test/dummy/key/test_keyfile_2048.pem
|
249
|
+
- test/dummy/key/test_keyfile_4096.pem
|
250
|
+
- test/dummy/key/test_keyfile_8192.pem
|
143
251
|
- test/dummy/log/development.log
|
144
252
|
- test/dummy/log/test.log
|
145
253
|
- test/dummy/public/404.html
|
@@ -147,6 +255,8 @@ files:
|
|
147
255
|
- test/dummy/public/500.html
|
148
256
|
- test/dummy/public/favicon.ico
|
149
257
|
- test/fixtures/letsencrypt_plugin/challenges.yml
|
258
|
+
- test/le.sublime-project
|
259
|
+
- test/le.sublime-workspace
|
150
260
|
- test/letsencrypt_plugin_test.rb
|
151
261
|
- test/models/letsencrypt_plugin/challenge_test.rb
|
152
262
|
- test/test_helper.rb
|
@@ -160,9 +270,9 @@ require_paths:
|
|
160
270
|
- lib
|
161
271
|
required_ruby_version: !ruby/object:Gem::Requirement
|
162
272
|
requirements:
|
163
|
-
- - "
|
273
|
+
- - "~>"
|
164
274
|
- !ruby/object:Gem::Version
|
165
|
-
version:
|
275
|
+
version: 2.1.0
|
166
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
277
|
requirements:
|
168
278
|
- - ">="
|
@@ -176,8 +286,12 @@ specification_version: 4
|
|
176
286
|
summary: Let's encrypt plugin for Ruby on Rails applications
|
177
287
|
test_files:
|
178
288
|
- test/controllers/application_controller_test.rb
|
289
|
+
- test/cassettes/letsencrypt.log
|
290
|
+
- test/cassettes/registration_agree_terms.yml
|
179
291
|
- test/test_helper.rb
|
292
|
+
- test/le.sublime-workspace
|
180
293
|
- test/letsencrypt_plugin_test.rb
|
294
|
+
- test/le.sublime-project
|
181
295
|
- test/models/letsencrypt_plugin/challenge_test.rb
|
182
296
|
- test/fixtures/letsencrypt_plugin/challenges.yml
|
183
297
|
- test/dummy/db/test.sqlite3
|
@@ -217,5 +331,9 @@ test_files:
|
|
217
331
|
- test/dummy/config/routes.rb
|
218
332
|
- test/dummy/log/test.log
|
219
333
|
- test/dummy/log/development.log
|
334
|
+
- test/dummy/key/test_keyfile_1024.pem
|
335
|
+
- test/dummy/key/test_keyfile_4096.pem
|
336
|
+
- test/dummy/key/test_keyfile_2048.pem
|
337
|
+
- test/dummy/key/test_keyfile_8192.pem
|
220
338
|
- test/dummy/config.ru
|
221
339
|
- test/dummy/README.rdoc
|