Merge pull request #5804 from betagouv/dev

2020-12-14-01
This commit is contained in:
LeSim 2020-12-14 21:42:32 +01:00 committed by GitHub
commit 4e5c1c08b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 37 deletions

1
.gitignore vendored
View file

@ -27,6 +27,7 @@ yarn-debug.log*
.yarn-integrity
/.vscode
/.idea
/public/assets
/public/packs
/public/packs-test
/node_modules

View file

@ -92,25 +92,27 @@ class BillSignature < ApplicationRecord
end
def read_signature
if attachment_changes['signature']
io = io_for_changes(attachment_changes['signature'])
io.read if io.present?
elsif signature.attached?
signature.download
end
read_attachment('signature')
end
def read_serialized
if attachment_changes['serialized']
io = io_for_changes(attachment_changes['serialized'])
io.read if io.present?
read_attachment('serialized')
end
private
def read_attachment(attachment)
if attachment_changes[attachment]
io = io_for_changes(attachment_changes[attachment])
if io.present?
io.rewind
io.read
end
elsif serialized.attached?
serialized.download
end
end
private
def io_for_changes(attachment_changes)
attachable = attachment_changes.attachable
case attachable

View file

@ -568,7 +568,7 @@ class Procedure < ApplicationRecord
if logo.attached?
Rails.application.routes.url_helpers.url_for(logo)
else
ActionController::Base.helpers.image_url("republique-francaise-logo.svg")
ActionController::Base.helpers.image_url(PROCEDURE_DEFAULT_LOGO_SRC)
end
end

View file

@ -19,7 +19,7 @@
%h2.header-section Informations de contact
%p.explication
Votre démarche sera hébergée par demarche-simplifiees.fr mais nous ne pouvons pas assurer le support des démarches. Et malgré la dématérialisation, les usagers se poseront parfois des questions légitimes sur le processus administratif.
Votre démarche sera hébergée par #{APPLICATION_NAME} mais nous ne pouvons pas assurer le support des démarches. Et malgré la dématérialisation, les usagers se poseront parfois des questions légitimes sur le processus administratif.
%br
Il est donc important que les usagers puissent vous contacter s'ils ont des questions sur votre démarche.
%br

View file

@ -41,5 +41,8 @@ APPLICATION_BASE_URL="https://www.demarches-simplifiees.fr"
# Personnalisation d'instance - Logo dans l'entête des emails ---> à placer dans "app/assets/images"
# MAILER_LOGO_SRC="mailer/instructeur_mailer/logo.png"
# Personnalisation d'instance - Logo par défaut d'une procédure ---> à placer dans "app/assets/images"
# PROCEDURE_DEFAULT_LOGO_SRC="republique-francaise-logo.svg"
# Personnalisation d'instance - fichier utilisé pour poser un filigrane sur les pièces d'identité
# WATERMARK_FILE=""

View file

@ -11,3 +11,6 @@ HEADER_LOGO_HEIGHT = ENV.fetch("HEADER_LOGO_HEIGHT", "56")
# Mailer logo
MAILER_LOGO_SRC = ENV.fetch("MAILER_LOGO_SRC", "mailer/instructeur_mailer/logo.png")
# Default logo of a procedure
PROCEDURE_DEFAULT_LOGO_SRC = ENV.fetch("PROCEDURE_DEFAULT_LOGO_SRC", "republique-francaise-logo.svg")

View file

@ -72,48 +72,41 @@ RSpec.describe BillSignature, type: :model do
end
describe 'check_signature_contents' do
let(:signature) { File.open('spec/fixtures/files/bill_signature/signature.der') }
let(:signature_date) { DateTime.parse('2019-04-30 15:30:20') }
let(:signature_digest) { Digest::SHA256.hexdigest('CECI EST UN BLOB') }
let(:current_date) { Time.zone.now }
before do
bill_signature.signature.attach(io: StringIO.new(signature), filename: 'file') if signature.present?
allow(ASN1::Timestamp).to receive(:signature_time).and_return(signature_time)
allow(ASN1::Timestamp).to receive(:signed_digest).and_return(signed_digest)
bill_signature.digest = digest
Timecop.freeze(current_date)
bill_signature.signature.attach(io: signature, filename: 'file') if signature.present?
bill_signature.digest = signature_digest
bill_signature.valid?
Timecop.return
end
context 'when the signature is correct' do
let(:signature) { 'signature' }
let(:signature_time) { 1.day.ago }
let(:digest) { 'abcd' }
let(:signed_digest) { 'abcd' }
subject { bill_signature.errors.details[:signature] }
it { expect(bill_signature.errors.details[:signature]).to be_empty }
context 'when the signature is correct' do
it { is_expected.to be_empty }
end
context 'when the signature isnt set' do
let(:signature) { nil }
let(:signature_time) { 1.day.ago }
let(:digest) { 'abcd' }
let(:signed_digest) { 'abcd' }
it { expect(bill_signature.errors.details[:signature]).to eq [error: :blank] }
it { is_expected.to eq [error: :blank] }
end
context 'when the signature time is in the future' do
let(:signature) { 'signature' }
let(:signature_time) { 1.day.from_now }
let(:digest) { 'abcd' }
let(:signed_digest) { 'abcd' }
let(:current_date) { signature_date - 1.day }
it { expect(bill_signature.errors.details[:signature]).to eq [error: :invalid_date] }
it { is_expected.to eq [error: :invalid_date] }
end
context 'when the signature doesnt match the digest' do
let(:signature) { 'signature' }
let(:signature_time) { 1.day.ago }
let(:digest) { 'abcd' }
let(:signed_digest) { 'dcba' }
let(:signature_digest) { 'dcba' }
it { expect(bill_signature.errors.details[:signature]).to eq [error: :invalid] }
it { is_expected.to eq [error: :invalid] }
end
end
end