Commit e52b6851 authored by georg's avatar georg

specs: Relax GPG dates in expected output

This helps with making schleuder build reproducible, because the dates
are non deterministic.

Closes: #268
parent 2835314c
......@@ -147,7 +147,7 @@ describe 'cli' do
mail = Mail::TestMailer.deliveries.first
expect(Mail::TestMailer.deliveries.length).to eq 1
expect(mail.first_plaintext_part.body.to_s).to eql("Refreshing all keys from the keyring of list #{list.email} resulted in this:\n\nThis key was updated (new signatures):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]\n\nThis key was updated (new user-IDs and new signatures):\n0x6EE51D78FD0B33DE65CCF69D2104E20E20889F66 new@example.org 2017-03-25\n")
expect(mail.first_plaintext_part.body.to_s).to match(/Refreshing all keys from the keyring of list #{list.email} resulted in this:\n\nThis key was updated \(new signatures\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]\n\nThis key was updated \(new user-IDs and new signatures\):\n0x6EE51D78FD0B33DE65CCF69D2104E20E20889F66 new@example.org \d{4}-\d{2}-\d{2}\n/)
teardown_list_and_mailer(list)
end
......@@ -166,7 +166,7 @@ describe 'cli' do
mail = Mail::TestMailer.deliveries.first
expect(Mail::TestMailer.deliveries.length).to eq 1
expect(mail.first_plaintext_part.body.to_s).to eql("Refreshing all keys from the keyring of list #{list1.email} resulted in this:\n\nThis key was updated (new signatures):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]\n\nThis key was updated (new user-IDs and new signatures):\n0x6EE51D78FD0B33DE65CCF69D2104E20E20889F66 new@example.org 2017-03-25\n")
expect(mail.first_plaintext_part.body.to_s).to match(/Refreshing all keys from the keyring of list #{list1.email} resulted in this:\n\nThis key was updated \(new signatures\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]\n\nThis key was updated \(new user-IDs and new signatures\):\n0x6EE51D78FD0B33DE65CCF69D2104E20E20889F66 new@example.org \d{4}-\d{2}-\d{2}\n/)
teardown_list_and_mailer(list1)
teardown_list_and_mailer(list2)
......
......@@ -856,7 +856,7 @@ describe "user sends keyword" do
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.first_plaintext_part.body.to_s).to eql("This key was fetched (new key):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]\n")
expect(message.first_plaintext_part.body.to_s).to match(/This key was fetched \(new key\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]\n/)
teardown_list_and_mailer(list)
end
......@@ -924,7 +924,7 @@ describe "user sends keyword" do
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.first_plaintext_part.body.to_s).to eql("This key was fetched (new key):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]\n")
expect(message.first_plaintext_part.body.to_s).to match(/This key was fetched \(new key\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]\n/)
teardown_list_and_mailer(list)
end
......@@ -1027,7 +1027,7 @@ describe "user sends keyword" do
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.first_plaintext_part.body.to_s).to eql("This key was fetched (new key):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]\n")
expect(message.first_plaintext_part.body.to_s).to match(/This key was fetched \(new key\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]\n/)
teardown_list_and_mailer(list)
end
......@@ -1061,7 +1061,7 @@ describe "user sends keyword" do
raw = Mail::TestMailer.deliveries.first
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.first_plaintext_part.body.to_s).to eql("This key was fetched (unchanged):\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org 2016-12-06\n")
expect(message.first_plaintext_part.body.to_s).to match(/This key was fetched \(unchanged\):\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org \d{4}-\d{2}-\d{2}/)
teardown_list_and_mailer(list)
end
......@@ -1515,7 +1515,7 @@ describe "user sends keyword" do
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.to).to eql(['schleuder@example.org'])
expect(message.to_s).to include("pub 4096R/59C71FB38AEE22E091C78259D06350440F759BD3 2016-12-06")
expect(message.to_s).to match(/pub 4096R\/59C71FB38AEE22E091C78259D06350440F759BD3 \d{4}-\d{2}-\d{2}/)
expect(message.to_s.scan(/^pub /).size).to eql(1)
teardown_list_and_mailer(list)
......@@ -1549,7 +1549,7 @@ describe "user sends keyword" do
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.to).to eql(['schleuder@example.org'])
expect(message.to_s).to include("pub 4096R/59C71FB38AEE22E091C78259D06350440F759BD3 2016-12-06")
expect(message.to_s).to match(/pub 4096R\/59C71FB38AEE22E091C78259D06350440F759BD3 \d{4}-\d{2}-\d{2}/)
expect(message.to_s.scan(/^pub /).size).to eql(1)
teardown_list_and_mailer(list)
......@@ -1583,7 +1583,7 @@ describe "user sends keyword" do
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.to).to eql(['schleuder@example.org'])
expect(message.to_s).to include("pub 4096R/59C71FB38AEE22E091C78259D06350440F759BD3 2016-12-06")
expect(message.to_s).to match(/pub 4096R\/59C71FB38AEE22E091C78259D06350440F759BD3 \d{4}-\d{2}-\d{2}/)
expect(message.to_s.scan(/^pub /).size).to eql(1)
teardown_list_and_mailer(list)
......@@ -1618,7 +1618,7 @@ describe "user sends keyword" do
message = Mail.create_message_to_list(raw.to_s, list.request_address, list).setup
expect(message.to).to eql(['schleuder@example.org'])
expect(message.to_s).to include("pub 4096R/59C71FB38AEE22E091C78259D06350440F759BD3 2016-12-06")
expect(message.to_s).to match(/pub 4096R\/59C71FB38AEE22E091C78259D06350440F759BD3 \d{4}-\d{2}-\d{2}/)
expect(message.to_s).to include("-----BEGIN PGP PUBLIC KEY")
teardown_list_and_mailer(list)
......@@ -1899,7 +1899,7 @@ describe "user sends keyword" do
expect(message.parts.last.parts.length).to eql(2)
expect(message.parts.last.parts.first.body.to_s).to eql(content_body)
expect(message.parts.last.parts.last.content_type.to_s).to eql("application/pgp-keys")
expect(message.parts.last.parts.last.body.decoded).to include("pub 4096R/59C71FB38AEE22E091C78259D06350440F759BD3 2016-12-06")
expect(message.parts.last.parts.last.body.decoded).to match(/pub 4096R\/59C71FB38AEE22E091C78259D06350440F759BD3 \d{4}-\d{2}-\d{2}/)
expect(message.parts.last.parts.last.body.decoded).to include("-----BEGIN PGP PUBLIC KEY BLOCK-----")
expect(message.parts.last.parts.last.body.decoded).to include("mQINBFhGvz0BEADXbbTWo/PStyTznAo/f1UobY0EiVPNKNERvYua2Pnq8BwOQ5bS")
......
......@@ -7,7 +7,7 @@ describe GPGME::Key do
key = list.key
expect(key.oneline).to eql("0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org 2016-12-06")
expect(key.oneline).to match(/0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org \d{4}-\d{2}-\d{2}/)
end
it "displays the expected attributes for an expiring key" do
......@@ -16,7 +16,7 @@ describe GPGME::Key do
key = list.key("421FBF7190640136788593CD9EE9BE5929CACC20")
expect(key.oneline).to eql("0x421FBF7190640136788593CD9EE9BE5929CACC20 expiringkey@example.org 2017-08-03 [expires: 2037-07-29]")
expect(key.oneline).to match(/0x421FBF7190640136788593CD9EE9BE5929CACC20 expiringkey@example.org \d{4}-\d{2}-\d{2} \[expires: \d{4}-\d{2}-\d{2}\]/)
end
it "displays the expected attributes for an expired key" do
......@@ -25,7 +25,7 @@ describe GPGME::Key do
key = list.key("98769E8A1091F36BD88403ECF71A3F8412D83889")
expect(key.oneline).to eql("0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2010-08-14]")
expect(key.oneline).to match(/0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]/)
end
it "displays the expected attributes for a revoked key" do
......@@ -34,7 +34,7 @@ describe GPGME::Key do
key = list.key("7E783CDE6D1EFE6D2409739C098AC83A4C0028E9")
expect(key.oneline).to eql("0x7E783CDE6D1EFE6D2409739C098AC83A4C0028E9 paz@nadir.org 2008-09-20 [revoked]")
expect(key.oneline).to match(/0x7E783CDE6D1EFE6D2409739C098AC83A4C0028E9 paz@nadir.org \d{4}-\d{2}-\d{2} \[revoked\]/)
end
# gpgme.rb doesn't report missing encryption-capability properly yet.
......@@ -44,7 +44,7 @@ describe GPGME::Key do
key = list.key("B1CD8BB15C2673C6BFD8FA4B70B2CF29E01AD53E")
expect(key.oneline).to eql("0xB1CD8BB15C2673C6BFD8FA4B70B2CF29E01AD53E signonly@example.org 2017-08-03 [not capable of encryption]")
expect(key.oneline).to match(/0xB1CD8BB15C2673C6BFD8FA4B70B2CF29E01AD53E signonly@example.org \d{4}-\d{2}-\d{2} \[not capable of encryption\]/)
end
end
end
......@@ -401,21 +401,21 @@ describe Schleuder::List do
list = create(:list)
allow_any_instance_of(GPGME::Key).to receive(:trust).and_return(:revoked)
expect(list.check_keys).to eq "This key is revoked:\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org 2016-12-06 [revoked]\n\n"
expect(list.check_keys).to match(/This key is revoked:\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org \d{4}-\d{2}-\d{2} \[revoked\]\n\n/)
end
it "adds a message if a key is disabled" do
list = create(:list)
allow_any_instance_of(GPGME::Key).to receive(:trust).and_return(:disabled)
expect(list.check_keys).to eq "This key is disabled:\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org 2016-12-06 [disabled]\n\n"
expect(list.check_keys).to match(/This key is disabled:\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org \d{4}-\d{2}-\d{2} \[disabled\]\n\n/)
end
it "adds a message if a key is invalid" do
list = create(:list)
allow_any_instance_of(GPGME::Key).to receive(:trust).and_return(:invalid)
expect(list.check_keys).to eq "This key is invalid:\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org 2016-12-06 [invalid]\n\n"
expect(list.check_keys).to match(/This key is invalid:\n0x59C71FB38AEE22E091C78259D06350440F759BD3 schleuder@example.org \d{4}-\d{2}-\d{2} \[invalid\]\n\n/)
end
end
......@@ -485,7 +485,7 @@ describe Schleuder::List do
output = list.fetch_keys('98769E8A1091F36BD88403ECF71A3F8412D83889')
end
expect(output).to include("This key was fetched (new key):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]")
expect(output).to match(/This key was fetched \(new key\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]/)
teardown_list_and_mailer(list)
end
......@@ -499,7 +499,7 @@ describe Schleuder::List do
output = list.fetch_keys('http://127.0.0.1:9999/keys/example.asc')
end
expect(output).to include("This key was fetched (new key):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]")
expect(output).to match(/This key was fetched \(new key\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]/)
teardown_list_and_mailer(list)
end
......@@ -513,7 +513,7 @@ describe Schleuder::List do
output = list.fetch_keys('admin@example.org')
end
expect(output).to include("This key was fetched (new key):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo 2010-08-13 [expired: 2017-01-20]")
expect(output).to match(/This key was fetched \(new key\):\n0x98769E8A1091F36BD88403ECF71A3F8412D83889 bla@foo \d{4}-\d{2}-\d{2} \[expired: \d{4}-\d{2}-\d{2}\]/)
teardown_list_and_mailer(list)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment