download.t 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2006, 2011 Alex Schroeder <alex@gnuxs.org>
  2. #
  3. # This program is free software: you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation, either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. require 't/test.pl';
  15. package OddMuse;
  16. use Test::More tests => 13;
  17. AppendStringToFile($ConfigFile, "\$UploadAllowed = 1;\n");
  18. test_page_negative(get_page('HomePage'), 'logo');
  19. AppendStringToFile($ConfigFile, "\$LogoUrl = '/pic/logo.png';\n");
  20. xpath_test(get_page('HomePage'), '//a[@class="logo"]/img[@class="logo"][@src="/pic/logo.png"][@alt="[Home]"]');
  21. AppendStringToFile($ConfigFile, "\$LogoUrl = 'Logo';\n");
  22. xpath_test(get_page('HomePage'), '//a[@class="logo"]/img[@class="logo"][@src="Logo"][@alt="[Home]"]');
  23. update_page('Logo', "#FILE image/png\niVBORw0KGgoAAAA");
  24. # make sure we don't supply "content-type: image/png; charset=utf-8"
  25. {
  26. local $raw = 1;
  27. test_page_negative(get_page('action=download id=Logo'), 'charset');
  28. }
  29. xpath_test(get_page('HomePage'), '//a[@class="logo"]/img[@class="logo"][@src="http://localhost/wiki.pl/download/Logo"][@alt="[Home]"]');
  30. AppendStringToFile($ConfigFile, "\$UsePathInfo = 0;\n");
  31. xpath_test(get_page('HomePage'), '//a[@class="logo"]/img[@class="logo"][@src="http://localhost/wiki.pl?action=download;id=Logo"][@alt="[Home]"]');
  32. my $page = <<EOT;
  33. #FILE image/svg+xml gzip
  34. H4sICKlml04AA3Rlc3Quc3ZnADWOQQ6DIBBF956CzF6hdtMY0F1PYA9gCqUkdMbIRKSnLy76t/+/
  35. vK+n4xPF7rYUCA1cOgXC4ZNsQG/gMd/bG4jEC9olEjoDSDCNjU67F5XEZODNvA5S5py7fO1o87JX
  36. Ssm6gEacSVxiJW1Ia1zKEDAGdDDWUrM7WBzVW7XFQK/gv34RcpvC1w29WhnGeSMfyRZ2qOWJ1ROn
  37. Y2x+OvAf9cMAAAA=
  38. EOT
  39. test_page(update_page('Trogs', $page), 'This page does not exist');
  40. test_page($redirect, "Status: 415");
  41. AppendStringToFile($ConfigFile, q{push(@UploadTypes, "image/svg+xml");
  42. });
  43. test_page(update_page('Trogs', $page), 'contains an uploaded file');
  44. xpath_test(get_page('Trogs'),
  45. '//p/img[@class="upload"][@src="http://localhost/wiki.pl?action=download;id=Trogs"][@alt="Trogs"]');
  46. {
  47. local $raw = 1;
  48. $page = get_page('action=download id=Trogs');
  49. }
  50. test_page($page,
  51. 'Content-Type: image/svg\+xml',
  52. 'Content-encoding: gzip');
  53. like($page, qr/\r\n\r\n\x1f\x8b/, "gzipped data being served");