sslocal 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc5b3d34e3f44dc24ac304305a1cbfaf60888ff6496c90a1a4d6142ade226555
4
- data.tar.gz: db30eb94f25c9458c6eadb43c8c9fd8a80836bb6bced032647b3116c201a8961
3
+ metadata.gz: ecd8e2c6a6fcf172a27195a297a5dba1d2ebb9b6338b82504f9eb747f673d502
4
+ data.tar.gz: a7dacc865f49a8b78b5a5f2ada1589d31d9a15e9ec6eb7002ea1feba8496b4e3
5
5
  SHA512:
6
- metadata.gz: 04fc271a743ddc37ed8976d5900ae7ec3a7dde455af53d894571586b2f97e2ffc2167a72ec0c61c728efb43deaa151f51114f08c5267974e43e7ed6a620dd21a
7
- data.tar.gz: ea541b4193a031ac8b3bed4cfcb9a307c4e2a1b5a349f50ec68cadc327097f1c8994a4469245437fd9a016a77d21e38a3130cf3edcf70d65a518eecbf7a02db9
6
+ metadata.gz: ef7efe06ecb11fb8c676edac7e1d9515229ffe3b085ccfd4d5d620c0e0a2b28b4ffdbf5a27c930770ea75ffb73b5bfe3727420d4f11feeaed2ba63318b834e16
7
+ data.tar.gz: 64ffd6a1ae1136ac91f183578bdc6b2e77bfac5de8fc70b65e205f6b744372100657334b9c14e13c1041ca32a1714dfaa6821cf8dab57c56e82b5d14f2a1660b
@@ -5,6 +5,8 @@ require "sslocal/state"
5
5
  module SSLocal
6
6
  class Railtie < Rails::Railtie
7
7
  initializer "sslocal.set_up_webpacker", :before => "webpacker.proxy" do
8
+ next unless defined?(Webpacker)
9
+
8
10
  state = SSLocal::State.new(Rails.env.to_s)
9
11
  Webpacker.config.dev_server[:https] = true if state.enabled?
10
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sslocal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-25 00:00:00.000000000 Z
11
+ date: 2023-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -80,38 +80,29 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.8'
83
- description:
83
+ description:
84
84
  email:
85
85
  - pat@freelancing-gods.com
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".rspec"
91
- - ".rubocop.yml"
92
90
  - CODE_OF_CONDUCT.md
93
- - Gemfile
94
91
  - LICENSE.txt
95
92
  - README.md
96
- - Rakefile
97
- - bin/console
98
- - bin/setup
99
93
  - lib/puma/plugin/sslocal.rb
100
94
  - lib/sslocal.rb
101
95
  - lib/sslocal/puma_rebinder.rb
102
96
  - lib/sslocal/railtie.rb
103
97
  - lib/sslocal/state.rb
104
- - spec/puma/plugin/sslocal_spec.rb
105
- - spec/spec_helper.rb
106
- - spec/sslocal/puma_rebinder_spec.rb
107
- - spec/sslocal/state_spec.rb
108
98
  homepage: https://github.com/pat/sslocal-rb
109
99
  licenses:
110
100
  - MIT
111
101
  metadata:
112
102
  homepage_uri: https://github.com/pat/sslocal-rb
103
+ rubygems_mfa_required: 'true'
113
104
  source_code_uri: https://github.com/pat/sslocal-rb
114
- post_install_message:
105
+ post_install_message:
115
106
  rdoc_options: []
116
107
  require_paths:
117
108
  - lib
@@ -126,18 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
117
  - !ruby/object:Gem::Version
127
118
  version: '0'
128
119
  requirements: []
129
- rubygems_version: 3.1.2
130
- signing_key:
120
+ rubygems_version: 3.2.32
121
+ signing_key:
131
122
  specification_version: 4
132
123
  summary: Make local environment SSL as streamlined as possible.
