cert_file_maker 0.0.5 → 0.0.6

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +138 -0
  5. data/LICENSE +21 -0
  6. data/README.md +44 -0
  7. data/cert_file_maker.gemspec +18 -0
  8. data/lib/cert_file_maker/railtie.rb +11 -0
  9. data/lib/generator.rb +11 -0
  10. data/lib/version.rb +3 -0
  11. data/test/cert_file_maker_test.rb +54 -0
  12. data/test/rails_app/Rakefile +6 -0
  13. data/test/rails_app/app/assets/config/manifest.js +3 -0
  14. data/test/rails_app/app/assets/images/.keep +0 -0
  15. data/test/rails_app/app/assets/javascripts/application.js +16 -0
  16. data/test/rails_app/app/assets/javascripts/cable.js +13 -0
  17. data/test/rails_app/app/assets/javascripts/channels/.keep +0 -0
  18. data/test/rails_app/app/assets/stylesheets/application.css +15 -0
  19. data/test/rails_app/app/channels/application_cable/channel.rb +4 -0
  20. data/test/rails_app/app/channels/application_cable/connection.rb +4 -0
  21. data/test/rails_app/app/controllers/application_controller.rb +2 -0
  22. data/test/rails_app/app/controllers/concerns/.keep +0 -0
  23. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  24. data/test/rails_app/app/jobs/application_job.rb +2 -0
  25. data/test/rails_app/app/mailers/application_mailer.rb +4 -0
  26. data/test/rails_app/app/models/application_record.rb +3 -0
  27. data/test/rails_app/app/models/concerns/.keep +0 -0
  28. data/test/rails_app/app/views/layouts/application.html.erb +15 -0
  29. data/test/rails_app/app/views/layouts/mailer.html.erb +13 -0
  30. data/test/rails_app/app/views/layouts/mailer.text.erb +1 -0
  31. data/test/rails_app/bin/bundle +3 -0
  32. data/test/rails_app/bin/rails +9 -0
  33. data/test/rails_app/bin/rake +9 -0
  34. data/test/rails_app/bin/setup +36 -0
  35. data/test/rails_app/bin/spring +17 -0
  36. data/test/rails_app/bin/update +31 -0
  37. data/test/rails_app/bin/yarn +11 -0
  38. data/test/rails_app/config.ru +5 -0
  39. data/test/rails_app/config/application.rb +19 -0
  40. data/test/rails_app/config/boot.rb +3 -0
  41. data/test/rails_app/config/cable.yml +10 -0
  42. data/test/rails_app/config/cert_file_maker.yml +1 -0
  43. data/test/rails_app/config/credentials.yml.enc +1 -0
  44. data/test/rails_app/config/database.yml +25 -0
  45. data/test/rails_app/config/environment.rb +6 -0
  46. data/test/rails_app/config/environments/development.rb +61 -0
  47. data/test/rails_app/config/environments/production.rb +94 -0
  48. data/test/rails_app/config/environments/test.rb +46 -0
  49. data/test/rails_app/config/initializers/application_controller_renderer.rb +8 -0
  50. data/test/rails_app/config/initializers/assets.rb +14 -0
  51. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  52. data/test/rails_app/config/initializers/content_security_policy.rb +25 -0
  53. data/test/rails_app/config/initializers/cookies_serializer.rb +5 -0
  54. data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
  55. data/test/rails_app/config/initializers/inflections.rb +16 -0
  56. data/test/rails_app/config/initializers/mime_types.rb +4 -0
  57. data/test/rails_app/config/initializers/wrap_parameters.rb +14 -0
  58. data/test/rails_app/config/locales/en.yml +33 -0
  59. data/test/rails_app/config/puma.rb +34 -0
  60. data/test/rails_app/config/routes.rb +3 -0
  61. data/test/rails_app/config/spring.rb +6 -0
  62. data/test/rails_app/config/storage.yml +34 -0
  63. data/test/rails_app/db/seeds.rb +7 -0
  64. data/test/rails_app/lib/assets/.keep +0 -0
  65. data/test/rails_app/lib/tasks/.keep +0 -0
  66. data/test/rails_app/log/development.log +0 -0
  67. data/test/rails_app/log/test.log +0 -0
  68. data/test/rails_app/package.json +5 -0
  69. data/test/rails_app/public/404.html +67 -0
  70. data/test/rails_app/public/422.html +67 -0
  71. data/test/rails_app/public/500.html +66 -0
  72. data/test/rails_app/public/apple-touch-icon-precomposed.png +0 -0
  73. data/test/rails_app/public/apple-touch-icon.png +0 -0
  74. data/test/rails_app/public/favicon.ico +0 -0
  75. data/test/rails_app/public/robots.txt +1 -0
  76. data/test/rails_app/tmp/development_secret.txt +1 -0
  77. data/test/rails_cert_file_maker_test.rb +82 -0
  78. data/test/test_helper.rb +6 -0
  79. metadata +78 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0bc0c44bccfba661da23e3ab7e1ad7cd3c181ae
4
- data.tar.gz: d136849acb5aa3977b8f7f7f3278ee120391a682
3
+ metadata.gz: 6794fc89fd41f986126cfe360baa902c02f42933
4
+ data.tar.gz: de9e4eac3846033155d016a75e2f274c8dbfa442
5
5
  SHA512:
6
- metadata.gz: dae8f8992b382c9a0919dfd11a1a0cf6e007c9b092beb96ec63f500d54a667aa2788c0efa7484269af1bdf5dc6c11699c41e347bd1712f2d86992dd02e28430c
7
- data.tar.gz: 478f1528eb9d2c5d8ac4e5d07492a1f666b6d1f0dd31b3a622c7b5bb093c40c4de013ea3fbae8729999ed0c58f1193f03e2a7ead4fbef32500699d26aab16104
6
+ metadata.gz: b3affa5364af98651e7203f3fa278e48c0ee03cdef318983378cca72e9423ea43946373273036e59cc9f2752aee027091dacbc95dd2cf9799b588137f3dc2c97
7
+ data.tar.gz: ced631a4a2e4f7234b3b7254171f79b750d46a77bab5c5fb781958da1bea232d8cc7b2cd4b9abcb5865e14db03d7be6aff795a9253bfb8ab4da0b758fc01be60
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.swp
2
+ .bundle/*
3
+ test/rails_app/.bundle/*
4
+ test/rails_app/config/master.key
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rails', '~> 5.2'
7
+ gem "ffi", ">= 1.9.24"
8
+ end
9
+
10
+ group :test do
11
+ gem 'rails', '~> 5.2'
12
+ gem "ffi", ">= 1.9.24"
13
+ gem 'listen'
14
+ gem 'sqlite3'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,138 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cert_file_maker (0.0.4)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (5.2.3)
10
+ actionpack (= 5.2.3)
11
+ nio4r (~> 2.0)
12
+ websocket-driver (>= 0.6.1)
13
+ actionmailer (5.2.3)
14
+ actionpack (= 5.2.3)
15
+ actionview (= 5.2.3)
16
+ activejob (= 5.2.3)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 2.0)
19
+ actionpack (5.2.3)
20
+ actionview (= 5.2.3)
21
+ activesupport (= 5.2.3)
22
+ rack (~> 2.0)
23
+ rack-test (>= 0.6.3)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
+ actionview (5.2.3)
27
+ activesupport (= 5.2.3)
28
+ builder (~> 3.1)
29
+ erubi (~> 1.4)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
+ activejob (5.2.3)
33
+ activesupport (= 5.2.3)
34
+ globalid (>= 0.3.6)
35
+ activemodel (5.2.3)
36
+ activesupport (= 5.2.3)
37
+ activerecord (5.2.3)
38
+ activemodel (= 5.2.3)
39
+ activesupport (= 5.2.3)
40
+ arel (>= 9.0)
41
+ activestorage (5.2.3)
42
+ actionpack (= 5.2.3)
43
+ activerecord (= 5.2.3)
44
+ marcel (~> 0.3.1)
45
+ activesupport (5.2.3)
46
+ concurrent-ruby (~> 1.0, >= 1.0.2)
47
+ i18n (>= 0.7, < 2)
48
+ minitest (~> 5.1)
49
+ tzinfo (~> 1.1)
50
+ arel (9.0.0)
51
+ builder (3.2.3)
52
+ concurrent-ruby (1.1.5)
53
+ crass (1.0.4)
54
+ erubi (1.8.0)
55
+ ffi (1.10.0)
56
+ globalid (0.4.2)
57
+ activesupport (>= 4.2.0)
58
+ i18n (1.6.0)
59
+ concurrent-ruby (~> 1.0)
60
+ listen (3.1.5)
61
+ rb-fsevent (~> 0.9, >= 0.9.4)
62
+ rb-inotify (~> 0.9, >= 0.9.7)
63
+ ruby_dep (~> 1.2)
64
+ loofah (2.2.3)
65
+ crass (~> 1.0.2)
66
+ nokogiri (>= 1.5.9)
67
+ mail (2.7.1)
68
+ mini_mime (>= 0.1.1)
69
+ marcel (0.3.3)
70
+ mimemagic (~> 0.3.2)
71
+ method_source (0.9.2)
72
+ mimemagic (0.3.3)
73
+ mini_mime (1.0.1)
74
+ mini_portile2 (2.4.0)
75
+ minitest (5.11.3)
76
+ nio4r (2.3.1)
77
+ nokogiri (1.10.2)
78
+ mini_portile2 (~> 2.4.0)
79
+ rack (2.0.7)
80
+ rack-test (1.1.0)
81
+ rack (>= 1.0, < 3)
82
+ rails (5.2.3)
83
+ actioncable (= 5.2.3)
84
+ actionmailer (= 5.2.3)
85
+ actionpack (= 5.2.3)
86
+ actionview (= 5.2.3)
87
+ activejob (= 5.2.3)
88
+ activemodel (= 5.2.3)
89
+ activerecord (= 5.2.3)
90
+ activestorage (= 5.2.3)
91
+ activesupport (= 5.2.3)
92
+ bundler (>= 1.3.0)
93
+ railties (= 5.2.3)
94
+ sprockets-rails (>= 2.0.0)
95
+ rails-dom-testing (2.0.3)
96
+ activesupport (>= 4.2.0)
97
+ nokogiri (>= 1.6)
98
+ rails-html-sanitizer (1.0.4)
99
+ loofah (~> 2.2, >= 2.2.2)
100
+ railties (5.2.3)
101
+ actionpack (= 5.2.3)
102
+ activesupport (= 5.2.3)
103
+ method_source
104
+ rake (>= 0.8.7)
105
+ thor (>= 0.19.0, < 2.0)
106
+ rake (12.3.2)
107
+ rb-fsevent (0.10.3)
108
+ rb-inotify (0.10.0)
109
+ ffi (~> 1.0)
110
+ ruby_dep (1.5.0)
111
+ sprockets (3.7.2)
112
+ concurrent-ruby (~> 1.0)
113
+ rack (> 1, < 3)
114
+ sprockets-rails (3.2.1)
115
+ actionpack (>= 4.0)
116
+ activesupport (>= 4.0)
117
+ sprockets (>= 3.0.0)
118
+ sqlite3 (1.4.0)
119
+ thor (0.20.3)
120
+ thread_safe (0.3.6)
121
+ tzinfo (1.2.5)
122
+ thread_safe (~> 0.1)
123
+ websocket-driver (0.7.0)
124
+ websocket-extensions (>= 0.1.0)
125
+ websocket-extensions (0.1.3)
126
+
127
+ PLATFORMS
128
+ ruby
129
+
130
+ DEPENDENCIES
131
+ cert_file_maker!
132
+ ffi (>= 1.9.24)
133
+ listen
134
+ rails (~> 5.2)
135
+ sqlite3
136
+
137
+ BUNDLED WITH
138
+ 1.17.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Bernardo Galindo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Cert File Maker
2
+
3
+ [Cert File Maker] is a tool to generate pem files (certificates, public keys)
4
+ files from environment variables.
5
+
6
+ ## Install
7
+ Add `cert_file_maker` to your Gemfile
8
+
9
+ ```ruby
10
+ gem 'cert_file_maker'
11
+ ```
12
+
13
+ Add `cert_file_maker.yml` config file to your `config` folder. Config folder
14
+ should live inside application root.
15
+
16
+
17
+ ```ruby
18
+ # config/cert_file_maker.yml
19
+ cert_names: 'PRIVATE_KEY,CERT'
20
+ ```
21
+ #### Important cert_names
22
+ This variable should contain the exac name of your credential,
23
+ environment_variables.
24
+
25
+ The certification file should contain the `cert_names` key with a string of
26
+ names separeted by a comma.
27
+
28
+
29
+ ### Ruby on Rails
30
+
31
+ Using ruby rails should be as easy as installed the gem. Because, this contains
32
+ a railtie class that appended before active_record establish connection.
33
+
34
+ ### Pure Ruby App
35
+
36
+ You should require the 'cert_file_maker' and validate and generate files
37
+
38
+ ```ruby
39
+ require 'cert_file_maker'
40
+ # validate
41
+ CertFileMaker.validate
42
+ # generate
43
+ CertFileMaker.generate
44
+ ```
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require_relative 'lib/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.platform = Gem::Platform::RUBY
6
+ s.name = 'cert_file_maker'
7
+ s.version = CertFileMaker::VERSION
8
+ s.summary = 'Generate certification file'
9
+ s.description = 'Railties app to generate certification files'
10
+
11
+ s.license = 'MIT'
12
+
13
+ s.author = 'Bernardo Galindo'
14
+ s.email = 'bernardo466@gmail.com'
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.require_path = 'lib'
18
+ end
@@ -0,0 +1,11 @@
1
+ module CertFileMaker
2
+ class Railtie < Rails::Railtie
3
+ config.before_configuration do
4
+ CertFileMaker.validate
5
+ end
6
+
7
+ initializer 'cert_file_maker.generate', before: 'active_record.initialize_database' do
8
+ CertFileMaker.generate
9
+ end
10
+ end
11
+ end
data/lib/generator.rb ADDED
@@ -0,0 +1,11 @@
1
+ module CertFileMaker
2
+ class Generator
3
+ def initialize(config)
4
+ begin
5
+ @config = config.fetch(:cert_names)
6
+ rescue KeyError => e
7
+
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module CertFileMaker
2
+ VERSION = '0.0.6'.freeze
3
+ end
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+
3
+ class TestCertFileMaker < Minitest::Test
4
+ def setup
5
+ @init = Dir.pwd
6
+ @test_obj = CertFileMaker
7
+ Dir.chdir('test')
8
+ end
9
+
10
+ def teardown
11
+ Dir.chdir(@init)
12
+ end
13
+
14
+ def test_that_config_file_is_required
15
+ assert_raises(StandardError){ @test_obj.validate }
16
+ end
17
+
18
+ def test_that_require_cert_names
19
+ file = File.open('config/cert_file_maker.yml', 'w+') do |f|
20
+ f.write "cert_name: 'test1,test2'"
21
+ end
22
+ assert_raises(KeyError) do
23
+ @test_obj.validate
24
+ end
25
+ File.delete('config/cert_file_maker.yml')
26
+ end
27
+
28
+ def test_that_generate_requires_env_vars
29
+ file = File.open('config/cert_file_maker.yml', 'w+') do |f|
30
+ f.write "cert_names: 'test1,test2'"
31
+ end
32
+ @test_obj.validate
33
+ assert_raises(KeyError) do
34
+ @test_obj.generate
35
+ end
36
+ File.delete('config/cert_file_maker.yml')
37
+ end
38
+
39
+ def test_that_generate_pem_files
40
+ file = File.open('config/cert_file_maker.yml', 'w+') do |f|
41
+ f.write "cert_names: 'test1,test2'"
42
+ end
43
+ @test_obj.validate
44
+ ENV.stub :fetch, 'random cert' do
45
+ @test_obj.generate
46
+ assert File.exists?('test1.pem')
47
+ assert File.exists?('test2.pem')
48
+ end
49
+ File.delete('test1.pem')
50
+ File.delete('test2.pem')
51
+ File.delete('config/cert_file_maker.yml')
52
+ end
53
+ end
54
+
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require rails-ujs
14
+ //= require activestorage
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end