mechanize 2.5.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of mechanize might be problematic. Click here for more details.

Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +16 -0
  3. data/CHANGELOG.rdoc +54 -1
  4. data/Manifest.txt +5 -0
  5. data/README.rdoc +5 -5
  6. data/Rakefile +4 -2
  7. data/lib/mechanize.rb +53 -10
  8. data/lib/mechanize/cookie.rb +8 -2
  9. data/lib/mechanize/cookie_jar.rb +33 -7
  10. data/lib/mechanize/directory_saver.rb +14 -2
  11. data/lib/mechanize/download.rb +2 -0
  12. data/lib/mechanize/element_matcher.rb +17 -6
  13. data/lib/mechanize/file.rb +25 -1
  14. data/lib/mechanize/form.rb +73 -28
  15. data/lib/mechanize/form/field.rb +6 -2
  16. data/lib/mechanize/form/select_list.rb +4 -4
  17. data/lib/mechanize/http/agent.rb +36 -15
  18. data/lib/mechanize/http/auth_challenge.rb +7 -8
  19. data/lib/mechanize/http/content_disposition_parser.rb +1 -1
  20. data/lib/mechanize/http/www_authenticate_parser.rb +9 -4
  21. data/lib/mechanize/page.rb +38 -12
  22. data/lib/mechanize/page/image.rb +1 -1
  23. data/lib/mechanize/parser.rb +12 -3
  24. data/lib/mechanize/pluggable_parsers.rb +8 -3
  25. data/lib/mechanize/test_case.rb +13 -0
  26. data/lib/mechanize/test_case/digest_auth_servlet.rb +4 -4
  27. data/lib/mechanize/util.rb +2 -2
  28. data/lib/mechanize/xml_file.rb +47 -0
  29. data/test/htdocs/tc_follow_meta_loop_1.html +8 -0
  30. data/test/htdocs/tc_follow_meta_loop_2.html +8 -0
  31. data/test/test_mechanize.rb +66 -12
  32. data/test/test_mechanize_cookie.rb +34 -0
  33. data/test/test_mechanize_cookie_jar.rb +67 -1
  34. data/test/test_mechanize_directory_saver.rb +10 -0
  35. data/test/test_mechanize_file.rb +22 -4
  36. data/test/test_mechanize_form.rb +14 -0
  37. data/test/test_mechanize_form_field.rb +14 -0
  38. data/test/test_mechanize_form_multi_select_list.rb +9 -0
  39. data/test/test_mechanize_form_option.rb +4 -0
  40. data/test/test_mechanize_form_select_list.rb +4 -0
  41. data/test/test_mechanize_http_agent.rb +59 -11
  42. data/test/test_mechanize_http_auth_challenge.rb +1 -1
  43. data/test/test_mechanize_http_content_disposition_parser.rb +8 -0
  44. data/test/test_mechanize_http_www_authenticate_parser.rb +29 -12
  45. data/test/test_mechanize_page.rb +58 -0
  46. data/test/test_mechanize_page_encoding.rb +1 -1
  47. data/test/test_mechanize_page_image.rb +2 -1
  48. data/test/test_mechanize_pluggable_parser.rb +4 -4
  49. data/test/test_mechanize_xml_file.rb +29 -0
  50. metadata +173 -229
  51. data.tar.gz.sig +0 -0
  52. metadata.gz.sig +0 -0
@@ -494,5 +494,39 @@ class TestMechanizeCookie < Mechanize::TestCase
494
494
  }
495
495
  assert 'example.com', cookie.domain
496
496
  end
497
+
498
+ def test_cookie_httponly
499
+ url = URI.parse('http://rubyforge.org/')
500
+ cookie_params = {}
501
+ cookie_params['httponly'] = 'HttpOnly'
502
+ cookie_value = '12345%7D=ASDFWEE345%3DASda'
503
+
504
+ expires = Time.parse('Sun, 27-Sep-2037 00:00:00 GMT')
505
+
506
+ cookie_params.keys.combine.each do |c|
507
+ cookie_text = "#{cookie_value}; "
508
+ c.each_with_index do |key, idx|
509
+ if idx == (c.length - 1)
510
+ cookie_text << "#{cookie_params[key]}"
511
+ else
512
+ cookie_text << "#{cookie_params[key]}; "
513
+ end
514
+ end
515
+ cookie = nil
516
+ Mechanize::Cookie.parse(url, cookie_text) { |p_cookie| cookie = p_cookie; }
517
+
518
+ assert_equal(true, cookie.httponly)
519
+
520
+
521
+ # if expires was set, make sure we parsed it
522
+ if c.find { |k| k == 'expires' }
523
+ assert_equal(expires, cookie.expires)
524
+ else
525
+ assert_nil(cookie.expires)
526
+ end
527
+ end
528
+ end
529
+
530
+
497
531
  end
