rc.t 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. # Copyright (C) 2006–20015 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. require 't/test.pl';
  16. package OddMuse;
  17. use Test::More tests => 93;
  18. # Make sure Days is numeric
  19. test_page(get_page(qw(action=rc days=WTF)), 'Updates in the last 30 days');
  20. # Check the More... links
  21. my $more = xpath_test(get_page('action=rc days=3'),
  22. '//a[text()="More..."]/attribute::href');
  23. my ($from, $upto) = $more =~ /action=rc;from=(\d+);upto=(\d+)/;
  24. is($upto - $from, 3 * 24 * 60 * 60, 'More... link is for 3 days');
  25. # Click it once...
  26. $more = xpath_test(get_page("action=rc from=$from upto=$upto"),
  27. '//a[text()="More..."]/attribute::href');
  28. ($from, $upto) = $more =~ /action=rc;from=(\d+);upto=(\d+)/;
  29. is($upto - $from, 3 * 24 * 60 * 60, 'Next More... link is for 3 days, too');
  30. # Click it twice...
  31. $more = xpath_test(get_page("action=rc from=$from upto=$upto"),
  32. '//a[text()="More..."]/attribute::href');
  33. ($from, $upto) = $more =~ /action=rc;from=(\d+);upto=(\d+)/;
  34. is($upto - $from, 3 * 24 * 60 * 60, 'Next More... link is for 3 days, too');
  35. # Make sure it handles empty log files and very old log files with
  36. # nothing appropriate in them.
  37. test_page(get_page('action=rc raw=1'), 'title: Wiki');
  38. # ts, id, minor, summary, host, username, revision, languages, cluster
  39. WriteStringToFile($RcFile, "1${FS}test${FS}${FS}test${FS}127.0.0.1${FS}${FS}1${FS}${FS}\n");
  40. test_page_negative(get_page('action=rc raw=1'), 'title: test');
  41. test_page(get_page('action=rc raw=1 from=1'), 'title: Wiki', 'title: test',
  42. 'description: test', 'generator: 127.0.0.1',
  43. 'link: http://localhost/wiki.pl/test',
  44. 'last-modified: 1970-01-01T00:00Z', 'revision: 1');
  45. test_page(get_page('action=maintain'),
  46. 'Moving part of the RecentChanges log file',
  47. 'Moving 1 log entries');
  48. # make sure it was anonymized
  49. test_page(get_page('action=rc raw=1 from=1'), 'title: Wiki', 'title: test',
  50. 'description: test', 'generator: Anonymous',
  51. 'link: http://localhost/wiki.pl/test',
  52. 'last-modified: 1970-01-01T00:00Z', 'revision: 1');
  53. # Test that newlines are in fact stripped
  54. update_page('Newlines', 'Some text', "Summary\nwith newlines",
  55. '', '', "'username=my%0aname'");
  56. $page = get_page('action=rc raw=1');
  57. test_page($page, 'title: Newlines',
  58. 'description: Summary with newlines');
  59. test_page_negative($page, 'generator: my');
  60. # More elaborate tests for the filters
  61. $host1 = 'tisch';
  62. $host2 = 'stuhl';
  63. $ENV{'REMOTE_ADDR'} = $host1;
  64. update_page('Mendacibombus', 'This is the place.', 'samba', 0, 0,
  65. ('username=berta'));
  66. update_page('Bombia', 'This is the time.', 'tango', 0, 0,
  67. ('username=alex'));
  68. $ENV{'REMOTE_ADDR'} = $host2;
  69. update_page('Confusibombus', 'This is order.', 'ballet', 1, 0,
  70. ('username=berta'));
  71. update_page('Mucidobombus', 'This is chaos.', 'tarantella', 0, 0,
  72. ('username=alex'));
  73. @Positives = split('\n',<<'EOT');
  74. for time\|place only
  75. Mendacibombus.*samba
  76. Bombia.*tango
  77. EOT
  78. @Negatives = split('\n',<<'EOT');
  79. Confusibombus
  80. ballet
  81. Mucidobombus
  82. tarantella
  83. EOT
  84. $page = get_page('action=rc rcfilteronly=time\|place');
  85. test_page($page, @Positives);
  86. test_page_negative($page, @Negatives);
  87. @Positives = qw(Mucidobombus.*tarantella);
  88. @Negatives = split('\n',<<'EOT');
  89. Mendacibombus
  90. samba
  91. Bombia
  92. tango
  93. Confusibombus
  94. ballet
  95. EOT
  96. $page = get_page('action=rc rcfilteronly=order\|chaos');
  97. test_page($page, @Positives);
  98. test_page_negative($page, @Negatives);
  99. @Positives = ();
  100. @Negatives = split('\n',<<'EOT');
  101. Mucidobombus
  102. tarantella
  103. Mendacibombus
  104. samba
  105. Bombia
  106. tango
  107. Confusibombus
  108. ballet
  109. EOT
  110. $page = get_page('action=rc rcfilteronly=order%20chaos');
  111. test_page($page, @Positives);
  112. test_page_negative($page, @Negatives);
  113. @Positives = qw(Mendacibombus.*samba Bombia.*tango);
  114. @Negatives = split('\n',<<'EOT');
  115. Mucidobombus
  116. tarantella
  117. Confusibombus
  118. ballet
  119. EOT
  120. $page = get_page('action=rc rchostonly=tisch');
  121. test_page($page, @Positives);
  122. test_page_negative($page, @Negatives);
  123. @Positives = qw(Mucidobombus.*tarantella);
  124. @Negatives = split('\n',<<'EOT');
  125. Confusibombus
  126. ballet
  127. Bombia
  128. tango
  129. Mendacibombus
  130. samba
  131. EOT
  132. $page = get_page('action=rc rchostonly=stuhl'); # no minor edits!
  133. test_page($page, @Positives);
  134. test_page_negative($page, @Negatives);
  135. @Positives = qw(Mucidobombus.*tarantella Confusibombus.*ballet);
  136. @Negatives = split('\n',<<'EOT');
  137. Mendacibombus
  138. samba
  139. Bombia
  140. tango
  141. EOT
  142. $page = get_page('action=rc rchostonly=stuhl showedit=1'); # with minor edits!
  143. test_page($page, @Positives);
  144. test_page_negative($page, @Negatives);
  145. @Positives = qw(Mendacibombus.*samba);
  146. @Negatives = split('\n',<<'EOT');
  147. Mucidobombus
  148. tarantella
  149. Bombia
  150. tango
  151. Confusibombus
  152. ballet
  153. EOT
  154. $page = get_page('action=rc rcuseronly=berta');
  155. test_page($page, @Positives);
  156. test_page_negative($page, @Negatives);
  157. @Positives = qw(Mucidobombus.*tarantella Bombia.*tango);
  158. @Negatives = qw(Confusibombus ballet Mendacibombus samba);
  159. $page = get_page('action=rc rcuseronly=alex');
  160. test_page($page, @Positives);
  161. test_page_negative($page, @Negatives);
  162. @Positives = qw(Bombia.*tango);
  163. @Negatives = qw(Mucidobombus tarantella Confusibombus ballet
  164. Mendacibombus samba);
  165. $page = get_page('action=rc rcidonly=Bombia');
  166. test_page($page, @Positives);
  167. test_page_negative($page, @Negatives);
  168. update_page('Mucidobombus', 'This is limbo.', 'flamenco');
  169. $page = get_page('action=rc');
  170. test_page($page, 'flamenco');
  171. test_page_negative($page, 'tarantella');
  172. $page = get_page('action=rc all=1');
  173. test_page($page, 'flamenco');
  174. test_page($page, 'tarantella');