-
Notifications
You must be signed in to change notification settings - Fork 20
Net: work around handling of empty PathAndQuery in http.
#98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,156 @@ | ||
| #!/usr/bin/perl | ||
|
|
||
| # Copyright (c) F5, Inc. | ||
| # | ||
| # This source code is licensed under the Apache License, Version 2.0 license | ||
| # found in the LICENSE file in the root directory of this source tree. | ||
|
|
||
| # Tests for ACME client: redirect and pathless URI handling. | ||
|
|
||
| ############################################################################### | ||
|
|
||
| use warnings; | ||
| use strict; | ||
|
|
||
| use Test::More; | ||
|
|
||
| BEGIN { use FindBin; chdir($FindBin::Bin); } | ||
|
|
||
| use lib 'lib'; | ||
| use Test::Nginx; | ||
| use Test::Nginx::ACME; | ||
| use Test::Nginx::DNS; | ||
|
|
||
| ############################################################################### | ||
|
|
||
| select STDERR; $| = 1; | ||
| select STDOUT; $| = 1; | ||
|
|
||
| my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite socket_ssl/) | ||
| ->has_daemon('openssl'); | ||
|
|
||
| $t->write_file_expand('nginx.conf', <<'EOF'); | ||
|
|
||
| %%TEST_GLOBALS%% | ||
|
|
||
| daemon off; | ||
|
|
||
| events { | ||
| } | ||
|
|
||
| http { | ||
| %%TEST_GLOBALS_HTTP%% | ||
|
|
||
| resolver 127.0.0.1:%%PORT_8980_UDP%%; | ||
|
|
||
| acme_issuer default { | ||
| uri https://acme.test:%%PORT_8999%%; | ||
| ssl_trusted_certificate acme.test.crt; | ||
| state_path %%TESTDIR%%; | ||
| accept_terms_of_service; | ||
| } | ||
|
|
||
| server { | ||
| listen 127.0.0.1:8080; | ||
| server_name example.test; | ||
| } | ||
|
|
||
| server { | ||
| listen 127.0.0.1:8443 ssl; | ||
| server_name example.test; | ||
|
|
||
| acme_certificate default; | ||
|
|
||
| ssl_certificate $acme_certificate; | ||
| ssl_certificate_key $acme_certificate_key; | ||
| } | ||
|
|
||
| server { | ||
| listen 127.0.0.1:8999 ssl; | ||
| server_name acme.test; | ||
|
|
||
| absolute_redirect off; | ||
|
|
||
| ssl_certificate acme.test.crt; | ||
| ssl_certificate_key acme.test.key; | ||
|
|
||
| location / { | ||
| return 301 /dir; | ||
| } | ||
|
|
||
| location /dir { | ||
| return 302 https://acme.test:%%PORT_9000%%/dir; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| EOF | ||
|
|
||
| $t->write_file('openssl.conf', <<EOF); | ||
| [ req ] | ||
| default_bits = 2048 | ||
| encrypt_key = no | ||
| distinguished_name = req_distinguished_name | ||
| [ req_distinguished_name ] | ||
| EOF | ||
|
|
||
| my $d = $t->testdir(); | ||
|
|
||
| foreach my $name ('acme.test') { | ||
| system('openssl req -x509 -new ' | ||
| . "-config $d/openssl.conf -subj /CN=$name/ " | ||
| . "-out $d/$name.crt -keyout $d/$name.key " | ||
| . ">>$d/openssl.out 2>&1") == 0 | ||
| or die "Can't create certificate for $name: $!\n"; | ||
| } | ||
|
|
||
| my $dp = port(8980, udp=>1); | ||
| my @dc = ( | ||
| { name => 'acme.test', A => '127.0.0.1' }, | ||
| { name => 'example.test', A => '127.0.0.1' } | ||
| ); | ||
|
|
||
| my $acme = Test::Nginx::ACME->new($t, port(9000), port(9001), | ||
| $t->testdir . '/acme.test.crt', | ||
| $t->testdir . '/acme.test.key', | ||
| http_port => port(8080), | ||
| dns_port => $dp, | ||
| nosleep => 1, | ||
| ); | ||
|
|
||
| $t->run_daemon(\&Test::Nginx::DNS::dns_test_daemon, $t, $dp, \@dc); | ||
| $t->waitforfile($t->testdir . '/' . $dp); | ||
|
|
||
| $t->run_daemon(\&Test::Nginx::ACME::acme_test_daemon, $t, $acme); | ||
| $t->waitforsocket('127.0.0.1:' . $acme->port()); | ||
| $t->write_file('acme-root.crt', $acme->trusted_ca()); | ||
|
|
||
| $t->write_file('index.html', 'SUCCESS'); | ||
| $t->plan(1)->run(); | ||
|
|
||
| ############################################################################### | ||
|
|
||
| $acme->wait_certificate('example.test') or die "no certificate"; | ||
|
|
||
| like(get(8443, 'example.test', 'acme-root'), qr/SUCCESS/, 'tls request'); | ||
|
|
||
| ############################################################################### | ||
|
|
||
| sub get { | ||
| my ($port, $host, $ca) = @_; | ||
|
|
||
| $ca = undef if $IO::Socket::SSL::VERSION < 2.062 | ||
| || !eval { Net::SSLeay::X509_V_FLAG_PARTIAL_CHAIN() }; | ||
|
|
||
| http_get('/', | ||
| PeerAddr => '127.0.0.1:' . port($port), | ||
| SSL => 1, | ||
| $ca ? ( | ||
| SSL_ca_file => "$d/$ca.crt", | ||
| SSL_verifycn_name => $host, | ||
| SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_PEER(), | ||
| ) : () | ||
| ); | ||
| } | ||
|
|
||
| ############################################################################### |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.