dvla-application_helper 5.1.5
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 +7 -0
- data/.drone.yml +481 -0
- data/.env.template +4 -0
- data/.rspec +3 -0
- data/.rubocop.yml +21 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +674 -0
- data/Rakefile +31 -0
- data/config/settings/drone-dev.yml +41 -0
- data/config/settings/drone-ext.yml +35 -0
- data/config/settings/drone-link.yml +35 -0
- data/config/settings/drone-perf.yml +35 -0
- data/config/settings/local-dev.yml +40 -0
- data/config/settings/local-ext.yml +35 -0
- data/config/settings/local-link.yml +35 -0
- data/config/settings/local-perf.yml +35 -0
- data/config/settings.yml +29 -0
- data/config/yarp.yml +6 -0
- data/functional-tests/Rakefile +74 -0
- data/functional-tests/chutney.yml +110 -0
- data/functional-tests/features/codl.feature +170 -0
- data/functional-tests/features/codl_image_review_states.feature +140 -0
- data/functional-tests/features/csudl.feature +54 -0
- data/functional-tests/features/csudl_image_review_states.feature +20 -0
- data/functional-tests/features/step_definitions/app_domain_steps.rb +213 -0
- data/functional-tests/features/step_definitions/application_creation_steps.rb +115 -0
- data/functional-tests/features/step_definitions/image_steps.rb +144 -0
- data/functional-tests/features/step_definitions/state_machine_steps.rb +43 -0
- data/functional-tests/features/support/data/artefacts.rb +27 -0
- data/functional-tests/features/support/data/image_helpers.rb +20 -0
- data/functional-tests/features/support/data/schema_helpers.rb +3 -0
- data/functional-tests/features/support/data/string_manipulation.rb +9 -0
- data/functional-tests/features/support/env.rb +25 -0
- data/functional-tests/features/support/hooks.rb +56 -0
- data/functional-tests/features/support/yarp_integration/yarp_helpers.rb +23 -0
- data/functional-tests/features/uodl_image_review_states.feature +244 -0
- data/functional-tests/features/uodl_non_processable.feature +441 -0
- data/functional-tests/features/uodl_processable.feature +416 -0
- data/lib/dvla/application_helper/builders/V1/application_builder.rb +298 -0
- data/lib/dvla/application_helper/builders/V1/codl_application_builder.rb +205 -0
- data/lib/dvla/application_helper/builders/V1/csudl_application_builder.rb +329 -0
- data/lib/dvla/application_helper/builders/V2/base_uodl_v2_application_builder.rb +357 -0
- data/lib/dvla/application_helper/builders/V2/cop_v2_application_builder.rb +59 -0
- data/lib/dvla/application_helper/builders/V2/dup_v2_application_builder.rb +84 -0
- data/lib/dvla/application_helper/builders/V2/exc_v2_application_builder.rb +55 -0
- data/lib/dvla/application_helper/builders/V2/rep_v2_application_builder.rb +84 -0
- data/lib/dvla/application_helper/builders/V2/tyr_v2_application_builder.rb +62 -0
- data/lib/dvla/application_helper/builders/V2/uodl_v2_application_builder.rb +278 -0
- data/lib/dvla/application_helper/builders/V3/base_uodl_v3_application_builder.rb +342 -0
- data/lib/dvla/application_helper/builders/V3/cop_v3_application_builder.rb +56 -0
- data/lib/dvla/application_helper/builders/V3/dup_v3_application_builder.rb +78 -0
- data/lib/dvla/application_helper/builders/V3/exc_v3_application_builder.rb +56 -0
- data/lib/dvla/application_helper/builders/V3/rep_v3_application_builder.rb +81 -0
- data/lib/dvla/application_helper/builders/V3/tyr_v3_application_builder.rb +59 -0
- data/lib/dvla/application_helper/builders/dup_rep_builder_mixin.rb +71 -0
- data/lib/dvla/application_helper/builders/photo_builder_mixin.rb +49 -0
- data/lib/dvla/application_helper/builders/photo_signature_builder_mixin.rb +68 -0
- data/lib/dvla/application_helper/configuration.rb +37 -0
- data/lib/dvla/application_helper/constants.rb +21 -0
- data/lib/dvla/application_helper/enums/review_state.rb +30 -0
- data/lib/dvla/application_helper/enums/unable_to_prove_licence_possession_reasons.rb +8 -0
- data/lib/dvla/application_helper/factories/address.rb +21 -0
- data/lib/dvla/application_helper/factories/application_details.rb +353 -0
- data/lib/dvla/application_helper/factories/casework.rb +7 -0
- data/lib/dvla/application_helper/factories/csudl_photo_signature_image.rb +156 -0
- data/lib/dvla/application_helper/factories/csudl_photo_signature_images.rb +85 -0
- data/lib/dvla/application_helper/factories/organ_donor.rb +32 -0
- data/lib/dvla/application_helper/factories/person.rb +73 -0
- data/lib/dvla/application_helper/factories/photo_image.rb +147 -0
- data/lib/dvla/application_helper/factories/photo_images.rb +183 -0
- data/lib/dvla/application_helper/factories/photo_signature_image.rb +158 -0
- data/lib/dvla/application_helper/factories/photo_signature_images.rb +64 -0
- data/lib/dvla/application_helper/fixtures/photo/comparison_image.jpeg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/passport_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/photocard_back.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/photocard_front.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/rejected_user_uploaded_image.jpeg +0 -0
- data/lib/dvla/application_helper/fixtures/photo/user_uploaded_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/signature/csudl_signature_image.tiff +0 -0
- data/lib/dvla/application_helper/fixtures/signature/passport_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/signature/rejected_user_uploaded_image.jpg +0 -0
- data/lib/dvla/application_helper/fixtures/signature/user_uploaded_image.jpg +0 -0
- data/lib/dvla/application_helper/processors/application_status.rb +45 -0
- data/lib/dvla/application_helper/processors/application_task.rb +301 -0
- data/lib/dvla/application_helper/services/application_diary.rb +123 -0
- data/lib/dvla/application_helper/services/application_domain.rb +239 -0
- data/lib/dvla/application_helper/services/application_process_engine.rb +120 -0
- data/lib/dvla/application_helper/services/check_aws_credentials.rb +24 -0
- data/lib/dvla/application_helper/services/driving_licence_channel_api.rb +67 -0
- data/lib/dvla/application_helper/services/image_service.rb +116 -0
- data/lib/dvla/application_helper/services/image_utility.rb +82 -0
- data/lib/dvla/application_helper/services/state_machine_helpers.rb +146 -0
- data/lib/dvla/application_helper/version.rb +5 -0
- data/lib/dvla/application_helper.rb +92 -0
- data/renovate.json +4 -0
- data/scripts/application-login.sh +56 -0
- data/scripts/drone-aws-login.sh +18 -0
- data/scripts/seed_application.rb +268 -0
- data/sonar-project.properties +4 -0
- metadata +343 -0
@@ -0,0 +1,115 @@
|
|
1
|
+
When(/^I create a "(non-processable|processable)" "(.*)" application( with "(.*)" flags?)?$/) do |processable, uodl_version, flags|
|
2
|
+
# start instance of builder, allows user to pass in either CODL, UODL (V1, V2, V3) to specify the specific builder
|
3
|
+
app_builder_instance = case uodl_version
|
4
|
+
when 'UODL V1'
|
5
|
+
DVLA::Application::ApplicationBuilder.new
|
6
|
+
when 'UODL V2'
|
7
|
+
DVLA::Application::UODLV2ApplicationBuilder.new
|
8
|
+
when 'UODL V2 TYR'
|
9
|
+
DVLA::Application::TYRV2ApplicationBuilder.new
|
10
|
+
when 'UODL V2 REP'
|
11
|
+
DVLA::Application::REPV2ApplicationBuilder.new
|
12
|
+
when 'UODL V2 DUP'
|
13
|
+
DVLA::Application::DUPV2ApplicationBuilder.new
|
14
|
+
when 'UODL V2 EXC'
|
15
|
+
DVLA::Application::EXCV2ApplicationBuilder.new
|
16
|
+
when 'UODL V2 COP'
|
17
|
+
DVLA::Application::COPV2ApplicationBuilder.new
|
18
|
+
when 'UODL V3 TYR'
|
19
|
+
DVLA::Application::TYRV3ApplicationBuilder.new
|
20
|
+
when 'UODL V3 REP'
|
21
|
+
DVLA::Application::REPV3ApplicationBuilder.new
|
22
|
+
when 'UODL V3 DUP'
|
23
|
+
DVLA::Application::DUPV3ApplicationBuilder.new
|
24
|
+
when 'UODL V3 EXC'
|
25
|
+
DVLA::Application::EXCV3ApplicationBuilder.new
|
26
|
+
when 'UODL V3 COP'
|
27
|
+
DVLA::Application::COPV3ApplicationBuilder.new
|
28
|
+
when 'CODL'
|
29
|
+
DVLA::Application::CODLApplicationBuilder.new
|
30
|
+
when 'CSUDL'
|
31
|
+
DVLA::Application::CSUDLApplicationBuilder.new
|
32
|
+
else
|
33
|
+
raise "Unsupported app version: #{uodl_version}"
|
34
|
+
end
|
35
|
+
|
36
|
+
# set and stores artefacts.processable as bool
|
37
|
+
artefacts.processable = processable == 'processable'
|
38
|
+
|
39
|
+
app_attributes = []
|
40
|
+
split_flags = flags&.split(',')&.map(&:strip)
|
41
|
+
split_flags&.each do |flag|
|
42
|
+
opts = case flag
|
43
|
+
when 'with_user_image'
|
44
|
+
# with user image expects passport_available param to be passed in as either true or false
|
45
|
+
true
|
46
|
+
when 'with_driver_id'
|
47
|
+
# sets a random uuid as the driver_id and stores as an artefact
|
48
|
+
artefacts.driver_id = SecureRandom.uuid
|
49
|
+
when 'with_customer_id'
|
50
|
+
# sets a random uuid as the customer_id and stores as an artefact
|
51
|
+
artefacts.customer_id = SecureRandom.uuid
|
52
|
+
when 'is_organ_donor'
|
53
|
+
artefacts.organ_donor
|
54
|
+
when 'with_payments'
|
55
|
+
artefacts.payment = [
|
56
|
+
{
|
57
|
+
paymentId: 1234567890,
|
58
|
+
paymentStatus: 'SETTLED',
|
59
|
+
paymentAmount: '14.00',
|
60
|
+
paymentReference: 'AB1234567',
|
61
|
+
},
|
62
|
+
]
|
63
|
+
when 'with_applicant'
|
64
|
+
artefacts.applicant = DVLA::Application::PersonFactory.new.build.to_applicant
|
65
|
+
when 'with_review_state', 'with_photo_review_state'
|
66
|
+
artefacts.review_state
|
67
|
+
when 'with_signature_review_state'
|
68
|
+
artefacts.signature_review_state
|
69
|
+
when 'with_application_status'
|
70
|
+
artefacts.application_status
|
71
|
+
when 'with_driving_licence_actions'
|
72
|
+
# EXAMPLE: {updatePhoto: { photographImageId: '617d6689-e03e-44e7-962d-ceb6e158e031',}}
|
73
|
+
artefacts.driving_licence_action = { updatePhoto: { photographImageId: '617d6689-e03e-44e7-962d-ceb6e158e031' } }
|
74
|
+
when 'with_product_type'
|
75
|
+
artefacts.product_type = Settings.test.product_type.sample
|
76
|
+
when 'with_unable_to_prove_licence_possession_reason'
|
77
|
+
'LOST_OR_STOLEN'
|
78
|
+
when 'with_update_address'
|
79
|
+
{
|
80
|
+
newAddress: {
|
81
|
+
unstructuredAddress: {
|
82
|
+
line1: 'TEST 5357 Gilberto Forge',
|
83
|
+
line5: 'New Lewisfort',
|
84
|
+
postcode: 'SA3 1AD',
|
85
|
+
},
|
86
|
+
},
|
87
|
+
}
|
88
|
+
else
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
|
92
|
+
if !flag.nil?
|
93
|
+
app_attributes << if opts.nil?
|
94
|
+
SimpleSymbolize.symbolize(flag)
|
95
|
+
else
|
96
|
+
[SimpleSymbolize.symbolize(flag), (opts unless opts.nil?)]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# set processable / non-processable flag
|
102
|
+
if artefacts.processable
|
103
|
+
app_attributes << [:processable]
|
104
|
+
elsif artefacts.application_status.nil?
|
105
|
+
app_attributes << [:with_application_status, 'Started']
|
106
|
+
end
|
107
|
+
|
108
|
+
# add build flag to end of array
|
109
|
+
app_attributes << :build
|
110
|
+
|
111
|
+
LOG.info "Schema class version: #{app_builder_instance.class}".bg_magenta.black
|
112
|
+
artefacts.submitted_application = Array(app_attributes).inject(app_builder_instance) { |instance, attribute| instance.send(*attribute) }
|
113
|
+
|
114
|
+
LOG.info "\nRetrieved Application: #{JSON.pretty_generate(JSON.parse(artefacts.submitted_application.to_json))}".blue
|
115
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
And(/^the application has (a )?(Passport|User|Home Office) image(s)?$/) do |_, image_origin, multiple_images|
|
2
|
+
expected_number_images = multiple_images.nil? ? 1 : 2
|
3
|
+
LOG.info "checking if #{expected_number_images} active images are present for: #{image_origin} image"
|
4
|
+
passport_images = artefacts.retrieved_application.images.find_all { |image| image.image_origin_type == image_origin && image.image_status == 'Active' }
|
5
|
+
expect(passport_images.length).to be(expected_number_images), "Expected #{expected_number_images} #{image_origin} images with status of Active"
|
6
|
+
end
|
7
|
+
|
8
|
+
And(/^the application has (unique_image_ids|static_image_ids) for photos$/) do |unique|
|
9
|
+
if unique == 'unique_image_ids'
|
10
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'Passport' }.image_id).to_not eq(DVLA::Application::PhotoImageFactory::PASSPORT_IMAGE_SERVICE_ID), 'Expected seeded image_id for Driving Licence to NOT MATCH static uuid'
|
11
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'User' }.image_id).to_not eq(DVLA::Application::PhotoImageFactory::USER_IMAGE_ID), 'Expected seeded image_id for Driving Licence to NOT MATCH static uuid'
|
12
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'Driving Licence' }.image_id).to_not eq(DVLA::Application::PhotoImageFactory::COMPARISON_IMAGE_ID), 'Expected seeded image_id for Driving Licence to NOT MATCH static uuid'
|
13
|
+
else
|
14
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'Passport' }.image_id).to eq(DVLA::Application::PhotoImageFactory::PASSPORT_IMAGE_SERVICE_ID), 'Expected seeded image_id for Driving Licence to MATCH static uuid'
|
15
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'User' }.image_id).to eq(DVLA::Application::PhotoImageFactory::USER_IMAGE_ID), 'Expected seeded image_id for Driving Licence to MATCH static uuid'
|
16
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'Driving Licence' }.image_id).to eq(DVLA::Application::PhotoImageFactory::COMPARISON_IMAGE_ID), 'Expected seeded image_id for Driving Licence to MATCH static uuid'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
And(/^the application has (unique_image_ids|static_image_ids) for photos and signatures$/) do |unique|
|
21
|
+
if unique == 'unique_image_ids'
|
22
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'Passport' && image.image_type == 'Photo' }.image_id).to_not eq(DVLA::Application::PhotoSignatureImageFactory::PASSPORT_COMPARISON_IMAGE_ID), 'Expected seeded image_id for Driving Licence to NOT MATCH static uuid'
|
23
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'User' && image.image_type == 'Photo' }.image_id).to_not eq(DVLA::Application::PhotoImageFactory::USER_IMAGE_ID), 'Expected seeded image_id for Driving Licence to NOT MATCH static uuid'
|
24
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'User' && image.image_type == 'Signature' }.image_id).to_not eq(DVLA::Application::PhotoSignatureImageFactory::USER_SIGNATURE_IMAGE_ID), 'Expected seeded image_id for Driving Licence to NOT MATCH static uuid'
|
25
|
+
else
|
26
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'Passport' && image.image_type == 'Photo' }.image_id).to eq(DVLA::Application::PhotoSignatureImageFactory::PASSPORT_COMPARISON_IMAGE_ID), 'Expected seeded image_id for Driving Licence to MATCH static uuid'
|
27
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'User' && image.image_type == 'Photo' }.image_id).to eq(DVLA::Application::PhotoImageFactory::USER_IMAGE_ID), 'Expected seeded image_id for Driving Licence to MATCH static uuid'
|
28
|
+
expect(artefacts.retrieved_application.images.find { |image| image.image_origin_type == 'User' && image.image_type == 'Signature' }.image_id).to eq(DVLA::Application::PhotoSignatureImageFactory::USER_SIGNATURE_IMAGE_ID), 'Expected seeded image_id for Driving Licence to MATCH static uuid'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Given(/^I want a specific (Photo|Signature) review state of "([^"]*)" to be set$/) do |image_type, review_state|
|
33
|
+
if image_type == 'Photo'
|
34
|
+
artefacts.review_state = DVLA::Application::ReviewState.const_get(review_state)
|
35
|
+
else
|
36
|
+
artefacts.signature_review_state = DVLA::Application::SignatureReviewState.const_get(review_state)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
And(/^the (CSUDL )?application contains the seeded (Photo|Signature) review state of "([^"]*)"$/) do |is_csudl, image_type, review_state|
|
42
|
+
app_type = is_csudl.nil? ? 'UODL' : 'CSUDL'
|
43
|
+
active_user_image = get_user_image(images: artefacts.retrieved_application.images, image_type:, app_type: app_type)
|
44
|
+
|
45
|
+
case review_state
|
46
|
+
when 'CLERK_IN_PROGRESS'
|
47
|
+
expect(active_user_image.review_history.empty?).to be(true), 'Error, clerk in progress state, use image review should be empty'
|
48
|
+
when 'CLERK_REJECTED'
|
49
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Rejection on standards', review_level: 'Clerk', outcome_reasons_required: true)
|
50
|
+
when 'CLERK_REFER_TO_SUPERVISOR_STANDARDS'
|
51
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Referral at standards', review_level: 'Clerk')
|
52
|
+
when 'CLERK_REFER_TO_SUPERVISOR_COMPARE'
|
53
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Referral at compare', review_level: 'Clerk')
|
54
|
+
when 'CLERK_APPROVED'
|
55
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Success', review_level: 'Clerk')
|
56
|
+
when 'SUPERVISOR_REJECTED'
|
57
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Rejection on standards', review_level: 'Supervisor', outcome_reasons_required: true)
|
58
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at standards', review_level: 'Clerk')
|
59
|
+
when 'SUPERVISOR_REFER_TO_FRAUD'
|
60
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Referral at compare', review_level: 'Supervisor')
|
61
|
+
if artefacts.processable
|
62
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at compare', review_level: 'Clerk')
|
63
|
+
else
|
64
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at standards', review_level: 'Clerk')
|
65
|
+
end
|
66
|
+
when 'SUPERVISOR_APPROVED'
|
67
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Success', review_level: 'Supervisor')
|
68
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at standards', review_level: 'Clerk')
|
69
|
+
when 'FRAUD_BEGIN_INVESTIGATION'
|
70
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Begin investigation', review_level: 'Fraud', outcome_reasons_required: true)
|
71
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at compare', review_level: 'Supervisor')
|
72
|
+
if artefacts.processable
|
73
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at compare', review_level: 'Clerk')
|
74
|
+
else
|
75
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at standards', review_level: 'Clerk')
|
76
|
+
end
|
77
|
+
when 'FRAUD_APPROVED'
|
78
|
+
if artefacts.processable
|
79
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Success', review_level: 'Fraud')
|
80
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at compare', review_level: 'Supervisor')
|
81
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at standards', review_level: 'Clerk')
|
82
|
+
else
|
83
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Referral at compare', review_level: 'Clerk')
|
84
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at standards', review_level: 'Clerk')
|
85
|
+
end
|
86
|
+
when 'FRAUD_REJECTED'
|
87
|
+
if artefacts.processable
|
88
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Rejection on standards', review_level: 'Fraud', outcome_reasons_required: true)
|
89
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at compare', review_level: 'Supervisor')
|
90
|
+
else
|
91
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Rejection on standards', review_level: 'Clerk', outcome_reasons_required: true)
|
92
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at compare', review_level: 'Clerk')
|
93
|
+
end
|
94
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at standards', review_level: 'Clerk')
|
95
|
+
when 'FRAUD_REVIEW_REJECTION_WITH_REFUND'
|
96
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Rejection with refund', review_level: 'Fraud review')
|
97
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Begin investigation', review_level: 'Fraud', outcome_reasons_required: true)
|
98
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at compare', review_level: 'Supervisor')
|
99
|
+
if artefacts.processable
|
100
|
+
assert_review_history(review_history: active_user_image.review_history[3], outcome: 'Referral at compare', review_level: 'Clerk')
|
101
|
+
else
|
102
|
+
assert_review_history(review_history: active_user_image.review_history[3], outcome: 'Referral at standards', review_level: 'Clerk')
|
103
|
+
end
|
104
|
+
when 'FRAUD_REVIEW_REJECTION_WITHOUT_REFUND'
|
105
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Rejection no refund', review_level: 'Fraud review')
|
106
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Begin investigation', review_level: 'Fraud', outcome_reasons_required: true)
|
107
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at compare', review_level: 'Supervisor')
|
108
|
+
if artefacts.processable
|
109
|
+
assert_review_history(review_history: active_user_image.review_history[3], outcome: 'Referral at compare', review_level: 'Clerk')
|
110
|
+
else
|
111
|
+
assert_review_history(review_history: active_user_image.review_history[3], outcome: 'Referral at standards', review_level: 'Clerk')
|
112
|
+
end
|
113
|
+
when 'FRAUD_REVIEW_APPROVED'
|
114
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Success', review_level: 'Fraud review')
|
115
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Begin investigation', review_level: 'Fraud', outcome_reasons_required: true)
|
116
|
+
assert_review_history(review_history: active_user_image.review_history[2], outcome: 'Referral at compare', review_level: 'Supervisor')
|
117
|
+
if artefacts.processable
|
118
|
+
assert_review_history(review_history: active_user_image.review_history[3], outcome: 'Referral at compare', review_level: 'Clerk')
|
119
|
+
else
|
120
|
+
assert_review_history(review_history: active_user_image.review_history[3], outcome: 'Referral at standards', review_level: 'Clerk')
|
121
|
+
end
|
122
|
+
else
|
123
|
+
Raise DVLA::Application.logger.warn 'Unknown review state passed in'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
And(/^the application contains the seeded Comparison review state of "([^"]*)"$/) do |review_state|
|
128
|
+
active_user_image = get_user_image(images: artefacts.retrieved_application.images, image_type: 'Photo')
|
129
|
+
active_comparison_image = get_comparison_image(images: artefacts.retrieved_application.images)
|
130
|
+
|
131
|
+
case review_state
|
132
|
+
when 'CLERK_REJECT_COMPARISON_PHOTO'
|
133
|
+
assert_review_history(review_history: active_comparison_image.review_history[0], outcome: 'Reject comparison photo', review_level: 'Clerk')
|
134
|
+
when 'FRAUD_REJECT_COMPARISON_PHOTO'
|
135
|
+
assert_review_history(review_history: active_comparison_image.review_history[0], outcome: 'Reject comparison photo', review_level: 'Fraud')
|
136
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Referral at compare', review_level: 'Supervisor')
|
137
|
+
assert_review_history(review_history: active_user_image.review_history[1], outcome: 'Referral at standards', review_level: 'Clerk')
|
138
|
+
when 'SUPERVISOR_REJECT_COMPARISON_PHOTO'
|
139
|
+
assert_review_history(review_history: active_comparison_image.review_history[0], outcome: 'Reject comparison photo', review_level: 'Supervisor')
|
140
|
+
assert_review_history(review_history: active_user_image.review_history[0], outcome: 'Referral at standards', review_level: 'Clerk')
|
141
|
+
else
|
142
|
+
raise DVLA::Application.logger.warn 'Unknown review state passed in'
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
And(/^the state machine is waiting on the PreparationHook$/) do
|
2
|
+
last_entered_state = nil
|
3
|
+
BlockRepeater::Repeater.new do
|
4
|
+
DVLA::Application.logger.info 'Waiting for state machine to start Preparation hook'.blue
|
5
|
+
execution_instance = DVLA::Application::StateMachineExecution.new.generate_execution_arn(execution_uuid: artefacts.submitted_application.application_id,
|
6
|
+
state_machine_name: 'application-process-engine-fulfilment',
|
7
|
+
calling_service: 'application-process-engine')
|
8
|
+
events = execution_instance.get_history.data[:events].reverse
|
9
|
+
events.each do |event|
|
10
|
+
unless event[:state_entered_event_details].nil?
|
11
|
+
last_entered_state = event[:state_entered_event_details][:name]
|
12
|
+
break
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end.until do
|
16
|
+
DVLA::Application.logger.info "Current hook: #{last_entered_state}".blue
|
17
|
+
last_entered_state == 'PreparationHook'
|
18
|
+
end.repeat(times: 10, delay: 3)
|
19
|
+
|
20
|
+
expect(last_entered_state).to eq 'PreparationHook'
|
21
|
+
end
|
22
|
+
|
23
|
+
And(/^I allow the (state machine time to be started|application actions time to be updated)$/) do |_|
|
24
|
+
# Reviewed this step and i saw no flakiness with dropping the sleep down to 1 second, updated to 2 seconds for now to review
|
25
|
+
LOG.info 'Waiting for 2 seconds to allow the state machine / lambdas to process'.blue
|
26
|
+
sleep 2
|
27
|
+
end
|
28
|
+
|
29
|
+
And(/^the application process engine fulfilment execution has a status of "([^"]*)"$/) do |expected_status|
|
30
|
+
actual_execution_status = nil
|
31
|
+
BlockRepeater::Repeater.new do
|
32
|
+
LOG.info("Waiting for the state machine to reach status of: #{expected_status}")
|
33
|
+
execution_instance = DVLA::Application::StateMachineExecution.new.generate_execution_arn(execution_uuid: artefacts.submitted_application.application_id,
|
34
|
+
state_machine_name: 'application-process-engine-fulfilment',
|
35
|
+
calling_service: 'application-process-engine')
|
36
|
+
|
37
|
+
actual_execution_status = execution_instance.describe_execution.data[:status]
|
38
|
+
LOG.info("The status of the execution is: #{actual_execution_status}")
|
39
|
+
end.until do
|
40
|
+
actual_execution_status == expected_status
|
41
|
+
end.repeat(times: 15, delay: 4)
|
42
|
+
expect(actual_execution_status).to eq(expected_status)
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# A lightweight class (Struct) to hold all the vars we'll be using in the tests to avoid
|
2
|
+
# the proliferation of @vars
|
3
|
+
Struct.new('TestArtefacts',
|
4
|
+
:applicant,
|
5
|
+
:application_status,
|
6
|
+
:application_id,
|
7
|
+
:customer_id,
|
8
|
+
:driver_id,
|
9
|
+
:driving_licence_action,
|
10
|
+
:execution_response,
|
11
|
+
:organ_donor,
|
12
|
+
:payment,
|
13
|
+
:processable,
|
14
|
+
:product_type,
|
15
|
+
:retrieved_application,
|
16
|
+
:review_state,
|
17
|
+
:signature_review_state,
|
18
|
+
:submitted_application) do
|
19
|
+
# naked asterisk - a splat operator that allow any number of arguments to be passed in
|
20
|
+
def initialize(*)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def artefacts
|
26
|
+
@artefacts ||= Struct::TestArtefacts.new
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
def get_user_image(images:, image_type:, app_type: 'UODL')
|
2
|
+
if app_type === 'CSUDL'
|
3
|
+
return images.find { |image| image.image_origin_type == 'Counter Service' && image.image_type == image_type }
|
4
|
+
end
|
5
|
+
|
6
|
+
images.find { |image| image.image_origin_type == 'User' && image.image_type == image_type && image.image_source == 'driving-licence-image-service' }
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_comparison_image(images:)
|
10
|
+
images.find { |image| image.image_origin_type == 'Home Office' && image.image_source == 'driving-licence-image-service' && image.image_purpose == 'Comparison' }
|
11
|
+
end
|
12
|
+
|
13
|
+
def assert_review_history(review_history:, outcome:, review_level:, outcome_reasons_required: false)
|
14
|
+
expect(review_history.outcome).to eq(outcome), "Expected image outcome: #{outcome} did not match the retrieved image outcome: #{review_history.outcome}"
|
15
|
+
expect(review_history.review_level).to eq(review_level), "Expected image review level: #{review_level} did not match the retrieved image review level: #{review_history.review_level}"
|
16
|
+
expect(review_history.task_id.empty?).to be(false), 'Expected taskId to be present but none found'
|
17
|
+
|
18
|
+
# check outcome reasons are not empty if they are required
|
19
|
+
expect(review_history.outcome_reasons.empty?).to be(false), 'Expected outcome_reasons to be present but none found' if outcome_reasons_required
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'rspec/expectations'
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
require 'dvla/application_helper'
|
7
|
+
|
8
|
+
# Allows creation and use of the config/settings.yml
|
9
|
+
environment = ENV.fetch('ENVIRONMENT', 'local-dev')
|
10
|
+
Config.load_and_set_settings(Config.setting_files('./config', environment))
|
11
|
+
|
12
|
+
# Application helper gem config
|
13
|
+
DVLA::Application.config do |config|
|
14
|
+
config.environment = environment
|
15
|
+
end
|
16
|
+
|
17
|
+
# Configure and initialise Logger
|
18
|
+
configuration = DVLA::Herodotus.config do |config|
|
19
|
+
config.display_pid = true
|
20
|
+
end
|
21
|
+
|
22
|
+
LOG = DVLA::Herodotus.logger('Application Helper', config: configuration)
|
23
|
+
|
24
|
+
# Set the Logger Level to output in terminal
|
25
|
+
LOG.level = Logger.const_get(Settings.logs.log_level)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Before('@wip') do |_scenario|
|
2
|
+
ENV['wip'] = 'true'
|
3
|
+
skip_this_scenario
|
4
|
+
end
|
5
|
+
|
6
|
+
Before do |scenario|
|
7
|
+
DVLA::Application.logger.new_scenario(scenario.id)
|
8
|
+
# LOG.new_scenario(scenario.id)
|
9
|
+
DVLA::Application.logger.info "Started running scenario: #{scenario.name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
# custom: delete any images which have been stored in S3 during test
|
13
|
+
After('@delete_images') do
|
14
|
+
artefacts.retrieved_application.images.each do |image|
|
15
|
+
response = DVLA::Application::ImageService.image_service_http_post(endpoint: 'set-image-retention', body: DVLA::Application::ImageService.image_retention_body(false, image.image_id, image.image_origin_type))
|
16
|
+
DVLA::Application.logger.info"Image ID: #{image.image_id} retention has been set to delete"
|
17
|
+
DVLA::Application.logger.info "Image retention response status #{response.status}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO: add this one in once Diary helpers has been added into the main gems services
|
22
|
+
# custom: delete any left over diary triggers
|
23
|
+
# After do
|
24
|
+
# LOG.info "Attempting to delete any triggers for application: #{artefacts.application_id}"
|
25
|
+
# delete_triggers_by_app_id(app_id: artefacts.application_id)
|
26
|
+
# end
|
27
|
+
|
28
|
+
After do
|
29
|
+
unless ENV['wip']
|
30
|
+
DVLA::Application.logger.info 'State machine clean up, attempting to abort execution'.blue
|
31
|
+
DVLA::Application.logger.info "Attempting to abort any execution for application: #{artefacts.submitted_application.application_id}".blue
|
32
|
+
execution_instance = DVLA::Application::StateMachineExecution.new.generate_execution_arn(execution_uuid: artefacts.submitted_application.application_id,
|
33
|
+
state_machine_name: 'application-process-engine-fulfilment',
|
34
|
+
calling_service: 'application-process-engine')
|
35
|
+
|
36
|
+
response = execution_instance.stop_execution
|
37
|
+
DVLA::Application.logger.info response.to_s.blue
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
After do |scenario|
|
42
|
+
if ENV['YARP_ENABLED'] == 'true' && scenario.failed?
|
43
|
+
add_attachments(scenario_name: generate_scenario_name(scenario: scenario))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Build scenario name with line number for unique file name in logs
|
48
|
+
def generate_scenario_name(scenario:)
|
49
|
+
line_number = scenario
|
50
|
+
.location
|
51
|
+
.inspect
|
52
|
+
.split(':')
|
53
|
+
.last
|
54
|
+
.tr('>', '')
|
55
|
+
"#{scenario.name.slice(0..23)}-#{line_number}"
|
56
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def add_attachments(scenario_name:)
|
4
|
+
LOG.info { "Taking attachment of '#{scenario_name}'" }
|
5
|
+
|
6
|
+
report_generated_time = Time.now.strftime('%Y-%m-%d_%H-%M-%S')
|
7
|
+
attachments_directory = "./failure-reports/#{scenario_name}"
|
8
|
+
|
9
|
+
# FileUtils.mkdir_p("#{attachments_directory}/screenshots")
|
10
|
+
FileUtils.mkdir_p("#{attachments_directory}/test-data")
|
11
|
+
|
12
|
+
# screenshot_path = "#{attachments_directory}/screenshots/#{report_generated_time}.png"
|
13
|
+
test_data_path = "#{attachments_directory}/test-data/#{report_generated_time}.json"
|
14
|
+
|
15
|
+
File.open(test_data_path, 'w') { |f| f.write(JSON.pretty_generate(artefacts.as_json)) }
|
16
|
+
|
17
|
+
# Capybara.save_screenshot(screenshot_path, full: true)
|
18
|
+
|
19
|
+
if Settings.yarp.enabled.to_s.eql?('true')
|
20
|
+
# attach(screenshot_path, 'image/png', 'Test Image')
|
21
|
+
attach(test_data_path, 'application/json', 'Test Data')
|
22
|
+
end
|
23
|
+
end
|