1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

refactor: move Postal::DKIMHeader to app/util/dkim_header

هذا الالتزام موجود في:
Adam Cooke
2024-02-21 21:05:36 +00:00
الأصل ed6da11b65
التزام 77faf886b3
4 ملفات معدلة مع 132 إضافات و134 حذوفات

عرض الملف

@@ -1,34 +0,0 @@
# frozen_string_literal: true
require "rails_helper"
describe Postal::DKIMHeader do
examples = Rails.root.join("spec/examples/dkim_signing/*.msg")
Dir[examples].each do |path|
contents = File.read(path)
frontmatter, email = contents.split(/^---\n/m, 2)
frontmatter = YAML.safe_load(frontmatter)
email.strip
it "works with #{path.split('/').last}" do
mocked_time = Time.at(frontmatter["time"].to_i)
allow(Time).to receive(:now).and_return(mocked_time)
domain = instance_double("Domain")
allow(domain).to receive(:dkim_status).and_return("OK")
allow(domain).to receive(:name).and_return(frontmatter["domain"])
allow(domain).to receive(:dkim_key).and_return(OpenSSL::PKey::RSA.new(frontmatter["private_key"]))
allow(domain).to receive(:dkim_identifier).and_return(frontmatter["dkim_identifier"])
expectation = "DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n" \
"\td=#{frontmatter['domain']};\r\n" \
"\ts=#{frontmatter['dkim_identifier']}; t=#{mocked_time.to_i};\r\n" \
"\tbh=#{frontmatter['bh']};\r\n" \
"\th=#{frontmatter['headers']};\r\n" \
"\tb=#{frontmatter['b'].scan(/.{1,72}/).join("\r\n\t")}"
header = described_class.new(domain, email)
expect(header.dkim_header).to eq expectation
end
end
end