aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_m17n_comb.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-05-23 20:07:36 -0700
committerJeremy Evans <code@jeremyevans.net>2019-06-01 10:50:06 -0700
commit4b9869e7e04cbfb581f6f1b21ae17b310135c5e2 (patch)
tree9baaa7e6e9efa28290e982dc641da13f05b8a6d0 /test/ruby/test_m17n_comb.rb
parent09c09eb0db6c14c532935081c9b79d38fdc81f6b (diff)
downloadruby-4b9869e7e04cbfb581f6f1b21ae17b310135c5e2.tar.gz
Update String#crypt tests to work on OpenBSD
Skip the webrick httpauth tests that use crypt when testing on OpenBSD. Fixes [Bug #11363]
Diffstat (limited to 'test/ruby/test_m17n_comb.rb')
-rw-r--r--test/ruby/test_m17n_comb.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb
index 99c162a92f..cfb8bff882 100644
--- a/test/ruby/test_m17n_comb.rb
+++ b/test/ruby/test_m17n_comb.rb
@@ -744,6 +744,10 @@ class TestM17NComb < Test::Unit::TestCase
}
end
+ def crypt_supports_des_crypt?
+ /openbsd/ !~ RUBY_PLATFORM
+ end
+
# glibc 2.16 or later denies salt contained other than [0-9A-Za-z./] #7312
# we use this check to test strict and non-strict behavior separately #11045
strict_crypt = if defined? Etc::CS_GNU_LIBC_VERSION
@@ -760,7 +764,7 @@ class TestM17NComb < Test::Unit::TestCase
}
end
- if !strict_crypt
+ if !strict_crypt && /openbsd/ !~ RUBY_PLATFORM
def test_str_crypt_nonstrict
combination(STRINGS, STRINGS) {|str, salt|
# only test input other than [0-9A-Za-z./] to confirm non-strict behavior
@@ -772,9 +776,14 @@ class TestM17NComb < Test::Unit::TestCase
end
private def confirm_crypt_result(str, salt)
- if b(salt).length < 2
- assert_raise(ArgumentError) { str.crypt(salt) }
- return
+ if crypt_supports_des_crypt?
+ if b(salt).length < 2
+ assert_raise(ArgumentError) { str.crypt(salt) }
+ return
+ end
+ else
+ return if b(salt).length < 2
+ salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmH#{salt}"
end
t = str.crypt(salt)
assert_equal(b(str).crypt(b(salt)), t, "#{encdump(str)}.crypt(#{encdump(salt)})")