SecureRandom uses v4 UUIDs, which are completely random except for
6 bits, 4 in the version field and 2 in the clk_seq_hi_res field.
Add a test that those bit patterns are set correctly for v4 UUIDs,
per RFC 4122 section 4.4.

Fixes [Bug #13603]
This commit is contained in:
Jeremy Evans 2019-07-26 09:56:53 -07:00
Родитель 4f978a1c99
Коммит 5fef46ae0d
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -140,6 +140,11 @@ end
def test_uuid def test_uuid
uuid = @it.uuid uuid = @it.uuid
assert_equal(36, uuid.size) assert_equal(36, uuid.size)
# Check time_hi_and_version and clock_seq_hi_res bits (RFC 4122 4.4)
assert_equal('4', uuid[14])
assert_include(%w'8 9 a b', uuid[19])
assert_match(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/, uuid) assert_match(/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\z/, uuid)
end end