Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl committed Feb 3, 2024
1 parent 9fb18dc commit da1cfc2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions spec/minisign_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

describe Minisign::PublicKey do
before do
@pk = Minisign::PublicKey.new(File.read('test/local.pub').split("\n").pop)
@pk = Minisign::PublicKey.new(File.read('test/minisign.pub').split("\n").pop)
@message = File.read('test/example.txt')
end
it 'verifies signatures' do
@signature = Minisign::Signature.new(File.read('test/example.txt.minisig'))
expect(@pk.verify(@signature, @message)).to match('Trusted comment')
end
it 'raises ed25519 errors' do
it 'raises ed25519 errors for valid signatures but mismatching content' do
@signature = Minisign::Signature.new(File.read('test/example.txt.minisig.unverifiable'))
expect { @pk.verify(@signature, @message) }.to raise_error(Ed25519::VerifyError)
end
Expand All @@ -18,20 +18,20 @@
expect { @pk.verify(@signature, @message) }.to raise_error('Comment signature verification failed')
end
it 'has a key_id' do
expect(@pk.key_id).to eq('E86FECED695E8E0')
expect(@pk.key_id).to eq('4CB7A94FABA329A6')
end
it 'raises errors on key id mismatch' do
@pk = Minisign::PublicKey.new('RWQIoBiLxWlf8dGe/DM+igVgetlwOuhWW3abyI1z8eS1RHJVc4o+1sCI')
@signature = Minisign::Signature.new(File.read('test/example.txt.minisig'))
expect do
@pk.verify(@signature, @message)
end.to raise_error("Signature key id is E86FECED695E8E0\nbut the key id in the public key is F15F69C58B18A08")
end.to raise_error("Signature key id is 4CB7A94FABA329A6\nbut the key id in the public key is F15F69C58B18A08")
end
end

describe Minisign::Signature do
it 'has a key id' do
@signature = Minisign::Signature.new(File.read('test/example.txt.minisig'))
expect(@signature.key_id).to eq('E86FECED695E8E0')
expect(@signature.key_id).to eq('4CB7A94FABA329A6')
end
end
6 changes: 3 additions & 3 deletions test/example.txt.minisig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
untrusted comment: signature from minisign secret key
RUTg6JXWzv6GDmPMFIE8V3D+S6mi6FBFrUNwvRVZrLNrySSWT8HPLXhN16nSzb3WLTSd59SceVfGtgEP2FMHVAqTc40mLXBbJQ4=
trusted comment: timestamp:1653934067 file:example.txt hashed
YU7xAGNcc5LGLHHyw14S6xtIvhfF3chGJ/rLSauaiPb1jtnt6JHB/ieMIjqEZ8unxxLllXQ2t6uQqzIKsiwAAg==
RUSmKaOrT6m3TM3Pv4f4gwv40qbXWPv+l8LX1741TuRQV1gfnPWQqcRbEhRXzUxaAFTQocrOhC1SLRTV2kQZZSIi6nBK1FC9GgA=
trusted comment: timestamp:1706961104 file:example.txt hashed
LzQ3/VkobtbyEZX95vEJ5kf2brGY/yGpxqT3o1OU2Be4RnWXeRky3lHfwjFHGaLB+egSgrUfntjY3cgACiBxDg==
6 changes: 3 additions & 3 deletions test/example.txt.minisig.tampered
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
untrusted comment: signature from minisign secret key
RUTg6JXWzv6GDmPMFIE8V3D+S6mi6FBFrUNwvRVZrLNrySSWT8HPLXhN16nSzb3WLTSd59SceVfGtgEP2FMHVAqTc40mLXBbJQ4=
trusted comment: timestamp:1653934367 file:example.txt hashed
YU7xAGNcc5LGLHHyw14S6xtIvhfF3chGJ/rLSauaiPb1jtnt6JHB/ieMIjqEZ8unxxLllXQ2t6uQqzIKsiwAAg==
RUSmKaOrT6m3TM3Pv4f4gwv40qbXWPv+l8LX1741TuRQV1gfnPWQqcRbEhRXzUxaAFTQocrOhC1SLRTV2kQZZSIi6nBK1FC9GgA=
trusted comment: timestamp:1706961103 file:example.txt hashed
LzQ3/VkobtbyEZX95vEJ5kf2brGY/yGpxqT3o1OU2Be4RnWXeRky3lHfwjFHGaLB+egSgrUfntjY3cgACiBxDg==
6 changes: 3 additions & 3 deletions test/example.txt.minisig.unverifiable
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
untrusted comment: signature from minisign secret key
RUTg6JXWzv6GDmPMFIE8V3D+S5mi6FBFrUNwvRVZrLNrySSWT8HPLXhN16nSzb3WLTSd59SceVfGtgEP2FMHVAqTc40mLXBbJQ4=
trusted comment: timestamp:1653934067 file:example.txt hashed
YU7xAGNcc5LGLHHyw14S6xtIvhfF3chGJ/rLSauaiPb1jtnt6JHB/ieMIjqEZ8unxxLllXQ2t6uQqzIKsiwAAg==
RUSmKaOrT6m3TENGp8riRZz/zdCYneGKtF/1JiL23qh/WKfVKzQJhmu5/1IYSZzluvpBRmTm9TvVfvDjPTUHPp80Lrv3mwnB3wU=
trusted comment: timestamp:1706961511 file:example.txt.minisig.tampered hashed
nBME8TuE4sS+q4MGSSDxaacbX/dFTWRaixyKFTSlUNx9jydYgb5Ivg2JnzO0oO5NauHge8L5LG/5wa9RIJriDw==

0 comments on commit da1cfc2

Please sign in to comment.