498
532
 
@@ -279,7 +279,8 @@ class TestMechanizeCookieJar < Mechanize::TestCase
279
279
  assert_equal(3, @jar.cookies(url).length)
280
280
 
281
281
  in_tmpdir do
282
- @jar.save_as("cookies.yml")
282
+ value = @jar.save_as("cookies.yml")
283
+ assert_same @jar, value
283
284
 
284
285
  jar = Mechanize::CookieJar.new
285
286
  jar.load("cookies.yml")
@@ -289,6 +290,33 @@ class TestMechanizeCookieJar < Mechanize::TestCase
289
290
  assert_equal(3, @jar.cookies(url).length)
290
291
  end
291
292
 
293
+ def test_save_session_cookies_yaml
294
+ url = URI 'http://rubyforge.org/'
295
+
296
+ # Add one cookie with an expiration date in the future
297
+ cookie = Mechanize::Cookie.new(cookie_values)
298
+ s_cookie = Mechanize::Cookie.new(cookie_values(:name => 'Bar',
299
+ :expires => nil,
300
+ :session => true))
301
+
302
+ @jar.add(url, cookie)
303
+ @jar.add(url, s_cookie)
304
+ @jar.add(url, Mechanize::Cookie.new(cookie_values(:name => 'Baz')))
305
+
306
+ assert_equal(3, @jar.cookies(url).length)
307
+
308
+ in_tmpdir do
309
+ @jar.save_as("cookies.yml", :format => :yaml, :session => true)
310
+
311
+ jar = Mechanize::CookieJar.new
312
+ jar.load("cookies.yml")
313
+ assert_equal(3, jar.cookies(url).length)
314
+ end
315
+
316
+ assert_equal(3, @jar.cookies(url).length)
317
+ end
318
+
319
+
292
320
  def test_save_cookies_cookiestxt
293
321
  url = URI 'http://rubyforge.org/'
294
322
 
@@ -480,4 +508,42 @@ class TestMechanizeCookieJar < Mechanize::TestCase
480
508
  assert_equal('Foo1', @jar.cookies(nurl).map { |c| c.name }.sort.join(' ') )
481
509
  assert_equal('Foo1 Foo2', @jar.cookies(surl).map { |c| c.name }.sort.join(' ') )
482
510
  end
511
+
512
+ def test_save_cookies_cookiestxt_subdomain
513
+ top_url = URI 'http://rubyforge.org/'
514
+ subdomain_url = URI 'http://admin.rubyforge.org/'
515
+
516
+ # cookie1 is for *.rubyforge.org; cookie2 is only for rubyforge.org, no subdomains
517
+ cookie1 = Mechanize::Cookie.new(cookie_values)
518
+ cookie2 = Mechanize::Cookie.new(cookie_values(:name => 'Boo', :for_domain => false))
519
+
520
+ @jar.add(top_url, cookie1)
521
+ @jar.add(top_url, cookie2)
522
+
523
+ assert_equal(2, @jar.cookies(top_url).length)
524
+ assert_equal(1, @jar.cookies(subdomain_url).length)
525
+
526
+ in_tmpdir do
527
+ @jar.save_as("cookies.txt", :cookiestxt)
528
+
529
+ jar = Mechanize::CookieJar.new
530
+ jar.load("cookies.txt", :cookiestxt) # HACK test the format
531
+ assert_equal(2, jar.cookies(top_url).length)
532
+ assert_equal(1, jar.cookies(subdomain_url).length)
533
+
534
+ # Check that we actually wrote the file correctly (not just that we were
535
+ # able to read what we wrote):
536
+ #
537
+ # * Cookies that only match exactly the domain specified must not have a
538
+ # leading dot, and must have FALSE as the second field.
539
+ # * Cookies that match subdomains must have a leading dot, and must have
540
+ # TRUE as the second field.
541
+ cookies_txt = File.readlines("cookies.txt")
542
+ assert_equal(1, cookies_txt.grep( /^rubyforge\.org\tFALSE/ ).length)
543
+ assert_equal(1, cookies_txt.grep( /^\.rubyforge\.org\tTRUE/ ).length)
544
+ end
545
+
546
+ assert_equal(2, @jar.cookies(top_url).length)
547
+ assert_equal(1, @jar.cookies(subdomain_url).length)
548
+ end
483
549
  end
@@ -35,6 +35,16 @@ class TestMechanizeDirectorySaver < Mechanize::TestCase
35
35
  end
36
36
  end
37
37
 
38
+ def test_with_decode_filename
39
+ in_tmpdir do
40
+ saver = Mechanize::DirectorySaver.save_to 'dir', :decode_filename => true
41
+ uri = URI 'http://example.com/foo+bar.html'
42
+ saver.new uri, nil, @io, 200
43
+
44
+ assert File.exist? 'dir/foo bar.html'
45
+ end
46
+ end
47
+
38
48
  def test_initialize_no_save_dir
39
49
  in_tmpdir do
40
50
  e = assert_raises Mechanize::Error do
@@ -18,14 +18,14 @@ class TestMechanizeFile < Mechanize::TestCase
18
18
 
19
19
  assert File.exist? 'test.html'
20
20
  assert_equal '0123456789', File.read('test.html')
21
-
21
+
22
22
  page.save 'test.html'
23
-
23
+
24
24
  assert File.exist? 'test.html.1'
25
25
  assert_equal '0123456789', File.read('test.html.1')
26
-
26
+
27
27
  page.save 'test.html'
28
-
28
+
29
29
  assert File.exist? 'test.html.2'
30
30
  assert_equal '0123456789', File.read('test.html.2')
31
31
  end
@@ -75,5 +75,23 @@ class TestMechanizeFile < Mechanize::TestCase
75
75
  assert_equal "test.html", page.filename
76
76
  end
77
77
 
78
+ def test_save_overwrite
79
+ uri = URI 'http://example/test.html'
80
+ page = Mechanize::File.new uri, nil, ''
81
+
82
+ Dir.mktmpdir do |dir|
83
+ Dir.chdir dir do
84
+ page.save 'test.html'
85
+
86
+ assert File.exist? 'test.html'
87
+
88
+ page.save! 'test.html'
89
+
90
+ assert File.exist? 'test.html'
91
+ refute File.exist? 'test.html.1'
92
+ end
93
+ end
94
+ end
95
+
78
96
  end
79
97
 
@@ -921,4 +921,18 @@ class TestMechanizeForm < Mechanize::TestCase
921
921
  assert_equal expected, query
922
922
  end
923
923
 
924
+ def test_form_input_disabled
925
+ page = html_page <<-BODY
926
+ <form name="form1" method="post" action="/form_post">
927
+ <input type="text" name="opa" value="omg" disabled />
928
+ <input type="submit" value="Submit" />
929
+ </form>
930
+ BODY
931
+ form = page.forms.first
932
+
933
+ page = @mech.submit form
934
+
935
+ assert_empty page.links
936
+ end
937
+
924
938
  end
@@ -2,6 +2,13 @@ require 'mechanize/test_case'
2
2
 
3
3
  class TestMechanizeFormField < Mechanize::TestCase
4
4
 
5
+ def test_inspect
6
+ field = node 'input'
7
+ field = Mechanize::Form::Field.new field, 'a&b'
8
+
9
+ assert_match "value: a&b", field.inspect
10
+ end
11
+
5
12
  def test_name
6
13
  field = node 'input', 'name' => 'a&b'
7
14
  field = Mechanize::Form::Field.new field
@@ -59,5 +66,12 @@ class TestMechanizeFormField < Mechanize::TestCase
59
66
  assert_equal 'a&b', field.value
60
67
  end
61
68
 
69
+ def test_raw_value
70
+ field = node 'input'
71
+ field = Mechanize::Form::Field.new field, 'a&amp;b'
72
+
73
+ assert_equal 'a&amp;b', field.raw_value
74
+ end
75
+
62
76
  end
63
77
 
@@ -22,6 +22,15 @@ class TestMechanizeFormMultiSelectList < Mechanize::TestCase
22
22
  @select = form.fields.first
23
23
  end
24
24
 
25
+ def test_inspect
26
+ assert_match "value: #{%w[2]}", @select.inspect
27
+ end
28
+
29
+ def test_inspect_select_all
30
+ @select.select_all
31
+ assert_match "value: #{%w[1 2 3 4 5 6]}", @select.inspect
32
+ end
33
+
25
34
  def test_option_with
