Merge pull request #51937 from rails/fxn/nil-uuid
Define Digest::UUID.nil_uuid
This commit is contained in:
commit
b9f814ad86
@ -53,6 +53,12 @@ def self.uuid_v4
|
||||
SecureRandom.uuid
|
||||
end
|
||||
|
||||
# Returns the nil UUID. This is a special form of UUID that is specified to
|
||||
# have all 128 bits set to zero.
|
||||
def self.nil_uuid
|
||||
"00000000-0000-0000-0000-000000000000"
|
||||
end
|
||||
|
||||
def self.pack_uuid_namespace(namespace)
|
||||
if [DNS_NAMESPACE, OID_NAMESPACE, URL_NAMESPACE, X500_NAMESPACE].include?(namespace)
|
||||
namespace
|
||||
|
@ -55,6 +55,10 @@ def test_v5_uuids_with_rfc4122_namespaced_uuids_enabled
|
||||
end
|
||||
end
|
||||
|
||||
def test_nil_uuid
|
||||
assert_equal "00000000-0000-0000-0000-000000000000", Digest::UUID.nil_uuid
|
||||
end
|
||||
|
||||
def test_invalid_hash_class
|
||||
assert_raise ArgumentError do
|
||||
Digest::UUID.uuid_from_hash(OpenSSL::Digest::SHA256, Digest::UUID::OID_NAMESPACE, "1.2.3")
|
||||
|
Loading…
Reference in New Issue
Block a user