test/test_key.rb in zold-0.2 vs test/test_key.rb in zold-0.3
- old
+ new
@@ -18,11 +18,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'minitest/autorun'
require 'tmpdir'
-require_relative '../lib/zold/key.rb'
+require_relative '../lib/zold/key'
# Key test.
# Author:: Yegor Bugayenko (yegor256@gmail.com)
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
@@ -56,9 +56,27 @@
File.write(file, key.public_key.to_s)
pub = Zold::Key.new(file: file)
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|
+ 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|
+ 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))
end
end
end