26
35
  option = @select.option_with :value => '1'
27
36
 
@@ -20,6 +20,10 @@ class TestMechanizeFormOption < Mechanize::TestCase
20
20
  @option2 = @select.options.last
21
21
  end
22
22
 
23
+ def test_inspect
24
+ assert_match "value: 2", @select.inspect
25
+ end
26
+
23
27
  def test_value_missing_value
24
28
  option = node 'option'
25
29
  option.inner_html = 'blah'
@@ -22,6 +22,10 @@ class TestMechanizeFormSelectList < Mechanize::TestCase
22
22
  @select = form.fields.first
23
23
  end
24
24
 
25
+ def test_inspect
26
+ assert_match "value: 2", @select.inspect
27
+ end
28
+
25
29
  def test_option_with
26
30
  option = @select.option_with :value => '1'
27
31
 
@@ -16,7 +16,9 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
16
16
  @res.instance_variable_set :@code, 200
17
17
  @res.instance_variable_set :@header, {}
18
18
 
19
- @headers = if RUBY_VERSION > '1.9' then
19
+ @headers = if RUBY_VERSION >= '2.0.0' then
20
+ %w[accept accept-encoding user-agent]
21
+ elsif RUBY_VERSION >= '1.9.0' then
20
22
  %w[accept user-agent]
21
23
  else
22
24
  %w[accept]
@@ -158,7 +160,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
158
160
  in_tmpdir do
159
161
  nonexistent = File.join Dir.pwd, 'nonexistent'
160
162
 
161
- uri = URI.parse "file://#{nonexistent}"
163
+ uri = URI.parse "file:///#{nonexistent}"
162
164
 
163
165
  e = assert_raises Mechanize::ResponseCodeError do
164
166
  @agent.fetch uri
@@ -251,6 +253,22 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
251
253
  assert_equal '500', e.response_code
252
254
  end
253
255
 
256
+ def test_fetch_allowed_error_codes
257
+ @agent.allowed_error_codes = ['500']
258
+
259
+ page = @mech.get 'http://localhost/response_code?code=500'
260
+
261
+ assert_equal '500', page.code
262
+ end
263
+
264
+ def test_fetch_allowed_error_codes_int
265
+ @agent.allowed_error_codes = [500]
266
+
267
+ page = @mech.get 'http://localhost/response_code?code=500'
268
+
269
+ assert_equal '500', page.code
270
+ end
271
+
254
272
  def test_get_meta_refresh_header_follow_self
255
273
  @agent.follow_meta_refresh = true
256
274
  @agent.follow_meta_refresh_self = true
@@ -511,9 +529,10 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
511
529
 
512
530
  @agent.request_cookies @req, uri
513
531
 
514
- expected = cookie_str.sub ', ', '; '
532
+ expected_variant1 = 'a=b domain=\.example\.com; c=d domain=\.example\.com'
533
+ expected_variant2 = 'c=d domain=\.example\.com; a=b domain=\.example\.com'
515
534
 
