/
ViewScriptTests.pm
727 lines (628 loc) · 25.2 KB
/
ViewScriptTests.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
package ViewScriptTests;
use strict;
use warnings;
use FoswikiFnTestCase;
our @ISA = qw( FoswikiFnTestCase );
use Foswiki;
use Foswiki::UI::View;
use Error qw( :try );
my $UI_FN;
my $topic1 = <<'HERE';
CONTENT
HERE
my $topic2 = <<'HERE';
----
MissingWikiWord %BR%
!ExclamationEscape <br />
<nop>NopEscape
%RED% <pre> adsf </pre> <verbatim> qwerty </verbatim>
<p>A Paragraph </p>
#anchor
<a href="http://blah.com/">asdf</a>
<noautolink>
NotTOAutoLink
</noautolink>
----
HERE
my $topic2meta =
'%META:TOPICINFO\{author="BaseUserMapping_666"( comment="")? date="[0-9]{10,10}" format="1.1" version="1"\}%'
. "\n";
my $topic2metaQ = $topic2meta;
$topic2metaQ =~ s/"/"/g;
my $topic2txtarea =
'<textarea name="" rows="22" cols="70" readonly="readonly" style="width:99%" id="topic" class="foswikiTextarea foswikiTextareaRawView">';
my $topic2rawON = $topic2;
$topic2rawON =~ s/</</g;
$topic2rawON =~ s/>/>/g;
$topic2rawON =~ s/"/"/g;
$topic2rawON .= '</textarea>';
my $topic3 = <<'HERE';
CONTENT
* Set ALLOWTOPICVIEW = NotAUser
HERE
my $templateTopicContent1 = <<'HERE';
pretemplate%STARTTEXT%pre%TEXT%post%ENDTEXT%posttemplate
HERE
my $templateTopicContent2 = <<'HERE';
pretemplate%TEXT%post%ENDTEXT%posttemplate
HERE
my $templateTopicContent3 = <<'HERE';
pretemplate%STARTTEXT%pre%TEXT%posttemplate
HERE
my $templateTopicContent4 = <<'HERE';
pretemplate%TEXT%posttemplate
HERE
my $templateTopicContent5 = <<'HERE';
pretemplate%STARTTEXT%posttemplate
HERE
## Should this be supported?
my $templateTopicContentX = <<'HERE';
pretemplate%STARTTEXT%pre%ENDTEXT%posttemplate
HERE
sub new {
my ( $class, @args ) = @_;
$Foswiki::cfg{EnableHierarchicalWebs} = 1;
return $class->SUPER::new( "ViewScript", @args );
}
# Set up the test fixture
sub set_up {
my $this = shift;
$this->SUPER::set_up();
$UI_FN ||= $this->getUIFn('view');
#set up nested web $this->{test_web}/Nest
$this->{test_subweb} = $this->{test_web} . '/Nest';
my $topic = 'TestTopic1';
my ($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'TestTopic1' );
$meta->text($topic1);
$meta->save();
$meta->finish();
$topic = 'TestTopic2';
($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'TestTopic2' );
$meta->text($topic2);
$meta->save();
$meta->finish();
$topic = 'TestTopic3';
($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'TestTopic3' );
$meta->text($topic3);
$meta->save();
$meta->finish();
($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'ViewoneTemplate' );
$meta->text($templateTopicContent1);
$meta->save( user => $this->{test_user_wikiname} );
$meta->finish();
($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'ViewtwoTemplate' );
$meta->text($templateTopicContent2);
$meta->save( user => $this->{test_user_wikiname} );
$meta->finish();
($meta) =
Foswiki::Func::readTopic( $this->{test_web}, 'ViewthreeTemplate' );
$meta->text($templateTopicContent3);
$meta->save( user => $this->{test_user_wikiname} );
$meta->finish();
($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'ViewfourTemplate' );
$meta->text($templateTopicContent4);
$meta->save( user => $this->{test_user_wikiname} );
$meta->finish();
($meta) = Foswiki::Func::readTopic( $this->{test_web}, 'ViewfiveTemplate' );
$meta->text($templateTopicContent5);
$meta->save( user => $this->{test_user_wikiname} );
$meta->finish();
try {
$this->createNewFoswikiSession('AdminUser');
my $webObject = $this->populateNewWeb( $this->{test_subweb} );
$webObject->finish();
$this->assert( $this->{session}->webExists( $this->{test_subweb} ) );
my ($topicObject) =
Foswiki::Func::readTopic( $this->{test_subweb},
$Foswiki::cfg{HomeTopicName} );
$topicObject->text("SMELL");
$topicObject->save();
$topicObject->finish();
$this->assert(
$this->{session}->topicExists(
$this->{test_subweb}, $Foswiki::cfg{HomeTopicName}
)
);
}
catch Error::Simple with {
$this->assert( 0, shift->stringify() || '' );
};
my ($topicObject) =
Foswiki::Func::readTopic( $this->{test_subweb}, $topic );
$topicObject->text('nested topci1 text');
$topicObject->save();
$topicObject->finish();
#set up nested web _and_ topic called $this->{test_web}/ThisTopic
($topicObject) = Foswiki::Func::readTopic( $this->{test_web}, 'ThisTopic' );
$topicObject->text('nested ThisTopic text');
$topicObject->save();
$topicObject->finish();
$this->{test_clashingsubweb} = $this->{test_web} . '/ThisTopic';
$topic = 'TestTopic1';
try {
$this->createNewFoswikiSession('AdminUser');
my $webObject = $this->populateNewWeb( $this->{test_clashingsubweb} );
$webObject->finish();
$this->assert(
$this->{session}->webExists( $this->{test_clashingsubweb} ) );
($topicObject) = Foswiki::Func::readTopic( $this->{test_clashingsubweb},
$Foswiki::cfg{HomeTopicName} );
$topicObject->text("SMELL");
$topicObject->save();
$topicObject->finish();
$this->assert(
$this->{session}->topicExists(
$this->{test_clashingsubweb},
$Foswiki::cfg{HomeTopicName}
)
);
}
catch Error::Simple with {
$this->assert( 0, shift->stringify() || '' );
};
($topicObject) =
Foswiki::Func::readTopic( $this->{test_clashingsubweb}, $topic );
$topicObject->text('nested topci1 text');
$topicObject->save();
$topicObject->finish();
return;
}
sub setup_view {
my ( $this, $web, $topic, $tmpl, $raw, $ctype, $skin, $method ) = @_;
my $query = Unit::Request->new(
{
webName => [$web],
topicName => [$topic],
template => [$tmpl],
raw => [$raw],
contenttype => [$ctype],
skin => [$skin],
}
);
$query->path_info("/$web/$topic");
$method ||= 'POST';
$query->method($method);
$this->createNewFoswikiSession( $this->{test_user_login}, $query );
my ($text) = $this->capture(
sub {
no strict 'refs';
&{$UI_FN}( $this->{session} );
use strict 'refs';
$Foswiki::engine->finalize( $this->{session}{response},
$this->{session}{request} );
}
);
my $editUrl =
$this->{session}
->getScriptUrl( '0', 'edit', $this->{test_web}, 'WebHome' );
$text =~ s/\r//g;
$text =~ s/(^.*?\n\n+)//s; # remove CGI header
return ( $text, $1, $editUrl );
}
# This test verifies the rendering of the various raw views
sub test_render_raw {
my $this = shift;
my $text;
my $hdr;
( $text, $hdr ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'text' );
$this->assert_equals( "$topic2", "$text\n",
"Unexpected output from raw=text" );
$this->assert_matches( qr#^Content-Type: text/plain#ms,
$hdr, "raw=text should return text/plain - got $hdr" );
( $text, $hdr ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'on' );
$this->assert_html_matches( $topic2txtarea . $topic2rawON,
$text, "Unexpected output from raw=on" );
$this->assert_matches( qr#^Content-Type: text/html#ms,
$hdr, "raw=on should return text/html - got $hdr" );
$this->expect_failure( 'Item11983 needs merge to 1.1',
with_dep => ('Foswiki,<,1.2') );
( $text, $hdr ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'all' );
$this->assert_matches( qr#$topic2meta$topic2#, "$text\n" );
$this->assert_matches( qr#^Content-Type: text/plain#ms,
$hdr, "raw=all should return text/plain - got $hdr" );
( $text, $hdr ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'debug' );
my ( $txttag, $txtarea, $txttail ) =
$text =~ m{.*?(<textarea .*?>)(.*?)(</textarea>).*}s;
$this->assert_html_matches( $topic2txtarea, $txttag,
"Unexpected tag output from raw=debug" );
$this->assert_matches(
$topic2metaQ . $topic2rawON,
$txtarea . $txttail,
"Unexpected body output from raw=debug"
);
$this->assert_matches( qr#^Content-Type: text/html#ms,
$hdr, "raw=debug should return text/html - got $hdr" );
return;
}
# This test verifies the rendering of the text/plain
sub test_render_textplain {
my $this = shift;
my $text;
my $hdr;
my $editUrl;
( $text, $hdr, $editUrl ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', '',
'text/plain', 'text' );
$editUrl =~ s/WebHome/MissingWikiWord/;
my $topic2plain = <<"HERE";
pretemplate<hr />
<a class="foswikiNewLink" href="$editUrl?topicparent=TemporaryViewScriptTestWebViewScript.TestTopic2" rel="nofollow" title="Create this topic">MissingWikiWord</a> <br />
ExclamationEscape <br />
NopEscape
<span class='foswikiRedFG'> <pre> adsf </pre> <pre> qwerty </pre>
<p>A Paragraph </p>
#anchor
<a href="http://blah.com/">asdf</a>
NotTOAutoLink
<hr />posttemplate
HERE
chomp $topic2plain;
$this->assert_matches( qr#^Content-Type: text/plain#ms,
$hdr, "contenttype=text/plain should return text/plain - got $hdr" );
$this->assert_does_not_match( qr#<(noautolink|nop)>#, $text,
"autolink or nop found in text skin" );
$this->assert_equals( $topic2plain, $text );
return;
}
# This test verifies the rendering of the HEAD
sub test_render_HEAD {
my $this = shift;
my $text;
my $hdr;
my $editUrl;
# setup_view( $this, $web, $topic, $tmpl, $raw, $ctype, $skin, $method ) = @_;
( $text, $hdr, $editUrl ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', '',
'text/plain', 'text', 'HEAD' );
$this->assert_matches(
qr#^Content-Type: text/plain#ms,
$hdr,
"HEAD test: contenttype=text/plain should return text/plain - got $hdr"
);
$this->assert_equals( "", $text,
"Unexpected output from HEAD Request, Text should not be returned, got: $text"
);
# Verify for a no-found topic
( $text, $hdr, $editUrl ) =
$this->setup_view( $this->{test_web}, 'AsdftTopic2', 'viewfour', '',
'text/plain', 'text', 'HEAD' );
$this->assert_equals( "", $text,
"Unexpected output from HEAD Request, Text should not be returned, got: $text"
);
$this->assert_matches( qr#^Status: 404#ms,
$hdr, "HEAD test: Not found should return 404 - got $hdr" );
# Verify for a not-authorized topic
$hdr = '';
try {
( $text, $hdr, $editUrl ) =
$this->setup_view( $this->{test_web}, 'TestTopic3', 'viewfour', '',
'text/plain', 'text', 'HEAD' );
}
catch Foswiki::AccessControlException with {
$this->assert( 1, "Successful ACL" );
};
$this->assert_equals( "", $text,
"Unexpected output from HEAD Request, Text should not be returned, got: $text"
);
$this->assert_equals( '',
$hdr, "HEAD test: Not found should throw an exception, got $hdr" );
return;
}
# This test verifies the handling of preamble (the text following
# %STARTTEXT%) and postamble (the text between %TEXT% and %ENDTEXT%).
sub test_prepostamble {
my $this = shift;
my $text;
($text) = $this->setup_view( $this->{test_web}, 'TestTopic1', 'viewone' );
$text =~ s/\n+$//s;
$this->assert_equals(
'pretemplatepreCONTENT
postposttemplate', $text
);
($text) = $this->setup_view( $this->{test_web}, 'TestTopic1', 'viewtwo' );
$this->assert_equals(
'pretemplateCONTENT
postposttemplate', $text
);
($text) = $this->setup_view( $this->{test_web}, 'TestTopic1', 'viewthree' );
$this->assert_equals( 'pretemplatepreCONTENTposttemplate', $text );
($text) = $this->setup_view( $this->{test_web}, 'TestTopic1', 'viewfour' );
$this->assert_equals( 'pretemplateCONTENTposttemplate', $text );
($text) = $this->setup_view( $this->{test_web}, 'TestTopic1', 'viewfive' );
$this->assert_equals( 'pretemplateposttemplate', $text );
return;
}
sub urltest {
my ( $this, $url, $web, $topic ) = @_;
my $query = Unit::Request->new( {} );
$query->setUrl($url);
$query->method('GET');
$this->createNewFoswikiSession( $this->{test_user_login}, $query );
$this->assert_equals( $web, $this->{session}->{webName} );
$this->assert_equals( $topic, $this->{session}->{topicName} );
return;
}
sub test_urlparsing {
my $this = shift;
$this->urltest( '', $this->{home_web}, 'WebHome' );
$this->urltest( '/', $this->{home_web}, 'WebHome' );
#SMELL: This has always been the case - sven recals changing it once and that causing issues?
my $dweb =
( $this->check_dependency('Foswiki,>=,1.2') ) ? $this->{home_web} : '';
$this->urltest( '/?topic=WebChanges', $dweb, 'WebChanges' );
$this->urltest( '/?topic=System.WebChanges', 'System', 'WebChanges' );
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
# the defaultweb parameter is new in 1.2
$this->urltest( '/?topic=System.WebChanges;defaultweb=Sandbox',
'System', 'WebChanges' );
$this->urltest( '/?topic=WebChanges;defaultweb=Sandbox',
'Sandbox', 'WebChanges' );
$this->urltest( '/System?topic=WebChanges;defaultweb=Sandbox',
'System', 'WebChanges' );
$this->urltest( '/?topic=System.WebChanges;defaultweb=Sandbox.WebHome',
'System', 'WebChanges' );
}
# $this->urltest('Sandbox', 'Sandbox', 'WebHome');
$this->urltest( '/Sandbox', 'Sandbox', 'WebHome' );
$this->urltest( '/Sandbox/', 'Sandbox', 'WebHome' );
$this->urltest( '//Sandbox', 'Sandbox', 'WebHome' );
$this->urltest( '///Sandbox', 'Sandbox', 'WebHome' );
$this->urltest( '/Sandbox//', 'Sandbox', 'WebHome' );
$this->urltest( '/Sandbox///', 'Sandbox', 'WebHome' );
$this->urltest( '/Sandbox/WebHome', 'Sandbox', 'WebHome' );
$this->urltest( '/Sandbox//WebHome', 'Sandbox', 'WebHome' );
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
$this->urltest( '/Sandbox/WebHome/', 'Sandbox', 'WebHome' );
$this->urltest( '/Sandbox/WebHome//', 'Sandbox', 'WebHome' );
}
else {
$this->urltest( '/Sandbox/WebHome/', 'Sandbox/WebHome', 'WebHome' );
$this->urltest( '/Sandbox/WebHome//', 'Sandbox/WebHome', 'WebHome' );
}
$this->urltest( '/Sandbox/NotATopic/', 'Sandbox/NotATopic', 'WebHome' );
$this->urltest( '/Sandbox/NotATopic//', 'Sandbox/NotATopic', 'WebHome' );
$this->urltest( '/Sandbox/WebIndex', 'Sandbox', 'WebIndex' );
$this->urltest( '/Sandbox//WebIndex', 'Sandbox', 'WebIndex' );
$this->urltest( '/Sandbox///WebIndex', 'Sandbox', 'WebIndex' );
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
$this->urltest( '/Sandbox/WebIndex/', 'Sandbox', 'WebIndex' );
$this->urltest( '/Sandbox/WebIndex//', 'Sandbox', 'WebIndex' );
$this->urltest( '/Sandbox/WebIndex///', 'Sandbox', 'WebIndex' );
}
else {
$this->urltest( '/Sandbox/WebIndex/', 'Sandbox/WebIndex', 'WebHome' );
$this->urltest( '/Sandbox/WebIndex//', 'Sandbox/WebIndex', 'WebHome' );
$this->urltest( '/Sandbox/WebIndex///', 'Sandbox/WebIndex', 'WebHome' );
}
$this->urltest( '/Sandbox/WebIndex/ok', 'Sandbox/WebIndex', 'Ok' );
$this->urltest( '/Sandbox/WebIndex/NotOk', 'Sandbox/WebIndex', 'NotOk' );
$this->urltest( '/Sandbox/WebIndex?asd=w', 'Sandbox', 'WebIndex' );
$this->urltest( '/Sandbox//WebIndex?asd=qwe', 'Sandbox', 'WebIndex' );
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
$this->urltest( '/Sandbox/WebIndex/?asd=qwe', 'Sandbox', 'WebIndex' );
$this->urltest( '/Sandbox/WebIndex//?asd=ewr', 'Sandbox', 'WebIndex' );
}
else {
$this->urltest( '/Sandbox/WebIndex/?asd=qwe', 'Sandbox/WebIndex',
'WebHome' );
$this->urltest( '/Sandbox/WebIndex//?asd=ewr', 'Sandbox/WebIndex',
'WebHome' );
}
$this->urltest( '/Sandbox/WebIndex?topic=WebChanges',
'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox//WebIndex?topic=WebChanges',
'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox/WebIndex/?topic=WebChanges',
'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox/WebIndex//?topic=WebChanges',
'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox?topic=WebChanges', 'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox/?topic=WebChanges', 'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox//?topic=WebChanges', 'Sandbox', 'WebChanges' );
$this->urltest( '/Sandbox/WebIndex?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/Sandbox//WebIndex?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/Sandbox/WebIndex/?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/Sandbox/WebIndex//?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/Sandbox?topic=System.WebChanges', 'System',
'WebChanges' );
$this->urltest( '/Sandbox/?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/Sandbox//?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '/WebHome',
$this->{test_subweb}, 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '//WebHome',
$this->{test_subweb}, 'WebHome' );
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
$this->urltest( '/' . $this->{test_subweb} . '/WebHome/',
$this->{test_subweb}, 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebHome//',
$this->{test_subweb}, 'WebHome' );
}
else {
$this->urltest( '/' . $this->{test_subweb} . '/WebHome/',
$this->{test_subweb} . '/WebHome', 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebHome//',
$this->{test_subweb} . '/WebHome', 'WebHome' );
}
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex',
$this->{test_subweb}, 'WebIndex' );
$this->urltest( '/' . $this->{test_subweb} . '//WebIndex',
$this->{test_subweb}, 'WebIndex' );
$this->urltest( '/' . $this->{test_subweb} . '///WebIndex',
$this->{test_subweb}, 'WebIndex' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex/',
$this->{test_subweb} . '/WebIndex', 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex//',
$this->{test_subweb} . '/WebIndex', 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex///',
$this->{test_subweb} . '/WebIndex', 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex?asd=w',
$this->{test_subweb}, 'WebIndex' );
$this->urltest( '/' . $this->{test_subweb} . '//WebIndex?asd=qwe',
$this->{test_subweb}, 'WebIndex' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex/?asd=qwe',
$this->{test_subweb} . '/WebIndex', 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex//?asd=ewr',
$this->{test_subweb} . '/WebIndex', 'WebHome' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex?topic=WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '//WebIndex?topic=WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex/?topic=WebChanges',
$this->{test_subweb} . '/WebIndex', 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '/WebIndex//?topic=WebChanges',
$this->{test_subweb} . '/WebIndex', 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '/Other?topic=WebChanges',
$this->{test_subweb}, 'WebChanges' );
#you may read 'subweb' but as its the last string in the url, foswiki treats it as a topicname
$this->urltest( '/' . $this->{test_subweb} . '?topic=WebChanges',
$this->{test_subweb}, 'WebChanges' );
#trailing slashes make it a web again
$this->urltest( '/' . $this->{test_subweb} . '/?topic=WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '//?topic=WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest(
'/' . $this->{test_subweb} . '/WebIndex?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest(
'/' . $this->{test_subweb} . '//WebIndex?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest(
'/' . $this->{test_subweb} . '/WebIndex/?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest(
'/' . $this->{test_subweb} . '/WebIndex//?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '/?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest( '/' . $this->{test_subweb} . '//?topic=System.WebChanges',
'System', 'WebChanges' );
$this->urltest(
'/'
. $this->{test_subweb}
. '/WebIndex?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/'
. $this->{test_subweb}
. '//WebIndex?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/'
. $this->{test_subweb}
. '/WebIndex/?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/'
. $this->{test_subweb}
. '/WebIndex//?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/'
. $this->{test_subweb}
. '?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/'
. $this->{test_subweb}
. '/?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/'
. $this->{test_subweb}
. '//?topic='
. $this->{test_subweb}
. '.WebChanges',
$this->{test_subweb}, 'WebChanges'
);
$this->urltest(
'/System/WebIndex?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest(
'/System//WebIndex?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest(
'/System/WebIndex/?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest(
'/System/WebIndex//?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest( '/System?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest( '/System/?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
$this->urltest( '/System//?topic=' . $this->{test_subweb} . '.WebChanges',
$this->{test_subweb}, 'WebChanges' );
#nonexistant webs
#noneexistant topics (Item598)
$this->urltest( '/Sandbox/ThisTopicShouldNotExist',
'Sandbox', 'ThisTopicShouldNotExist' );
$this->urltest(
'/Sandbox/ThisTopicShouldNotExist/',
'Sandbox/ThisTopicShouldNotExist',
'WebHome'
);
$this->urltest( '/' . $this->{test_subweb} . '/ThisTopicShouldNotExist',
$this->{test_subweb}, 'ThisTopicShouldNotExist' );
$this->urltest( '/' . $this->{test_subweb} . '/ThisTopicShouldNotExist/',
$this->{test_subweb} . '/ThisTopicShouldNotExist', 'WebHome' );
#both topic and subweb of same name exists (Item598)
#$this->{test_web}/ThisTopic is both a web and a topic
$this->urltest( '/' . $this->{test_web} . '/ThisTopic',
$this->{test_web}, 'ThisTopic' ); #the only way yo get to the topic
$this->urltest( '/' . $this->{test_web} . '/ThisTopic/',
$this->{test_web} . '/ThisTopic', 'WebHome' );
$this->urltest( '/' . $this->{test_web} . '/ThisTopic/WebHome',
$this->{test_web} . '/ThisTopic', 'WebHome' );
if ( $this->check_dependency('Foswiki,>=,1.2') ) {
$this->urltest( '/' . $this->{test_web} . '/ThisTopic/WebHome/',
$this->{test_web} . '/ThisTopic', 'WebHome' );
}
else {
$this->urltest( '/' . $this->{test_web} . '/ThisTopic/WebHome/',
$this->{test_web} . '/ThisTopic/WebHome', 'WebHome' );
}
return;
}
sub test_urlparsing_invalid {
my $this = shift;
# - Invalid web name - Tasks.Item8713
$this->urltest( '/A:B/WebPreferences', $Foswiki::cfg{HomeWebName},
'WebPreferences' );
$this->urltest( '/A\'":B/WebPreferences', $Foswiki::cfg{HomeWebName},
'WebPreferences' );
#invalid topic name
$this->urltest( '/System/WebPre@ferences', $Foswiki::cfg{SystemWebName},
'WebHome' );
}
1;