Feature #14915 » deprecate-string-crypt.patch
| string.c | ||
|---|---|---|
|     char salt_8bit_clean[3]; | ||
| #endif | ||
|     rb_warn("The String#crypt method is deprecated. " \ | ||
| 	"Install the string-crypt gem and require \"string/crypt\" " \ | ||
| 	"to continue using String#crypt."); | ||
|     StringValue(salt); | ||
|     mustnot_wchar(str); | ||
|     mustnot_wchar(salt); | ||
| test/ruby/test_m17n_comb.rb | ||
|---|---|---|
|     end | ||
|   end | ||
|   private def crypt_result(str, salt) | ||
|     assert_warning(/The String#crypt core method is deprecated/) do | ||
|       str.crypt(salt) | ||
|     end | ||
|   end | ||
|   private def confirm_crypt_result(str, salt) | ||
|     if b(salt).length < 2 | ||
|       assert_raise(ArgumentError) { str.crypt(salt) } | ||
|       assert_raise(ArgumentError) { crypt_result(str, salt) } | ||
|       return | ||
|     end | ||
|     t = str.crypt(salt) | ||
|     assert_equal(b(str).crypt(b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})") | ||
|     t = crypt_result(str, salt) | ||
|     assert_equal(crypt_result(b(str), b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})") | ||
|     assert_encoding('ASCII-8BIT', t.encoding) | ||
|   end | ||
| test/ruby/test_string.rb | ||
|---|---|---|
|     assert_raise(ArgumentError) { "foo".count } | ||
|   end | ||
|   def crypt(str, salt) | ||
|     assert_warning(/The String#crypt core method is deprecated/) do | ||
|       str.crypt(salt) | ||
|     end | ||
|   end | ||
|   def test_crypt | ||
|     assert_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("aa"))) | ||
|     assert_not_equal(S('aaGUC/JkO9/Sc'), S("mypassword").crypt(S("ab"))) | ||
|     assert_raise(ArgumentError) {S("mypassword").crypt(S(""))} | ||
|     assert_raise(ArgumentError) {S("mypassword").crypt(S("\0a"))} | ||
|     assert_raise(ArgumentError) {S("mypassword").crypt(S("a\0"))} | ||
|     assert_raise(ArgumentError) {S("poison\u0000null").crypt(S("aa"))} | ||
|     assert_equal(S('aaGUC/JkO9/Sc'), crypt(S("mypassword"), S("aa"))) | ||
|     assert_not_equal(S('aaGUC/JkO9/Sc'), crypt(S("mypassword"), S("ab"))) | ||
|     assert_raise(ArgumentError) {crypt(S("mypassword"), S(""))} | ||
|     assert_raise(ArgumentError) {crypt(S("mypassword"), S("\0a"))} | ||
|     assert_raise(ArgumentError) {crypt(S("mypassword"), S("a\0"))} | ||
|     assert_raise(ArgumentError) {crypt(S("poison\u0000null"), S("aa"))} | ||
|     [Encoding::UTF_16BE, Encoding::UTF_16LE, | ||
|      Encoding::UTF_32BE, Encoding::UTF_32LE].each do |enc| | ||
|       assert_raise(ArgumentError) {S("mypassword").crypt(S("aa".encode(enc)))} | ||
|       assert_raise(ArgumentError) {S("mypassword".encode(enc)).crypt(S("aa"))} | ||
|       assert_raise(ArgumentError) {crypt(S("mypassword"), S("aa".encode(enc)))} | ||
|       assert_raise(ArgumentError) {crypt(S("mypassword".encode(enc)), S("aa"))} | ||
|     end | ||
|     @cls == String and | ||
|       assert_no_memory_leak([], 's = ""', "#{<<~"begin;"}\n#{<<~'end;'}") | ||
|     begin; | ||
|       1000.times { s.crypt(-"..").clear  } | ||
|       1000.times { crypt(s, -"..").clear  } | ||
|     end; | ||
|   end | ||
| test/webrick/test_httpauth.rb | ||
|---|---|---|
|       next | ||
|     end | ||
|     if hash_algo == :bcrypt | ||
|       warning = /\A\z/ | ||
|     else | ||
|       warning = /The String#crypt core method is deprecated/ | ||
|     end | ||
|     define_method(:"test_basic_auth_htpasswd_#{hash_algo}") do | ||
|       log_tester = lambda {|log, access_log| | ||
|         log.reject! {|line| /\A\s*\z/ =~ line } | ||
| ... | ... | |
|         Tempfile.create("test_webrick_auth") {|tmpfile| | ||
|           tmpfile.close | ||
|           tmp_pass = WEBrick::HTTPAuth::Htpasswd.new(tmpfile.path, password_hash: hash_algo) | ||
|           tmp_pass.set_passwd(realm, "webrick", "supersecretpassword") | ||
|           tmp_pass.set_passwd(realm, "foo", "supersecretpassword") | ||
|           assert_warning(warning) do | ||
|             tmp_pass.set_passwd(realm, "webrick", "supersecretpassword") | ||
|             tmp_pass.set_passwd(realm, "foo", "supersecretpassword") | ||
|           end | ||
|           tmp_pass.flush | ||
|           htpasswd = WEBrick::HTTPAuth::Htpasswd.new(tmpfile.path, password_hash: hash_algo) | ||
| ... | ... | |
|           } | ||
|           http = Net::HTTP.new(addr, port) | ||
|           g = Net::HTTP::Get.new(path) | ||
|           g.basic_auth("webrick", "supersecretpassword") | ||
|           http.request(g){|res| assert_equal("hoge", res.body, log.call)} | ||
|           g.basic_auth("webrick", "not super") | ||
|           http.request(g){|res| assert_not_equal("hoge", res.body, log.call)} | ||
|           assert_warning(warning) do | ||
|             g.basic_auth("webrick", "supersecretpassword") | ||
|             http.request(g){|res| assert_equal("hoge", res.body, log.call)} | ||
|             g.basic_auth("webrick", "not super") | ||
|             http.request(g){|res| assert_not_equal("hoge", res.body, log.call)} | ||
|           end | ||
|         } | ||
|       } | ||
|     end | ||
| ... | ... | |
|         Tempfile.create("test_webrick_auth") {|tmpfile| | ||
|           tmpfile.close | ||
|           tmp_pass = WEBrick::HTTPAuth::Htpasswd.new(tmpfile.path, password_hash: hash_algo) | ||
|           tmp_pass.set_passwd(realm, "webrick", "supersecretpassword") | ||
|           tmp_pass.set_passwd(realm, "foo", "supersecretpassword") | ||
|           assert_warning(warning) do | ||
|             tmp_pass.set_passwd(realm, "webrick", "supersecretpassword") | ||
|             tmp_pass.set_passwd(realm, "foo", "supersecretpassword") | ||
|           end | ||
|           tmp_pass.flush | ||
|           htpasswd = WEBrick::HTTPAuth::Htpasswd.new(tmpfile.path, password_hash: hash_algo) | ||
| ... | ... | |
|           } | ||
|           http = Net::HTTP.new(addr, port) | ||
|           g = Net::HTTP::Get.new(path) | ||
|           g.basic_auth("foo\ebar", "passwd") | ||
|           assert_warning(warning) do | ||
|             g.basic_auth("foo\ebar", "passwd") | ||
|           end | ||
|           http.request(g){|res| assert_not_equal("hoge", res.body, log.call) } | ||
|         } | ||
|       } | ||
- « Previous
- 1
- …
- 3
- 4
- 5
- Next »