| 1 | #!/opt/perl58/bin/perl -w |
| 2 | |
| 3 | use Test::Morescip-perl cpan WWW-Mechanize-FormFiller 0.13 Test/More/ 'no_plan'; |
| 4 | |
| 5 | package Catchscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/; |
| 6 | |
| 7 | sub TIEHANDLEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/TIEHANDLE(). { |
| 8 | my($class, $var) = @_scip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/`@_`.; |
| 9 | return blessscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/bless(). { var => $var }, $class; |
| 10 | } |
| 11 | |
| 12 | sub PRINTscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/PRINT(). { |
| 13 | my($self) = shiftscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/shift().; |
| 14 | ${'main::'.$self->{var}} .= joinscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/join(). '', @_scip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/`@_`.; |
| 15 | } |
| 16 | |
| 17 | sub OPENscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/OPEN(). {} # XXX Hackery in case the user redirects |
| 18 | sub CLOSEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/CLOSE(). {} # XXX STDERR/STDOUT. This is not the behavior we want. |
| 19 | |
| 20 | sub READscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/READ(). {} |
| 21 | sub READLINEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/READLINE(). {} |
| 22 | sub GETCscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/GETC(). {} |
| 23 | sub BINMODEscip-perl cpan WWW-Mechanize-FormFiller 0.13 Catch/BINMODE(). {} |
| 24 | |
| 25 | my $Original_File = 'lib/WWW/Mechanize/FormFiller.pm'; |
| 26 | |
| 27 | package mainscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/; |
| 28 | |
| 29 | # pre-5.8.0's warns aren't caught by a tied STDERR. |
| 30 | $SIGscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`%SIG`.{__WARN__} = sub { $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_. .= joinscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/join(). '', @_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`@_`.; }; |
| 31 | tie *STDOUT, 'Catch', '_STDOUT_' or diescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/die(). $!scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$!`.; |
| 32 | tie *STDERR, 'Catch', '_STDERR_' or diescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/die(). $!scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$!`.; |
| 33 | |
| 34 | SKIP: { |
| 35 | # A header testing whether we find all prerequisites : |
| 36 | # Check for module HTML::Form |
| 37 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 38 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 39 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 40 | |
| 41 | # Check for module WWW::Mechanize::FormFiller |
| 42 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller }; |
| 43 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller to run this test", 1 |
| 44 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 45 | |
| 46 | |
| 47 | # The original POD test |
| 48 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 49 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 50 | eval q{ |
| 51 | my $example = sub { |
| 52 | local $^W = 0; |
| 53 | |
| 54 | #line 161 lib/WWW/Mechanize/FormFiller.pm |
| 55 | |
| 56 | use WWW::Mechanize::FormFiller; |
| 57 | use HTML::Form; |
| 58 | |
| 59 | # Create a form filler that fills out google for my homepage |
| 60 | |
| 61 | my $html = "<html><body><form name='f' action='http://www.google.com/search'> |
| 62 | <input type='text' name='q' value='' /> |
| 63 | <input type='submit' name=btnG value='Google Search' /> |
| 64 | <input type='hidden' name='secretValue' value='0xDEADBEEF' /> |
| 65 | </form></body></html>"; |
| 66 | |
| 67 | my $f = WWW::Mechanize::FormFiller->new( |
| 68 | values => [ |
| 69 | [q => Fixed => "Corion Homepage"], |
| 70 | ]); |
| 71 | my $form = HTML::Form->parse($html,"http://www.google.com/intl/en/"); |
| 72 | $f->fill_form($form); |
| 73 | |
| 74 | my $request = $form->click("btnG"); |
| 75 | # Now we have a complete HTTP request, which we can hand off to |
| 76 | # LWP::UserAgent or (preferrably) WWW::Mechanize |
| 77 | |
| 78 | print $request->as_string; |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | ; |
| 84 | |
| 85 | } |
| 86 | }; |
| 87 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 161"); |
| 88 | |
| 89 | }; |
| 90 | SKIP: { |
| 91 | # A header testing whether we find all prerequisites : |
| 92 | # Check for module HTML::Form |
| 93 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 94 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 95 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 96 | |
| 97 | # Check for module WWW::Mechanize::FormFiller |
| 98 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller }; |
| 99 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller to run this test", 1 |
| 100 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 101 | |
| 102 | |
| 103 | # The original POD test |
| 104 | { |
| 105 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 106 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 107 | #line 161 lib/WWW/Mechanize/FormFiller.pm |
| 108 | |
| 109 | use WWW::Mechanize::FormFillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/; |
| 110 | use HTML::Formscip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/; |
| 111 | |
| 112 | # Create a form filler that fills out google for my homepage |
| 113 | |
| 114 | my $html = "<html><body><form name='f' action='http://www.google.com/search'> |
| 115 | <input type='text' name='q' value='' /> |
| 116 | <input type='submit' name=btnG value='Google Search' /> |
| 117 | <input type='hidden' name='secretValue' value='0xDEADBEEF' /> |
| 118 | </form></body></html>"; |
| 119 | |
| 120 | my $f = WWW::Mechanize::FormFiller->newscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/new().( |
| 121 | values => [ |
| 122 | [q => Fixed => "Corion Homepage"], |
| 123 | ]); |
| 124 | my $form = HTML::Form->parsescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/parse().($html,"http://www.google.com/intl/en/"); |
| 125 | $f->fill_formscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/fill_form().($form); |
| 126 | |
| 127 | my $request = $form->clickscip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/click().("btnG"); |
| 128 | # Now we have a complete HTTP request, which we can hand off to |
| 129 | # LWP::UserAgent or (preferrably) WWW::Mechanize |
| 130 | |
| 131 | printscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/print(). $request->as_stringscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/as_string().; |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | $_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_. =~ s/[\x0a\x0d]+$//; |
| 137 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.,"GET http://www.google.com/search?q=Corion+Homepage&btnG=Google+Search&secretValue=0xDEADBEEF",'Got the expected HTTP query string'); |
| 138 | |
| 139 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 140 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 141 | } |
| 142 | |
| 143 | }; |
| 144 | SKIP: { |
| 145 | # A header testing whether we find all prerequisites : |
| 146 | |
| 147 | # The original POD test |
| 148 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 149 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 150 | |
| 151 | }; |
| 152 | SKIP: { |
| 153 | # A header testing whether we find all prerequisites : |
| 154 | # Check for module HTML::Form |
| 155 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 156 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 157 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 158 | |
| 159 | # Check for module WWW::Mechanize::FormFiller |
| 160 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller }; |
| 161 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller to run this test", 1 |
| 162 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 163 | |
| 164 | |
| 165 | # The original POD test |
| 166 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 167 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 168 | eval q{ |
| 169 | my $example = sub { |
| 170 | local $^W = 0; |
| 171 | |
| 172 | #line 197 lib/WWW/Mechanize/FormFiller.pm |
| 173 | use WWW::Mechanize::FormFiller; |
| 174 | use HTML::Form; |
| 175 | |
| 176 | |
| 177 | |
| 178 | my $html = "<html><body><form name='f' action='http://www.example.com/'> |
| 179 | <input type='text' name='date_birth_spouse' value='' /> |
| 180 | <input type='text' name='date_birth' value='' /> |
| 181 | <input type='text' name='date_birth_kid_1' value='' /> |
| 182 | <input type='text' name='date_birth_kid_2' value='' /> |
| 183 | <input type='submit' name='fool'> |
| 184 | </form></body></html>"; |
| 185 | |
| 186 | my $f = WWW::Mechanize::FormFiller->new( |
| 187 | values => [ |
| 188 | [date_birth => Fixed => "01.01.1970"], |
| 189 | |
| 190 | # We are less discriminate with the other dates |
| 191 | [qr/date_birth/ => 'Random::Date' => string => '%d.%m.%Y'], |
| 192 | ]); |
| 193 | my $form = HTML::Form->parse($html,"http://www.example.com"); |
| 194 | $f->fill_form($form); |
| 195 | |
| 196 | my $request = $form->click("fool"); |
| 197 | # Now we have a complete HTTP request, which we can hand off to |
| 198 | # LWP::UserAgent or (preferrably) WWW::Mechanize |
| 199 | |
| 200 | print $request->as_string; |
| 201 | |
| 202 | |
| 203 | |
| 204 | |
| 205 | ; |
| 206 | |
| 207 | } |
| 208 | }; |
| 209 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 197"); |
| 210 | |
| 211 | }; |
| 212 | SKIP: { |
| 213 | # A header testing whether we find all prerequisites : |
| 214 | # Check for module HTML::Form |
| 215 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 216 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 217 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 218 | |
| 219 | # Check for module WWW::Mechanize::FormFiller |
| 220 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller }; |
| 221 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller to run this test", 1 |
| 222 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 223 | |
| 224 | |
| 225 | # The original POD test |
| 226 | { |
| 227 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 228 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 229 | #line 197 lib/WWW/Mechanize/FormFiller.pm |
| 230 | use WWW::Mechanize::FormFillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/; |
| 231 | use HTML::Formscip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/; |
| 232 | |
| 233 | |
| 234 | |
| 235 | my $html = "<html><body><form name='f' action='http://www.example.com/'> |
| 236 | <input type='text' name='date_birth_spouse' value='' /> |
| 237 | <input type='text' name='date_birth' value='' /> |
| 238 | <input type='text' name='date_birth_kid_1' value='' /> |
| 239 | <input type='text' name='date_birth_kid_2' value='' /> |
| 240 | <input type='submit' name='fool'> |
| 241 | </form></body></html>"; |
| 242 | |
| 243 | my $f = WWW::Mechanize::FormFiller->new( |
| 244 | values => [ |
| 245 | [date_birth => Fixed => "01.01.1970"], |
| 246 | |
| 247 | # We are less discriminate with the other dates |
| 248 | [qr/date_birth/ => 'Random::Date' => string => '%d.%m.%Y'], |
| 249 | ]); |
| 250 | my $form = HTML::Form->parsescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/parse().($html,"http://www.example.com"); |
| 251 | $f->fill_formscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/fill_form().($form); |
| 252 | |
| 253 | my $request = $form->clickscip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/click().("fool"); |
| 254 | # Now we have a complete HTTP request, which we can hand off to |
| 255 | # LWP::UserAgent or (preferrably) WWW::Mechanize |
| 256 | |
| 257 | printscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/print(). $request->as_stringscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/as_string().; |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | $_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_. =~ s/[\x0a\x0d]+$//; |
| 263 | likescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/like().($_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.,qr"^GET\shttp://www\.example\.com/ |
| 264 | \?date_birth_spouse=\d\d.\d\d.\d\d\d\d |
| 265 | \&date_birth=01.01.1970 |
| 266 | \&date_birth_kid_1=\d\d.\d\d.\d\d\d\d |
| 267 | \&date_birth_kid_2=\d\d.\d\d.\d\d\d\d |
| 268 | (?:\&fool=)?$"x,'Got the expected HTTP query string'); |
| 269 | |
| 270 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 271 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 272 | } |
| 273 | |
| 274 | }; |
| 275 | SKIP: { |
| 276 | # A header testing whether we find all prerequisites : |
| 277 | |
| 278 | # The original POD test |
| 279 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 280 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 281 | |
| 282 | }; |
| 283 | SKIP: { |
| 284 | # A header testing whether we find all prerequisites : |
| 285 | # Check for module HTML::Form |
| 286 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 287 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 288 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 289 | |
| 290 | # Check for module WWW::Mechanize::FormFiller::Value::Interactive |
| 291 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller::Value::Interactive }; |
| 292 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller::Value::Interactive to run this test", 1 |
| 293 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 294 | |
| 295 | |
| 296 | # The original POD test |
| 297 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 298 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 299 | eval q{ |
| 300 | my $example = sub { |
| 301 | local $^W = 0; |
| 302 | |
| 303 | #line 240 lib/WWW/Mechanize/FormFiller.pm |
| 304 | no warnings 'once'; |
| 305 | require HTML::Form; |
| 306 | require WWW::Mechanize::FormFiller::Value::Interactive; |
| 307 | local *WWW::Mechanize::FormFiller::Value::Interactive::ask_value = sub { "s3[r3t" }; #<-- not a good password |
| 308 | |
| 309 | |
| 310 | |
| 311 | # Create a form filler that asks us for the password |
| 312 | |
| 313 | # Normally, the HTML would come from a LWP::UserAgent request |
| 314 | my $html = "<html><body><form name='f' action='/login.asp'> |
| 315 | <input type='text' name='login'> |
| 316 | <input type='password' name='password' > |
| 317 | <input type='submit' name=Login value='Log in'> |
| 318 | <input type='hidden' name='session' value='0xDEADBEEF' /> |
| 319 | </form></body></html>"; |
| 320 | |
| 321 | my $f = WWW::Mechanize::FormFiller->new(); |
| 322 | my $form = HTML::Form->parse($html,"http://www.fbi.gov/super/secret/"); |
| 323 | |
| 324 | $f->add_filler( password => Interactive => []); |
| 325 | $f->fill_form($form); |
| 326 | |
| 327 | my $request = $form->click("Login"); |
| 328 | |
| 329 | # Now we have a complete HTTP request, which we can hand off to |
| 330 | # LWP::UserAgent or (preferrably) WWW::Mechanize |
| 331 | print $request->as_string; |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | ; |
| 337 | |
| 338 | } |
| 339 | }; |
| 340 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 240"); |
| 341 | |
| 342 | }; |
| 343 | SKIP: { |
| 344 | # A header testing whether we find all prerequisites : |
| 345 | # Check for module HTML::Form |
| 346 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form }; |
| 347 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module HTML::Form to run this test", 1 |
| 348 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 349 | |
| 350 | # Check for module WWW::Mechanize::FormFiller::Value::Interactive |
| 351 | eval { requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller::Value::Interactive }; |
| 352 | skipscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/skip(). "Need module WWW::Mechanize::FormFiller::Value::Interactive to run this test", 1 |
| 353 | if $@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`.; |
| 354 | |
| 355 | |
| 356 | # The original POD test |
| 357 | { |
| 358 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 359 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 360 | #line 240 lib/WWW/Mechanize/FormFiller.pm |
| 361 | no warnings 'once'; |
| 362 | requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). HTML::Form; |
| 363 | requirescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/require(). WWW::Mechanize::FormFiller::Value::Interactive; |
| 364 | local *WWW::Mechanize::FormFiller::Value::Interactive::ask_value = sub { "s3[r3t" }; #<-- not a good password |
| 365 | |
| 366 | |
| 367 | |
| 368 | # Create a form filler that asks us for the password |
| 369 | |
| 370 | # Normally, the HTML would come from a LWP::UserAgent request |
| 371 | my $html = "<html><body><form name='f' action='/login.asp'> |
| 372 | <input type='text' name='login'> |
| 373 | <input type='password' name='password' > |
| 374 | <input type='submit' name=Login value='Log in'> |
| 375 | <input type='hidden' name='session' value='0xDEADBEEF' /> |
| 376 | </form></body></html>"; |
| 377 | |
| 378 | my $f = WWW::Mechanize::FormFiller->newscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/new().(); |
| 379 | my $form = HTML::Form->parsescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/parse().($html,"http://www.fbi.gov/super/secret/"); |
| 380 | |
| 381 | $f->add_fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/add_filler().( password => Interactive => []); |
| 382 | $f->fill_formscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/fill_form().($form); |
| 383 | |
| 384 | my $request = $form->clickscip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/click().("Login"); |
| 385 | |
| 386 | # Now we have a complete HTTP request, which we can hand off to |
| 387 | # LWP::UserAgent or (preferrably) WWW::Mechanize |
| 388 | printscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/print(). $request->as_stringscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/as_string().; |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | isa_okscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/isa_ok().($f,"WWW::Mechanize::FormFiller"); |
| 394 | $_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_. =~ s/[\x0a\x0d]+$//; |
| 395 | likescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/like().($_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.,qr"^GET http://www.fbi.gov/login.asp\?login=&(password=.*?&)?Login=Log\+in&session=0xDEADBEEF",'Got the expected HTTP query string'); |
| 396 | |
| 397 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 398 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 399 | } |
| 400 | |
| 401 | }; |
| 402 | SKIP: { |
| 403 | # A header testing whether we find all prerequisites : |
| 404 | |
| 405 | # The original POD test |
| 406 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 407 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 408 | |
| 409 | }; |
| 410 | SKIP: { |
| 411 | # A header testing whether we find all prerequisites : |
| 412 | |
| 413 | # The original POD test |
| 414 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 415 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 416 | eval q{ |
| 417 | my $example = sub { |
| 418 | local $^W = 0; |
| 419 | |
| 420 | #line 301 lib/WWW/Mechanize/FormFiller.pm |
| 421 | |
| 422 | # This filler fills all unspecified fields |
| 423 | # with the string "<purposedly left blank>" |
| 424 | my $f = WWW::Mechanize::FormFiller->new( |
| 425 | default => [ Fixed => "<purposedly left blank>" ]); |
| 426 | |
| 427 | # This filler automatically fills in a username |
| 428 | # and asks for a password |
| 429 | my $f = WWW::Mechanize::FormFiller->new( |
| 430 | values => [[ login => Fixed => "corion" ], |
| 431 | [ password => Interactive => []], |
| 432 | ]); |
| 433 | |
| 434 | # This filler only fills in a username |
| 435 | # if it is the empty string, and still asks for the password : |
| 436 | my $f = WWW::Mechanize::FormFiller->new( |
| 437 | values => [[ login => Default => "corion" ], |
| 438 | [ password => Interactive => [], |
| 439 | ]]); |
| 440 | |
| 441 | ; |
| 442 | |
| 443 | } |
| 444 | }; |
| 445 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 301"); |
| 446 | |
| 447 | }; |
| 448 | SKIP: { |
| 449 | # A header testing whether we find all prerequisites : |
| 450 | |
| 451 | # The original POD test |
| 452 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 453 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 454 | |
| 455 | }; |
| 456 | SKIP: { |
| 457 | # A header testing whether we find all prerequisites : |
| 458 | |
| 459 | # The original POD test |
| 460 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 461 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 462 | eval q{ |
| 463 | my $example = sub { |
| 464 | local $^W = 0; |
| 465 | |
| 466 | #line 351 lib/WWW/Mechanize/FormFiller.pm |
| 467 | |
| 468 | $filler = WWW::Mechanize::FormFiller->new(); |
| 469 | $filler->fillout( |
| 470 | # For the the simple case, assumed 'Fixed' class, |
| 471 | name => 'Mark', |
| 472 | |
| 473 | # With an array reference, create and fill with the right kind of object. |
| 474 | widget_id => [ 'Random', (1..5) ], |
| 475 | ); |
| 476 | |
| 477 | |
| 478 | |
| 479 | |
| 480 | ; |
| 481 | |
| 482 | } |
| 483 | }; |
| 484 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 351"); |
| 485 | |
| 486 | }; |
| 487 | SKIP: { |
| 488 | # A header testing whether we find all prerequisites : |
| 489 | |
| 490 | # The original POD test |
| 491 | { |
| 492 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 493 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 494 | #line 351 lib/WWW/Mechanize/FormFiller.pm |
| 495 | |
| 496 | $fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler. = WWW::Mechanize::FormFiller->newscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/new().(); |
| 497 | $fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler.->filloutscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/fillout().( |
| 498 | # For the the simple case, assumed 'Fixed' class, |
| 499 | name => 'Mark', |
| 500 | |
| 501 | # With an array reference, create and fill with the right kind of object. |
| 502 | widget_id => [ 'Random', (1..5) ], |
| 503 | ); |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | isa_okscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/isa_ok().($fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler.,"WWW::Mechanize::FormFiller"); |
| 509 | |
| 510 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 511 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 512 | } |
| 513 | |
| 514 | }; |
| 515 | SKIP: { |
| 516 | # A header testing whether we find all prerequisites : |
| 517 | |
| 518 | # The original POD test |
| 519 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 520 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 521 | |
| 522 | }; |
| 523 | SKIP: { |
| 524 | # A header testing whether we find all prerequisites : |
| 525 | |
| 526 | # The original POD test |
| 527 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 528 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 529 | eval q{ |
| 530 | my $example = sub { |
| 531 | local $^W = 0; |
| 532 | |
| 533 | #line 367 lib/WWW/Mechanize/FormFiller.pm |
| 534 | $form = HTML::Form->parse('<html><body><form> |
| 535 | <input name="name" type="text" /> |
| 536 | <input name="motto" type="text" /> |
| 537 | </form></body></html>','http://www.example.com/'); |
| 538 | |
| 539 | |
| 540 | |
| 541 | $filler = WWW::Mechanize::FormFiller->new(); |
| 542 | $filler->fillout( |
| 543 | # If the first parameter isa HTML::Form, it is |
| 544 | # filled out directly |
| 545 | $form, |
| 546 | name => 'Mark', |
| 547 | motto => [ 'Random::Word', size => 5 ], |
| 548 | ); |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | ; |
| 554 | |
| 555 | } |
| 556 | }; |
| 557 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 367"); |
| 558 | |
| 559 | }; |
| 560 | SKIP: { |
| 561 | # A header testing whether we find all prerequisites : |
| 562 | |
| 563 | # The original POD test |
| 564 | { |
| 565 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 566 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 567 | #line 367 lib/WWW/Mechanize/FormFiller.pm |
| 568 | $form = HTML::Form->parsescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/parse().('<html><body><form> |
| 569 | <input name="name" type="text" /> |
| 570 | <input name="motto" type="text" /> |
| 571 | </form></body></html>','http://www.example.com/'); |
| 572 | |
| 573 | |
| 574 | |
| 575 | $fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler. = WWW::Mechanize::FormFiller->newscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/new().(); |
| 576 | $fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler.->filloutscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/fillout().( |
| 577 | # If the first parameter isa HTML::Form, it is |
| 578 | # filled out directly |
| 579 | $form, |
| 580 | name => 'Mark', |
| 581 | motto => [ 'Random::Word', size => 5 ], |
| 582 | ); |
| 583 | |
| 584 | |
| 585 | |
| 586 | |
| 587 | isa_okscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/isa_ok().($fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler.,"WWW::Mechanize::FormFiller"); |
| 588 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($form->valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/value().('name'),'Mark','Name is set'); |
| 589 | likescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/like().($form->valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/value().('motto'),qr/^[-'\w]+( [-'\w]+){3} [-'\w]+$/,'Motto is set'); |
| 590 | |
| 591 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 592 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 593 | } |
| 594 | |
| 595 | }; |
| 596 | SKIP: { |
| 597 | # A header testing whether we find all prerequisites : |
| 598 | |
| 599 | # The original POD test |
| 600 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 601 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 602 | |
| 603 | }; |
| 604 | SKIP: { |
| 605 | # A header testing whether we find all prerequisites : |
| 606 | |
| 607 | # The original POD test |
| 608 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 609 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 610 | eval q{ |
| 611 | my $example = sub { |
| 612 | local $^W = 0; |
| 613 | |
| 614 | #line 391 lib/WWW/Mechanize/FormFiller.pm |
| 615 | $form2 = HTML::Form->parse('<html><body><form> |
| 616 | <input name="name" type="text" /> |
| 617 | <input name="motto" type="text" />','http://www.example.com/'); |
| 618 | |
| 619 | |
| 620 | |
| 621 | # This works as a direct constructor as well |
| 622 | WWW::Mechanize::FormFiller->fillout( |
| 623 | $form2, |
| 624 | name => 'Mark', |
| 625 | motto => [ 'Random::Word', size => 5 ], |
| 626 | ); |
| 627 | |
| 628 | |
| 629 | |
| 630 | |
| 631 | ; |
| 632 | |
| 633 | } |
| 634 | }; |
| 635 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($@scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/`$@`., '', "example from line 391"); |
| 636 | |
| 637 | }; |
| 638 | SKIP: { |
| 639 | # A header testing whether we find all prerequisites : |
| 640 | |
| 641 | # The original POD test |
| 642 | { |
| 643 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 644 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 645 | #line 391 lib/WWW/Mechanize/FormFiller.pm |
| 646 | $form2scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$form2. = HTML::Form->parsescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/parse().('<html><body><form> |
| 647 | <input name="name" type="text" /> |
| 648 | <input name="motto" type="text" />','http://www.example.com/'); |
| 649 | |
| 650 | |
| 651 | |
| 652 | # This works as a direct constructor as well |
| 653 | WWW::Mechanize::FormFiller->filloutscip-perl cpan WWW-Mechanize-FormFiller 0.13 WWW/Mechanize/FormFiller/fillout().( |
| 654 | $form2scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$form2., |
| 655 | name => 'Mark', |
| 656 | motto => [ 'Random::Word', size => 5 ], |
| 657 | ); |
| 658 | |
| 659 | |
| 660 | |
| 661 | |
| 662 | isa_okscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/isa_ok().($fillerscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$filler.,"WWW::Mechanize::FormFiller"); |
| 663 | isscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/is().($form2scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$form2.->valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/value().('name'),'Mark','Name is set'); |
| 664 | likescip-perl cpan WWW-Mechanize-FormFiller 0.13 main/like().($form->valuescip-perl cpan WWW-Mechanize-FormFiller 0.13 HTML/Form/value().('motto'),qr/^[-'\w]+( [-'\w]+){3} [-'\w]+$/,'Motto is set'); |
| 665 | |
| 666 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 667 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 668 | } |
| 669 | |
| 670 | }; |
| 671 | SKIP: { |
| 672 | # A header testing whether we find all prerequisites : |
| 673 | |
| 674 | # The original POD test |
| 675 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDOUT_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDOUT_.; |
| 676 | undefscip-perl cpan WWW-Mechanize-FormFiller 0.13 main/undef(). $main::_STDERR_scip-perl cpan WWW-Mechanize-FormFiller 0.13 main/$_STDERR_.; |
| 677 | |
| 678 | }; |