From c89d283f9ad3ed92ef4de60060c012509a38c86b Mon Sep 17 00:00:00 2001 From: DiogoAndreBotas Date: Wed, 19 Feb 2025 09:48:04 +0000 Subject: [PATCH] Add tests for downloadNfcFace endpoint Add tests for /documents/{document_id}/nfc_face endpoint, added to the OpenAPI spec in onfido/onfido-openapi-spec@c479418 --- spec/integrations/document_spec.rb | 16 ++++++++++++++-- spec/shared_contexts/with_document.rb | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/spec/integrations/document_spec.rb b/spec/integrations/document_spec.rb index 2e03594..7b4aa54 100644 --- a/spec/integrations/document_spec.rb +++ b/spec/integrations/document_spec.rb @@ -34,13 +34,25 @@ end it 'cannot download an inexistent document' do - inexistent_document_id = '00000000-0000-0000-0000-000000000000' - expect { onfido_api.download_document(inexistent_document_id) }.to raise_error(Onfido::ApiError) { |e| expect(e.code).to eq(404) } end + + it 'downloads an NFC face' do + file = onfido_api.download_nfc_face(nfc_face_id) + + expect(file.size).to be > 0 + end + + it 'cannot download an inexistent NFC face' do + expect { + onfido_api.download_nfc_face(inexistent_document_id) + }.to raise_error(Onfido::ApiError) { |e| + expect(e.code).to eq(404) + } + end end end diff --git a/spec/shared_contexts/with_document.rb b/spec/shared_contexts/with_document.rb index d1a1be5..d520598 100644 --- a/spec/shared_contexts/with_document.rb +++ b/spec/shared_contexts/with_document.rb @@ -10,4 +10,8 @@ let(:document) { onfido_api.upload_document(Onfido::DocumentTypes::PASSPORT, applicant_id, document_file) } let!(:document_id) { document.id } + + let(:nfc_face_id) { 'cc2dc25f-2df6-4f8f-a5aa-60f49cef9b3c' } + + let(:inexistent_document_id) { '00000000-0000-0000-0000-000000000000' } end