-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to enable accept-proxy via env (#38)
- Loading branch information
Showing
4 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
describe Kontena::Views::HttpIn do | ||
|
||
describe '.render' do | ||
context 'bind' do | ||
it 'bings to port 80' do | ||
output = described_class.render( | ||
format: :text, | ||
services: [] | ||
) | ||
expect(output.match(/bind \*:80/)).to be_truthy | ||
end | ||
|
||
it 'does not accept proxy protocol by default' do | ||
output = described_class.render( | ||
format: :text, | ||
services: [] | ||
) | ||
expect(output.match(/accept-proxy/)).to be_falsey | ||
end | ||
|
||
it 'accepts proxy protocol if env is set' do | ||
allow(ENV).to receive(:[]) | ||
allow(ENV).to receive(:[]).with('KONTENA_LB_ACCEPT_PROXY').and_return('true') | ||
output = described_class.render( | ||
format: :text, | ||
services: [] | ||
) | ||
expect(output.match(/accept-proxy/)).to be_truthy | ||
end | ||
|
||
it 'does not bind to port 443 by default' do | ||
output = described_class.render( | ||
format: :text, | ||
services: [] | ||
) | ||
expect(output.match(/bind \*:443/)).to be_falsey | ||
end | ||
|
||
it 'binds to port 443 if SSL certs exist' do | ||
allow(ENV).to receive(:[]) | ||
allow(ENV).to receive(:[]).with('SSL_CERTS').and_return('certs') | ||
output = described_class.render( | ||
format: :text, | ||
services: [] | ||
) | ||
expect(output.match(/bind \*:443/)).to be_truthy | ||
end | ||
|
||
it 'supports http2 if SSL certs exist' do | ||
allow(ENV).to receive(:[]) | ||
allow(ENV).to receive(:[]).with('SSL_CERTS').and_return('certs') | ||
output = described_class.render( | ||
format: :text, | ||
services: [] | ||
) | ||
expect(output.match(/alpn h2/)).to be_truthy | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters