onfido 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +17 -1
- data/lib/onfido/api/default_api.rb +492 -79
- data/lib/onfido/api_client.rb +6 -2
- data/lib/onfido/configuration.rb +88 -0
- data/lib/onfido/models/biometric_token.rb +265 -0
- data/lib/onfido/models/biometric_token_data.rb +317 -0
- data/lib/onfido/models/biometric_token_response.rb +237 -0
- data/lib/onfido/models/biometric_token_updater.rb +262 -0
- data/lib/onfido/models/biometric_tokens_response.rb +239 -0
- data/lib/onfido/models/document_types.rb +3 -1
- data/lib/onfido/models/invalidated_biometric_token_response.rb +237 -0
- data/lib/onfido/models/invalidated_biometric_token_summary.rb +238 -0
- data/lib/onfido/models/invalidated_biometric_token_summary_deleted_items.rb +239 -0
- data/lib/onfido/models/invalidated_biometric_tokens_response.rb +237 -0
- data/lib/onfido/models/updated_biometric_token_response.rb +237 -0
- data/lib/onfido/models/watchlist_mesh_added_mentions.rb +247 -0
- data/lib/onfido/models/watchlist_mesh_alert_risk.rb +323 -0
- data/lib/onfido/models/watchlist_mesh_alert_risk1.rb +316 -0
- data/lib/onfido/models/watchlist_mesh_associate.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_date_value.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_field.rb +241 -0
- data/lib/onfido/models/watchlist_mesh_image.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_lists.rb +309 -0
- data/lib/onfido/models/watchlist_mesh_media.rb +261 -0
- data/lib/onfido/models/watchlist_mesh_name.rb +231 -0
- data/lib/onfido/models/watchlist_mesh_pep.rb +369 -0
- data/lib/onfido/models/watchlist_mesh_person.rb +283 -0
- data/lib/onfido/models/watchlist_mesh_profile.rb +273 -0
- data/lib/onfido/models/watchlist_mesh_risk_decision.rb +43 -0
- data/lib/onfido/models/watchlist_mesh_risk_detail.rb +255 -0
- data/lib/onfido/models/watchlist_mesh_risk_indicators.rb +271 -0
- data/lib/onfido/models/watchlist_mesh_sanctions.rb +309 -0
- data/lib/onfido/models/webhook.rb +11 -1
- data/lib/onfido/models/webhook_builder.rb +11 -1
- data/lib/onfido/models/webhook_create.rb +11 -1
- data/lib/onfido/models/webhook_response.rb +11 -1
- data/lib/onfido/models/webhook_update.rb +11 -1
- data/lib/onfido/models/webhook_updater.rb +11 -1
- data/lib/onfido/version.rb +1 -1
- data/lib/onfido.rb +27 -0
- data/spec/integrations/biometric_token_spec.rb +122 -0
- data/spec/integrations/document_spec.rb +8 -1
- data/spec/integrations/media/nfc_data.json +11768 -0
- data/spec/integrations/watchlist_alert_risk_spec.rb +66 -0
- data/spec/shared_contexts/with_document.rb +0 -1
- data/spec/shared_contexts/with_onfido.rb +14 -2
- data/spec/spec_helper.rb +6 -7
- metadata +57 -24
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
require_relative '../shared_contexts/with_onfido'
|
|
6
|
+
|
|
7
|
+
describe Onfido::BiometricToken do
|
|
8
|
+
describe 'Biometric tokens' do
|
|
9
|
+
include_context 'with onfido'
|
|
10
|
+
|
|
11
|
+
let(:biometric_workflow_id) { 'b79dcf69-41a0-412d-b803-d1a618730f72' }
|
|
12
|
+
let(:customer_user_id) { "test-user-id-#{SecureRandom.uuid}" }
|
|
13
|
+
let(:unique_suffix) { SecureRandom.hex(4) }
|
|
14
|
+
let(:applicant_builder) do
|
|
15
|
+
Onfido::ApplicantBuilder.new(
|
|
16
|
+
first_name: "First#{unique_suffix}",
|
|
17
|
+
last_name: "Last#{unique_suffix}",
|
|
18
|
+
email: "first.last.#{unique_suffix}@example.com",
|
|
19
|
+
consents: [
|
|
20
|
+
Onfido::ApplicantConsentBuilder.new(
|
|
21
|
+
name: Onfido::ApplicantConsentName::PRIVACY_NOTICES_READ,
|
|
22
|
+
granted: true,
|
|
23
|
+
),
|
|
24
|
+
],
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
let(:applicant_id) { onfido_api.create_applicant(applicant_builder).id }
|
|
28
|
+
let(:live_photo_file) { File.open('spec/integrations/media/sample_photo.png') }
|
|
29
|
+
let(:live_photo) do
|
|
30
|
+
onfido_api.upload_live_photo(
|
|
31
|
+
applicant_id: applicant_id,
|
|
32
|
+
file: live_photo_file,
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
let(:workflow_run_builder) do
|
|
36
|
+
Onfido::WorkflowRunBuilder.new(
|
|
37
|
+
applicant_id: applicant_id,
|
|
38
|
+
workflow_id: biometric_workflow_id,
|
|
39
|
+
customer_user_id: customer_user_id,
|
|
40
|
+
custom_data: {
|
|
41
|
+
media_ids: [
|
|
42
|
+
{
|
|
43
|
+
id: live_photo.id,
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
let(:workflow_run) { onfido_api.create_workflow_run(workflow_run_builder) }
|
|
50
|
+
let(:biometric_tokens) do
|
|
51
|
+
created_workflow_run = workflow_run
|
|
52
|
+
|
|
53
|
+
expect(created_workflow_run.customer_user_id).to eq(customer_user_id)
|
|
54
|
+
|
|
55
|
+
repeat_request_until_biometric_tokens_created(customer_user_id)
|
|
56
|
+
end
|
|
57
|
+
let(:biometric_token) { biometric_tokens.biometric_tokens.first }
|
|
58
|
+
let(:biometric_token_id) { biometric_token.uuid }
|
|
59
|
+
|
|
60
|
+
def repeat_request_until_biometric_tokens_created(user_id, max_retries = 10, interval = 3)
|
|
61
|
+
attempts = 0
|
|
62
|
+
|
|
63
|
+
loop do
|
|
64
|
+
response = onfido_api.list_biometric_tokens(user_id)
|
|
65
|
+
return response if response.biometric_tokens.any?
|
|
66
|
+
|
|
67
|
+
raise 'Biometric tokens were not created in time' if attempts >= max_retries
|
|
68
|
+
|
|
69
|
+
attempts += 1
|
|
70
|
+
sleep(interval)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'lists biometric tokens' do
|
|
75
|
+
expect(biometric_tokens).to be_an_instance_of(Onfido::BiometricTokensResponse)
|
|
76
|
+
expect(biometric_tokens.biometric_tokens.length).to be > 0
|
|
77
|
+
expect(biometric_token.uuid).not_to be_nil
|
|
78
|
+
expect(biometric_token.data.status).not_to be_nil
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'finds a biometric token' do
|
|
82
|
+
biometric_token_response = onfido_api.find_biometric_token(customer_user_id, biometric_token_id)
|
|
83
|
+
|
|
84
|
+
expect(biometric_token_response).to be_an_instance_of(Onfido::BiometricTokenResponse)
|
|
85
|
+
expect(biometric_token_response.biometric_token.uuid).to eq(biometric_token_id)
|
|
86
|
+
expect(biometric_token_response.biometric_token.data.status).not_to be_nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'updates a biometric token status' do
|
|
90
|
+
approved_status = 'approved'
|
|
91
|
+
|
|
92
|
+
updated_biometric_token = onfido_api.update_biometric_token(
|
|
93
|
+
customer_user_id,
|
|
94
|
+
biometric_token_id,
|
|
95
|
+
Onfido::BiometricTokenUpdater.new(status: approved_status),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
expect(updated_biometric_token).to be_an_instance_of(Onfido::UpdatedBiometricTokenResponse)
|
|
99
|
+
expect(updated_biometric_token.biometric_token.uuid).to eq(biometric_token_id)
|
|
100
|
+
expect(updated_biometric_token.biometric_token.data.status).to eq(approved_status)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'invalidates a biometric token successfully' do
|
|
104
|
+
invalidated_biometric_token, status_code, = onfido_api.invalidate_biometric_token_with_http_info(
|
|
105
|
+
customer_user_id,
|
|
106
|
+
biometric_token_id,
|
|
107
|
+
debug_return_type: 'Object',
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
expect(invalidated_biometric_token).to be_a(Hash)
|
|
111
|
+
expect(status_code).to eq(200)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it 'invalidates biometric tokens successfully' do
|
|
115
|
+
invalidated_biometric_tokens, status_code, = onfido_api.invalidate_biometric_tokens_with_http_info(customer_user_id)
|
|
116
|
+
|
|
117
|
+
expect(invalidated_biometric_tokens).to be_an_instance_of(Onfido::InvalidatedBiometricTokensResponse)
|
|
118
|
+
expect(invalidated_biometric_tokens.biometric_tokens.deleted_items.count).to eq(0)
|
|
119
|
+
expect(status_code).to eq(200)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -43,7 +43,14 @@ describe Onfido::Document do
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
describe 'downloading an NFC face' do
|
|
46
|
-
let(:
|
|
46
|
+
let(:nfc_document) do
|
|
47
|
+
onfido_api.upload_document(
|
|
48
|
+
Onfido::DocumentTypes::PASSPORT,
|
|
49
|
+
applicant_id,
|
|
50
|
+
File.open('spec/integrations/media/nfc_data.json')
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
let(:file) { onfido_api.download_nfc_face(nfc_document.id) }
|
|
47
54
|
|
|
48
55
|
it_behaves_like "a valid PNG file", 471345
|
|
49
56
|
end
|