133
- test_files:
134
- - bin/setup
135
- - bin/console
136
- - spec/spec_helper.rb
137
- - spec/puma/plugin/sslocal_spec.rb
138
- - spec/sslocal/state_spec.rb
139
- - spec/sslocal/puma_rebinder_spec.rb
140
- - ".rspec"
141
- - ".rubocop.yml"
142
- - Gemfile
143
- - Rakefile
124
+ test_files: []
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- inherit_from:
2
- - https://gist.githubusercontent.com/pat/ba3b8ffb1901bfe5439b460943b6b019/raw/.rubocop.yml
3
- - https://gist.githubusercontent.com/pat/ba3b8ffb1901bfe5439b460943b6b019/raw/performance.yml
4
-
5
- require:
6
- - rubocop-packaging
7
- - rubocop-performance
8
-
9
- AllCops:
10
- TargetRubyVersion: 2.7
11
-
12
- Gemspec/RequiredRubyVersion:
13
- Enabled: false
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec
6
-
7
- gem "rake", "~> 12.0"
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => :spec
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "sslocal"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "puma/plugin/sslocal"
4
-
5
- RSpec.describe Puma::Plugin::SSLocal do
6
- it "responds to initialize without an argument" do
7
- expect { described_class.new }.to_not raise_error
8
- end
9
-
10
- it "responds to initialize with an argument" do
11
- expect { described_class.new double }.to_not raise_error
12
- end
13
-
14
- it "responds to config" do
15
- expect { subject.config double }.to_not raise_error
16
- end
17
-
18
- describe "#start" do
19
- let(:launcher) { double(:launcher, :config => configuration) }
20
- let(:configuration) { double(:configuration) }
21
- let(:user_config) { double }
22
- let(:file_config) { double }
23
- let(:default_config) { double }
24
- let(:rebinder) { double(:rebinder, :call => nil) }
25
-
26
- before :each do
27
- allow(configuration).to receive(:configure).
28
- and_yield(user_config, file_config, default_config)
29
-
30
- stub_const("SSLocal::PumaRebinder", rebinder)
31
- end
32
-
33
- it "rebinds the user configuration" do
34
- subject.start(launcher)
35
-
36
- expect(rebinder).to have_received(:call).with(user_config)
37
- end
38
-
39
- it "rebinds the file configuration" do
40
- subject.start(launcher)
41
-
42
- expect(rebinder).to have_received(:call).with(file_config)
43
- end
44
-
45
- it "rebinds the default configuration" do
46
- subject.start(launcher)
47
-
48
- expect(rebinder).to have_received(:call).with(default_config)
49
- end
50
- end
51
- end
data/spec/spec_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "sslocal"
4
-
5
- RSpec.configure do |config|
6
- # Enable flags like --only-failures and --next-failure
7
- config.example_status_persistence_file_path = ".rspec_status"
8
-
9
- # Disable RSpec exposing methods globally on `Module` and `main`
10
- config.disable_monkey_patching!
11
-
12
- config.expect_with :rspec do |c|
13
- c.syntax = :expect
14
- end
15
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "sslocal/puma_rebinder"
4
-
5
- RSpec.describe SSLocal::PumaRebinder do
6
- let(:dsl) do
7
- double(:dsl, :clear_binds! => nil, :ssl_bind => nil, :bind => nil)
8
- end
9
- let(:binds) { ["tcp://0.0.0.0:3000"] }
10
- let(:state) do
11
- double(:state, :enabled? => true, :key_path => "my.key",
12
- :cert_path => "my.crt")
13
- end
14
-
15
- subject { described_class }
16
-
17
- before :each do
18
- allow(dsl).to receive(:get).with(:binds).and_return(binds)
19
- allow(dsl).to receive(:get).with(:environment).and_return("test")
20
-
21
- allow(SSLocal::State).to receive(:new).and_return(state)
22
- end
23
-
24
- it "does nothing if there are no binds" do
25
- allow(dsl).to receive(:get).with(:binds).and_return(nil)
26
-
27
- subject.call dsl
28
-
29
- expect(dsl).to_not have_received(:clear_binds!)
30
- end
31
-
32
- it "loads the state for the supplied environment" do
33
- subject.call dsl
34
-
35
- expect(SSLocal::State).to have_received(:new).with("test")
36
- end
37
-
38
- it "does nothing if the state is disabled" do
39
- allow(state).to receive(:enabled?).and_return(false)
40
-
41
- subject.call dsl
42
-
43
- expect(dsl).to_not have_received(:clear_binds!)
44
- end
45
-
46
- it "replaces TCP bindings with SSL" do
47
- subject.call dsl
48
-
49
- expect(dsl).to have_received(:ssl_bind).with(
50
- "0.0.0.0", "3000", :key => "my.key", :cert => "my.crt"
51
- )
52
- end
53
-
54
- it "does not modify unix bindings" do
55
- allow(dsl).to receive(:get).with(:binds).and_return(["unix:///path.socket"])
56
-
57
- subject.call dsl
58
-
59
- expect(dsl).to have_received(:bind).with("unix:///path.socket")
60
- end
61
-
62
- it "uses 0.0.0.0 if the binding does not specify a host" do
63
- allow(dsl).to receive(:get).with(:binds).and_return(["tcp://:4000"])
64
-
65
- subject.call dsl
66
-
67
- expect(dsl).to have_received(:ssl_bind).with(
68
- "0.0.0.0", "4000", :key => "my.key", :cert => "my.crt"
69
- )
70
- end
71
-
72
- it "does not modify any bindings if there's an unknown TCP format" do
73
- allow(dsl).to receive(:get).with(:binds).and_return(["tcp://foo"])
74
-
75
- subject.call dsl
76
-
77
- expect(dsl).to have_received(:bind).with("tcp://foo")
78
- end
79
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "sslocal/state"
4
-
5
- RSpec.describe SSLocal::State do
6
- subject { described_class.new "test" }
7
-
8
- before :each do
9
- allow(File).to receive(:exist?).and_return(false)
10
- end
11
-
12
- describe "#enabled?" do
13
- it "returns true if both files exist" do
14
- allow(File).to receive(:exist?).with(
15
- File.expand_path("config/certificates/test.key")
16
- ).and_return(true)
17
-
18
- allow(File).to receive(:exist?).with(
19
- File.expand_path("config/certificates/test.crt")
20
- ).and_return(true)
21
-
22
- expect(subject).to be_enabled
23
- end
24
-
25
- it "returns false if only the key file exists" do
26
- allow(File).to receive(:exist?).with(
27
- File.expand_path("config/certificates/test.key")
28
- ).and_return(true)
29
-
30
- allow(File).to receive(:exist?).with(
31
- File.expand_path("config/certificates/test.crt")
32
- ).and_return(false)
33
-
34
- expect(subject).to_not be_enabled
35
- end
36
-
37
- it "returns false if only the cert file exists" do
38
- allow(File).to receive(:exist?).with(
39
- File.expand_path("config/certificates/test.key")
40
- ).and_return(false)
41
-
42
- allow(File).to receive(:exist?).with(
43
- File.expand_path("config/certificates/test.crt")
44
- ).and_return(true)
45
-
46
- expect(subject).to_not be_enabled
47
- end
48
-
49
- it "returns false if neither file exists" do
50
- allow(File).to receive(:exist?).with(
51
- File.expand_path("config/certificates/test.key")
52
- ).and_return(false)
53
-
54
- allow(File).to receive(:exist?).with(
55
- File.expand_path("config/certificates/test.crt")
56
- ).and_return(false)
57
-
58
- expect(subject).to_not be_enabled
59
- end
60
- end
61
- end