core-var-include.t 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env perl
  2. BEGIN {
  3. # add current source dir to the include-path
  4. # we need this for make distcheck
  5. (my $srcdir = $0) =~ s,/[^/]+$,/,;
  6. unshift @INC, $srcdir;
  7. }
  8. use strict;
  9. use IO::Socket;
  10. use Test::More tests => 17;
  11. use LightyTest;
  12. my $tf = LightyTest->new();
  13. my $t;
  14. $ENV{"env_test"} = "good_env";
  15. $tf->{CONFIGFILE} = 'var-include.conf';
  16. ok($tf->start_proc == 0, "Starting lighttpd") or die();
  17. $t->{REQUEST} = ( "GET /index.html HTTP/1.0\r\nHost: www.example.org\r\n" );
  18. $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => "/redirect" } ];
  19. ok($tf->handle_http($t) == 0, 'basic test');
  20. my $myvar = "good";
  21. my $server_name = "test.example.org";
  22. my $mystr = "string";
  23. $mystr .= "_append";
  24. my $tests = {
  25. "include" => "/good_include",
  26. "concat" => "/good_" . "concat",
  27. "servername1" => "/good_" . $server_name,
  28. "servername2" => $server_name . "/good_",
  29. "servername3" => "/good_" . $server_name . "/",
  30. "var.myvar" => "/good_var_myvar" . $myvar,
  31. "myvar" => "/good_myvar" . $myvar,
  32. "env" => "/" . $ENV{"env_test"},
  33. "number1" => "/good_number" . "1",
  34. "number2" => "1" . "/good_number",
  35. "array_append" => "/good_array_append",
  36. "string_append" => "/good_" . $mystr,
  37. "number_append" => "/good_" . "2",
  38. "include_shell" => "/good_include_shell_" . "456"
  39. };
  40. foreach my $test (keys %{ $tests }) {
  41. my $expect = $tests->{$test};
  42. $t->{REQUEST} = ( <<EOF
  43. GET /$test HTTP/1.0
  44. Host: $server_name
  45. EOF
  46. );
  47. $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 301, 'Location' => $expect } ];
  48. ok($tf->handle_http($t) == 0, $test);
  49. }
  50. ok($tf->stop_proc == 0, "Stopping lighttpd");