516
- assert_equal expected, @req['Cookie']
535
+ assert_match(/^(#{expected_variant1}|#{expected_variant2})$/, @req['Cookie'])
517
536
  end
518
537
 
519
538
  def test_request_cookies_none
@@ -708,7 +727,10 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
708
727
  realm = Mechanize::HTTP::AuthRealm.new 'Digest', base_uri, 'r'
709
728
  assert_equal [realm], @agent.authenticate_methods[base_uri][:digest]
710
729
 
711
- challenge = Mechanize::HTTP::AuthChallenge.new 'Digest', 'realm' => 'r'
730
+ challenge = Mechanize::HTTP::AuthChallenge.new('Digest',
731
+ { 'realm' => 'r' },
732
+ 'Digest realm=r')
733
+
712
734
  assert_equal challenge, @agent.digest_challenges[realm]
713
735
  end
714
736
 
@@ -925,7 +947,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
925
947
  body_io = StringIO.new \
926
948
  "\037\213\b\0002\002\225M\000\003+H,*\001\000\306p\017I\005\000\000\000"
927
949
 
928
- body = @agent.response_content_encoding @res, body_io
950
+ @agent.response_content_encoding @res, body_io
929
951
 
930
952
  assert body_io.closed?
931
953
 
@@ -941,7 +963,7 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
941
963
  body_io = StringIO.new \
942
964
  "\037\213\b\0002\002\225M\000\003+H,*\001\000\306p\017I\004\000\000"
943
965
 
944
- body = @agent.response_content_encoding @res, body_io
966
+ @agent.response_content_encoding @res, body_io
945
967
 
946
968
  assert body_io.closed?
947
969
 
@@ -1063,15 +1085,18 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1063
1085
  uri = URI.parse 'http://host.example.com'
1064
1086
  cookie1 = 'a=b domain=.example.com'
1065
1087
  cookie2 = 'c=d domain=.example.com'
1088
+ cookies = [cookie1, cookie2]
1066
1089
  @res.instance_variable_set(:@header,
1067
- 'set-cookie' => [cookie1, cookie2],
1090
+ 'set-cookie' => cookies,
1068
1091
  'content-type' => %w[text/html])
1069
1092
  page = Mechanize::Page.new uri, @res, '', 200, @mech
1070
1093
 
1071
1094
  @agent.response_cookies @res, uri, page
1072
1095
 
1073
- assert_equal ['a=b domain=.example.com', 'c=d domain=.example.com'],
1074
- @agent.cookie_jar.cookies(uri).map { |c| c.to_s }
1096
+ cookies_from_jar = @agent.cookie_jar.cookies(uri)
1097
+
1098
+ assert_equal 2, cookies_from_jar.length
1099
+ cookies_from_jar.each { |cookie| assert cookies.include? cookie.to_s }
1075
1100
  end
1076
1101
 
1077
1102
  def test_response_cookies_meta
@@ -1094,6 +1119,24 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1094
1119
  @agent.cookie_jar.cookies(uri).map { |c| c.to_s }
1095
1120
  end
1096
1121
 
1122
+ def test_response_cookies_meta_bogus
1123
+ uri = URI.parse 'http://host.example.com'
1124
+
1125
+ body = <<-BODY
1126
+ <head>
1127
+ <meta http-equiv="Set-Cookie">
1128
+ </head>"
1129
+ BODY
1130
+
1131
+ @res.instance_variable_set(:@header,
1132
+ 'content-type' => %w[text/html])
1133
+ page = Mechanize::Page.new uri, @res, body, 200, @mech
1134
+
1135
+ @agent.response_cookies @res, uri, page
1136
+
1137
+ assert_empty @agent.cookie_jar.cookies(uri)
1138
+ end
1139
+
1097
1140
  def test_response_follow_meta_refresh
1098
1141
  uri = URI.parse 'http://example/#id+1'
1099
1142
 
@@ -1309,8 +1352,13 @@ class TestMechanizeHttpAgent < Mechanize::TestCase
1309
1352
  expected = "π\n"
1310
1353
  expected.force_encoding Encoding::BINARY if expected.respond_to? :encoding
1311
1354
 
1355
+ # Ruby 1.8.7 doesn't let us set the write mode of the tempfile to binary,
1356
+ # so we should expect an inserted carriage return on some platforms
1357
+ expected_with_carriage_return = "π\r\n"
1358
+ expected_with_carriage_return.force_encoding Encoding::BINARY if expected_with_carriage_return.respond_to? :encoding
1359
+
1312
1360
  body = io.read
1313
- assert_equal expected, body
1361
+ assert_match(/^(#{expected}|#{expected_with_carriage_return})$/m, body)
1314
1362
  assert_equal Encoding::BINARY, body.encoding if body.respond_to? :encoding
1315
1363
  end
1316
1364
  end
@@ -8,7 +8,7 @@ class TestMechanizeHttpAuthChallenge < Mechanize::TestCase
8
8
  @uri = URI 'http://example/'
9
9
  @AR = Mechanize::HTTP::AuthRealm
10
10
  @AC = Mechanize::HTTP::AuthChallenge
11
- @challenge = @AC.new 'Digest', 'realm' => 'r'
11
+ @challenge = @AC.new 'Digest', { 'realm' => 'r' }, 'Digest realm=r'
12
12
  end
13
13
 
14
14
  def test_realm_basic
@@ -119,6 +119,14 @@ class TestMechanizeHttpContentDispositionParser < Mechanize::TestCase
119
119
 
120
120
  assert_equal 'end "', string
121
121
  end
122
+
123
+ def test_parse_uppercase
124
+ content_disposition = @parser.parse \
125
+ 'content-disposition: attachment; Filename=value', true
126
+
127
+ assert_equal 'attachment', content_disposition.type
128
+ assert_equal 'value', content_disposition.filename
129
+ end
122
130
 
123
131
  end
124
132
 
@@ -44,25 +44,42 @@ class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase
44
44
 
45
45
  def test_parse
46
46
  expected = [
47
- challenge('Basic', { 'realm' => 'foo' }),
47
+ challenge('Basic', { 'realm' => 'foo', 'qop' => 'auth,auth-int' }, 'Basic realm=foo, qop="auth,auth-int"'),
48
48
  ]
49
49
 
50
- assert_equal expected, @parser.parse('Basic realm=foo')
50
+ assert_equal expected, @parser.parse('Basic realm=foo, qop="auth,auth-int"')
51
+ end
52
+
53
+ def test_parse_without_comma_delimiter
54
+ expected = [
55
+ challenge('Basic', { 'realm' => 'foo', 'qop' => 'auth,auth-int' }, 'Basic realm=foo qop="auth,auth-int"'),
56
+ ]
57
+
58
+ assert_equal expected, @parser.parse('Basic realm=foo qop="auth,auth-int"')
51
59
  end
52
60
 
53
61
  def test_parse_multiple
54
62
  expected = [
55
- challenge('Basic', { 'realm' => 'foo' }),
56
- challenge('Digest', { 'realm' => 'bar' }),
63
+ challenge('Basic', { 'realm' => 'foo' }, 'Basic realm=foo'),
64
+ challenge('Digest', { 'realm' => 'bar' }, 'Digest realm=bar'),
57
65
  ]
58
66
 
59
67
  assert_equal expected, @parser.parse('Basic realm=foo, Digest realm=bar')
60
68
  end
61
69
 
70
+ def test_parse_multiple_without_comma_delimiter
71
+ expected = [
72
+ challenge('Basic', { 'realm' => 'foo' }, 'Basic realm=foo'),
73
+ challenge('Digest', { 'realm' => 'bar' }, 'Digest realm=bar'),
74
+ ]
75
+
76
+ assert_equal expected, @parser.parse('Basic realm=foo Digest realm=bar')
77
+ end
78
+
62
79
  def test_parse_multiple_blank
63
80
  expected = [
64
- challenge('Basic', { 'realm' => 'foo' }),
65
- challenge('Digest', { 'realm' => 'bar' }),
81
+ challenge('Basic', { 'realm' => 'foo' }, 'Basic realm=foo'),
82
+ challenge('Digest', { 'realm' => 'bar' }, 'Digest realm=bar'),
66
83
  ]
67
84
 
68
85
  assert_equal expected, @parser.parse('Basic realm=foo,, Digest realm=bar')
@@ -70,7 +87,7 @@ class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase
70
87
 
71
88
  def test_parse_ntlm_init
72
89
  expected = [
73
- challenge('NTLM', nil),
90
+ challenge('NTLM', nil, 'NTLM'),
74
91
  ]
75
92
 
76
93
  assert_equal expected, @parser.parse('NTLM')
@@ -78,7 +95,7 @@ class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase
78
95
 
79
96
  def test_parse_ntlm_type_2_3
80
97
  expected = [
81
- challenge('NTLM', 'foo='),
98
+ challenge('NTLM', 'foo=', 'NTLM foo='),
82
99
  ]
83
100
 
84
101
  assert_equal expected, @parser.parse('NTLM foo=')
@@ -86,7 +103,7 @@ class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase
86
103
 
87
104
  def test_parse_realm_uppercase
88
105
  expected = [
89
- challenge('Basic', { 'realm' => 'foo' }),
106
+ challenge('Basic', { 'realm' => 'foo' }, 'Basic ReAlM=foo'),
90
107
  ]
91
108
 
92
109
  assert_equal expected, @parser.parse('Basic ReAlM=foo')
@@ -94,7 +111,7 @@ class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase
94
111
 
95
112
  def test_parse_scheme_uppercase
96
113
  expected = [
97
- challenge('Basic', { 'realm' => 'foo' }),
114
+ challenge('Basic', { 'realm' => 'foo' }, 'BaSiC realm=foo'),
98
115
  ]
99
116
 
100
117
  assert_equal expected, @parser.parse('BaSiC realm=foo')
@@ -154,8 +171,8 @@ class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase
154
171
  assert_equal 't', string
155
172
  end
156
173
 
157
- def challenge scheme, params
158
- Mechanize::HTTP::AuthChallenge.new scheme, params
174
+ def challenge scheme, params, raw
175
+ Mechanize::HTTP::AuthChallenge.new scheme, params, raw
159
176
  end
160
177
 
161
178
  end