test/test_key.rb in zold-0.31.5 vs test/test_key.rb in zold-0.31.6
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-# Copyright (c) 2018-2023 Zerocracy, Inc.
+# Copyright (c) 2018-2023 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -61,29 +61,29 @@
def test_signs_and_verifies_with_random_key
Dir.mktmpdir do |dir|
key = OpenSSL::PKey::RSA.new(2048)
file = File.join(dir, 'temp')
- IO.write(file, key.public_key.to_s)
+ File.write(file, key.public_key.to_s)
pub = Zold::Key.new(file: file)
- IO.write(file, key.to_s)
+ File.write(file, key.to_s)
pvt = Zold::Key.new(file: file)
text = 'How are you doing, dude?'
signature = pvt.sign(text)
assert(pub.verify(signature, text))
end
end
def test_read_public_keys
- Dir.new('fixtures/keys').select { |f| f =~ /\.pub$/ }.each do |f|
+ Dir.new('fixtures/keys').grep(/\.pub$/).each do |f|
path = "fixtures/keys/#{f}"
pub = Zold::Key.new(file: path)
assert(pub.to_pub.length > 100)
end
end
def test_signs_with_real_keys
- Dir.new('fixtures/keys').select { |f| f =~ /[0-9]+$/ }.each do |f|
+ Dir.new('fixtures/keys').grep(/[0-9]+$/).each do |f|
pvt = Zold::Key.new(file: "fixtures/keys/#{f}")
pub = Zold::Key.new(file: "fixtures/keys/#{f}.pub")
text = 'How are you doing, my friend?'
signature = pvt.sign(text)
assert(pub.verify(signature, text))