-
Notifications
You must be signed in to change notification settings - Fork 166
LG-10889: image metric error #9426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
22ce3e1
8a3e2f2
84a5a29
df2d15c
c8c08ee
d4d9a78
76d9886
d02e2f3
f151298
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,29 @@ def metric_name | |
| def timeout | ||
| IdentityConfig.store.acuant_get_results_timeout | ||
| end | ||
|
|
||
| def errors_from_http_status(status) | ||
| case status | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
| when 438 | ||
| { | ||
| general: [Errors::IMAGE_LOAD_FAILURE], | ||
| front: [Errors::IMAGE_LOAD_FAILURE_FIELD], | ||
| back: [Errors::IMAGE_LOAD_FAILURE_FIELD], | ||
| } | ||
| when 439 | ||
| { | ||
| general: [Errors::PIXEL_DEPTH_FAILURE], | ||
| front: [Errors::PIXEL_DEPTH_FAILURE_FIELD], | ||
| back: [Errors::PIXEL_DEPTH_FAILURE_FIELD], | ||
| } | ||
| when 440 | ||
| { | ||
| general: [Errors::IMAGE_SIZE_FAILURE], | ||
| front: [Errors::IMAGE_SIZE_FAILURE_FIELD], | ||
| back: [Errors::IMAGE_SIZE_FAILURE_FIELD], | ||
| } | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,12 +78,18 @@ module DocAuthRouter | |
| DocAuth::Errors::GLARE_LOW_BOTH_SIDES => 'doc_auth.errors.glare.top_msg_plural', | ||
| # i18n-tasks-use t('doc_auth.errors.glare.failed_short') | ||
| DocAuth::Errors::GLARE_LOW_FIELD => 'doc_auth.errors.glare.failed_short', | ||
| # i18n-tasks-use t('doc_auth.errors.http.image_load') | ||
| DocAuth::Errors::IMAGE_LOAD_FAILURE => 'doc_auth.errors.http.image_load', | ||
| # i18n-tasks-use t('doc_auth.errors.http.pixel_depth') | ||
| DocAuth::Errors::PIXEL_DEPTH_FAILURE => 'doc_auth.errors.http.pixel_depth', | ||
| # i18n-tasks-use t('doc_auth.errors.http.image_size') | ||
| DocAuth::Errors::IMAGE_SIZE_FAILURE => 'doc_auth.errors.http.image_size', | ||
| # i18n-tasks-use t('doc_auth.errors.http.image_load.top_msg') | ||
| DocAuth::Errors::IMAGE_LOAD_FAILURE => 'doc_auth.errors.http.image_load.top_msg', | ||
| # i18n-tasks-use t('doc_auth.errors.http.image_load.failed_short') | ||
| DocAuth::Errors::IMAGE_LOAD_FAILURE_FIELD => 'doc_auth.errors.http.image_load.failed_short', | ||
| # i18n-tasks-use t('doc_auth.errors.http.pixel_depth.top_msg') | ||
| DocAuth::Errors::PIXEL_DEPTH_FAILURE => 'doc_auth.errors.http.pixel_depth.top_msg', | ||
| # i18n-tasks-use t('doc_auth.errors.http.pixel_depth.failed_short') | ||
| DocAuth::Errors::PIXEL_DEPTH_FAILURE_FIELD => 'doc_auth.errors.http.pixel_depth.failed_short', | ||
| # i18n-tasks-use t('doc_auth.errors.http.image_size.top_msg') | ||
| DocAuth::Errors::IMAGE_SIZE_FAILURE => 'doc_auth.errors.http.image_size.top_msg', | ||
| # i18n-tasks-use t('doc_auth.errors.http.image_size.failed_short') | ||
| DocAuth::Errors::IMAGE_SIZE_FAILURE_FIELD => 'doc_auth.errors.http.image_size.failed_short', | ||
| # i18n-tasks-use t('doc_auth.errors.general.fallback_field_level') | ||
| DocAuth::Errors::FALLBACK_FIELD_LEVEL => 'doc_auth.errors.general.fallback_field_level', | ||
| }.freeze | ||
|
|
@@ -122,7 +128,9 @@ def translate_doc_auth_errors!(response) | |
| error_keys = DocAuth::ErrorGenerator::ERROR_KEYS.dup | ||
|
|
||
| error_keys.each do |category| | ||
| response.errors[category]&.map! do |plain_error| | ||
| cat_errors = response.errors[category] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read the commit message, and that's an interesting bug! Glad you figured out a way to fix it. This looks good.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eileen-nava , yeah very similar to the one we have with hash keys collision. Here I have some test case failed and some worked. |
||
| next unless cat_errors | ||
| translated_cat_errors = cat_errors.map do |plain_error| | ||
| error_key = ERROR_TRANSLATIONS[plain_error] | ||
| if error_key | ||
| I18n.t(error_key) | ||
|
|
@@ -131,6 +139,7 @@ def translate_doc_auth_errors!(response) | |
| I18n.t('doc_auth.errors.general.no_liveness') | ||
| end | ||
| end | ||
| response.errors[category] = translated_cat_errors | ||
| end | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -305,6 +305,47 @@ | |
| end | ||
| end | ||
|
|
||
| context 'when image upload fails with 4xx status' do | ||
| before do | ||
| status = 440 | ||
| errors = { general: [DocAuth::Errors::IMAGE_SIZE_FAILURE], | ||
| front: [DocAuth::Errors::IMAGE_SIZE_FAILURE_FIELD] } | ||
| message = [ | ||
| self.class.name, | ||
| 'Unexpected HTTP response', | ||
| status, | ||
| ].join(' ') | ||
| exception = DocAuth::RequestError.new(message, status) | ||
| response = DocAuth::Response.new( | ||
| success: false, | ||
| errors: errors, | ||
| exception: exception, | ||
| extra: { vendor: 'Mock' }, | ||
| ) | ||
| DocAuth::Mock::DocAuthMockClient.mock_response!( | ||
| method: :post_front_image, | ||
| response: response, | ||
| ) | ||
| end | ||
|
|
||
| it 'returns error response' do | ||
| action | ||
| expect(response.status).to eq(400) | ||
| expect(json[:success]).to eq(false) | ||
| expect(json[:remaining_attempts]).to be_a_kind_of(Numeric) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻 |
||
| expect(json[:errors]).to eq [ | ||
| { | ||
| field: 'general', | ||
| message: I18n.t('doc_auth.errors.http.image_size.top_msg'), | ||
| }, | ||
| { | ||
| field: 'front', | ||
| message: I18n.t('doc_auth.errors.http.image_size.failed_short'), | ||
| }, | ||
| ] | ||
| end | ||
| end | ||
|
|
||
| context 'when image upload succeeds' do | ||
| it 'returns a successful response and modifies the session' do | ||
| action | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.