Skip to content
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

Paf 49 test private link #98

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6b642b8
PAF-50 Deploy ims-resolver
sulthan-ahmed Mar 22, 2023
aa1f599
PAF-50 add wsdl and endpoint as secrets
sulthan-ahmed Mar 22, 2023
1f14e71
PAF-50 deploy ims-resolver
sulthan-ahmed Mar 23, 2023
2dde8ba
PAF-50 deploy ims-resolver
sulthan-ahmed Mar 23, 2023
52035b9
PAF-50 deploy ims-resolver
sulthan-ahmed Mar 23, 2023
feb0c76
PAF-50 deploy ims-resolver
sulthan-ahmed Mar 30, 2023
3b2498d
PAF-50 deploy ims-resolver
sulthan-ahmed Mar 30, 2023
331602d
PAF-50 deploy ims resolver
sulthan-ahmed Mar 30, 2023
c97540a
PAF-50 update ims resolver key names as part of k8
sulthan-ahmed Apr 3, 2023
84527e4
PAF-11: create attachments
Rhodine-orleans-lindsay Dec 20, 2022
b69e206
Merge pull request #63 from UKHomeOffice/PAF-11-attachments
Rhodine-orleans-lindsay Apr 4, 2023
3cd30c9
Merge pull request #61 from UKHomeOffice/PAF-50-deploy-ims-resolver
sulthan-ahmed Apr 6, 2023
6067174
Update README about IMS API docs
sulthan-ahmed Apr 27, 2023
21b4be5
PAF-49 Test the private link
sulthan-ahmed Apr 28, 2023
1b82cbd
WIP
sulthan-ahmed May 12, 2023
0258a00
Deploy resolver that doesn't run the commands
sulthan-ahmed May 15, 2023
ac3a82a
PAF-49 change the ims-resolver to use curl
sulthan-ahmed May 17, 2023
f5d98fb
WIP
sulthan-ahmed May 17, 2023
5f65818
WIP
sulthan-ahmed May 17, 2023
cb7a557
PAF-49 deploy resolver to test private link
sulthan-ahmed May 22, 2023
ff764b8
WIP
sulthan-ahmed May 22, 2023
519e176
Set NODE_TLS_REJECT_UNAUTHORIZED 0 in kube file
sulthan-ahmed May 23, 2023
b032e0c
WIP check we can set env variable for TLS being 0
sulthan-ahmed May 23, 2023
b8ad087
PAF-135 use ims-resolver image for private link
sulthan-ahmed May 24, 2023
132fbce
deploy tls cert - PAF-153
JHoldergov Dec 20, 2023
93e26e0
Pvt link add deploy branch
JHoldergov Dec 20, 2023
961c7f8
error message fix
JHoldergov Dec 20, 2023
73ff62b
self signed cert
JHoldergov Dec 20, 2023
96b58bf
redeploy
JHoldergov Dec 20, 2023
7970f03
redeploy
JHoldergov Dec 20, 2023
221744e
mounting cert volume
JHoldergov Dec 27, 2023
34e134c
deploy error
JHoldergov Dec 27, 2023
7250cdd
disable cert bypass
JHoldergov Dec 27, 2023
ef69f4e
configmap trial
JHoldergov Dec 28, 2023
e2ad7ab
syntax fix
JHoldergov Dec 28, 2023
fcdd91e
corrrection
JHoldergov Dec 28, 2023
33d2f9d
error solve attempt
JHoldergov Dec 28, 2023
8cf14a6
re-deployment
JHoldergov Dec 28, 2023
db85095
adjustments
JHoldergov Dec 28, 2023
9a48a8a
timeout changes
JHoldergov Dec 28, 2023
ab85e4d
adding config map
JHoldergov Dec 29, 2023
ee58af7
memory increase
JHoldergov Dec 29, 2023
db9701b
syntax
JHoldergov Dec 29, 2023
ccf462c
config on node
JHoldergov Dec 29, 2023
ea92732
Added certificate
TemitopeAyokuHO Jan 4, 2024
8f9808d
code changes for cert (trial)
JHoldergov Jan 15, 2024
7343786
syntax
JHoldergov Jan 15, 2024
0418294
untrusted source cert
JHoldergov Jan 15, 2024
ad10121
change directory
JHoldergov Jan 15, 2024
daee213
dir correction
JHoldergov Jan 15, 2024
96d7b40
try two vol mounts
JHoldergov Jan 16, 2024
858a20e
volume mounts testing
JHoldergov Jan 16, 2024
d058f1e
typo
JHoldergov Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ trigger:
branch:
- feature/*
- master
- PAF-49-test-private-link

linting: &linting
pull: if-not-exists
Expand Down Expand Up @@ -62,6 +63,7 @@ steps:
include:
- master
- feature/*
- PAF-49-test-private-link
event: [push, pull_request]

- name: setup_deploy
Expand Down Expand Up @@ -122,6 +124,7 @@ steps:
include:
- master
- feature/*
- PAF-49-test-private-link
event: [push, pull_request]

- name: image_to_quay
Expand All @@ -139,6 +142,7 @@ steps:
include:
- master
- feature/*
- PAF-49-test-private-link
event: [push, pull_request]

# Deploy to pull request UAT environment.
Expand All @@ -157,6 +161,7 @@ steps:
include:
- master
- feature/*
- PAF-49-test-private-link
event: [push, pull_request]

- name: setup_branch
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Public Allegations Form (PAF) Application built using HOF (Home Office Forms) fr

The PAF app will send data to an AWS SQS (Simple Queue Service), the [ims-resolver](https://github.com/UKHomeOffice/ims-resolver/) will pull from the queue and attempt to send the data to the IMS system. The ims-resolver is a github repo supported by the HOF team. The IMS system is hosted on EBSA hosted by a supplier, Verint.

## IMS API integration

There is some sensitive information about IMS integration. The documentation of this can be found in an internal repo
https://github.com/UKHomeOffice/ims-integration-documentation

## Getting Started

Expand Down
13 changes: 13 additions & 0 deletions apps/paf/behaviours/disable-file-upload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = superclass => class extends superclass {
locals(req, res) {
const locals = super.locals(req, res);
const images = req.sessionModel.get('images');
if (images && images.length >= 3) {
// disable file upload if attachment limit reached.
req.form.options.fields['other-info-file-upload'].attributes = [{attribute: 'disabled'}];
return locals;
}
req.form.options.fields['other-info-file-upload'].attributes = [];
return locals;
}
}
16 changes: 16 additions & 0 deletions apps/paf/behaviours/limit-documents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = superclass => class LimitDocs extends superclass {
validate(req, res, next) {
const images = req.sessionModel.get('images');
if (images && images.length >= 3 && req.form.values['other-info-file-uploads-add-another'] === 'yes') {
return next({
'other-info-file-uploads-add-another': new this.ValidationError(
'other-info-file-uploads-add-another',
{
type: 'tooMany'
}
)
});
} super.validate(req, res, next);
return next;
}
};
15 changes: 15 additions & 0 deletions apps/paf/behaviours/remove-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = superclass => class extends superclass {
configure(req, res, next) {
if (req.query.delete) {
const images = req.sessionModel.get('images') || [];
const remaining = images.filter(i => i.id !== req.query.delete);
req.log('info', `Reference: ${req.sessionModel.get('reference')}, Removing image: ${req.query.delete}`);
req.sessionModel.set('images', remaining);
const path = req.baseUrl + req.path;
return res.redirect(path);
}
return super.configure(req, res, next);
}
};
41 changes: 41 additions & 0 deletions apps/paf/behaviours/save-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

const _ = require('lodash');
const Model = require('../models/file-upload');

module.exports = name => superclass => class extends superclass {
process(req) {
if (req.files && req.files[name]) {
// set image name on values for filename extension validation
// N:B validation controller gets values from
// req.form.values and not on req.files
req.form.values[name] = req.files[name].name;
req.log('info', `Reference: ${req.sessionModel.get('reference')},
Processing image: ${req.form.values[name]}`);
}
super.process.apply(this, arguments);
}

locals(req, res, next) {
if (!Object.keys(req.form.errors).length) {
req.form.values['other-info-file-upload'] = null;
}
return super.locals(req, res, next);
}

saveValues(req, res, next) {
const images = req.sessionModel.get('images') || [];
if (req.files && req.files[name]) {
req.log('info', `Reference: ${req.sessionModel.get('reference')}, Saving image: ${req.files[name].name}`);
const image = _.pick(req.files[name], ['name', 'data', 'mimetype']);
const model = new Model(image);
return model.save()
.then(() => {
req.sessionModel.set('images', [...images, model.toJSON()]);
return super.saveValues(req, res, next);
})
.catch(next);
}
return super.saveValues.apply(this, arguments);
}
};
32 changes: 21 additions & 11 deletions apps/paf/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ module.exports = {
dependent: {
field: 'vehicle-type',
value: 'cars'
},
}
},
'crime-hgv-group': {
mixin: 'radio-group',
Expand All @@ -238,7 +238,7 @@ module.exports = {
dependent: {
field: 'vehicle-type',
value: 'hgvs'
},
}
},
'crime-lorry-group': {
mixin: 'radio-group',
Expand All @@ -252,7 +252,7 @@ module.exports = {
dependent: {
field: 'vehicle-type',
value: 'lorries'
},
}
},
'crime-van-group': {
mixin: 'radio-group',
Expand All @@ -268,7 +268,7 @@ module.exports = {
dependent: {
field: 'vehicle-type',
value: 'vans'
},
}
},
'boat-type': {
isPageHeading: true,
Expand Down Expand Up @@ -320,7 +320,7 @@ module.exports = {
dependent: {
field: 'boat-type',
value: 'carriers'
},
}
},
'crime-general-cargo-group': {
mixin: 'radio-group',
Expand All @@ -334,7 +334,7 @@ module.exports = {
dependent: {
field: 'boat-type',
value: 'general-cargos'
},
}
},
'crime-vessel-group': {
mixin: 'radio-group',
Expand All @@ -349,7 +349,7 @@ module.exports = {
dependent: {
field: 'boat-type',
value: 'vessels'
},
}
},
'boat-name': {
mixin: 'input-text'
Expand Down Expand Up @@ -913,7 +913,7 @@ module.exports = {
dependent: {
field: 'report-person-transport-type',
value: 'cars'
},
}
},
'report-person-transport-hgv-group': {
mixin: 'radio-group',
Expand All @@ -930,7 +930,7 @@ module.exports = {
dependent: {
field: 'report-person-transport-type',
value: 'hgv'
},
}
},
'report-person-transport-lorry-group': {
mixin: 'radio-group',
Expand All @@ -944,7 +944,7 @@ module.exports = {
dependent: {
field: 'report-person-transport-type',
value: 'lorries'
},
}
},
'report-person-transport-van-group': {
mixin: 'radio-group',
Expand All @@ -960,7 +960,7 @@ module.exports = {
dependent: {
field: 'report-person-transport-type',
value: 'vans'
},
}
},
'report-person-transport-make': {
mixin: 'input-text'
Expand Down Expand Up @@ -1167,6 +1167,16 @@ module.exports = {
value: 'yes'
}
},
'other-info-file-upload': {
mixin: 'input-file',
className: 'govuk-file-upload',
attributes: []
},
'add-other-info-file-upload': {
isPageHeading: true,
mixin: 'radio-group',
options: ['yes', 'no']
},
'about-you-first-name': {
mixin: 'input-text'
},
Expand Down
37 changes: 36 additions & 1 deletion apps/paf/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
'use strict';
const saveImage = require('./behaviours/save-file');
const removeImage = require('./behaviours/remove-file');
const CombineAndLoopFields = require('hof').components.combineAndLoopFields;
const limitDocs = require('./behaviours/limit-documents');
const disableUpload = require('./behaviours/disable-file-upload');
const SummaryPageBehaviour = require('hof').components.summary;
const transportBehaviour = require('./behaviours/transport-behaviour');
const Aggregate = require('./behaviours/aggregator');
Expand Down Expand Up @@ -356,7 +361,7 @@ module.exports = {
field: 'report-person-occupation',
value: 'yes'
}
},
}
]
},
'/report-person-occupation-type': {
Expand Down Expand Up @@ -662,6 +667,36 @@ module.exports = {
next: '/other-info-file-upload'
},
'/other-info-file-upload': {
behaviours: [saveImage('other-info-file-upload'), disableUpload],
fields: ['other-info-file-upload'],
continueOnEdit: true,
forks: [{
target: '/add-other-info-file-upload',
condition: req => {
if (req.form.values['other-info-file-upload']) {
return true
}
return false;
}
}],
next: '/about-you'
},
'/add-other-info-file-upload': {
template: 'list-add-looped-files',
behaviours: [CombineAndLoopFields({
groupName: 'other-info-file-uploads',
fieldsToGroup: [
'other-info-file-upload'
],
groupOptional: true,
removePrefix: 'other-',
combineValuesToSingleField: 'record',
returnTo: '/other-info-file-upload'
}), removeImage, limitDocs],
next: '/about-you',
locals: {
section: 'other-info-file-upload'
}
},
'/about-you': {
fields: ['how-did-you-find-out-about-the-crime'],
Expand Down
75 changes: 75 additions & 0 deletions apps/paf/models/file-upload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

const url = require('url');
const Model = require('hof').model;
const uuid = require('uuid').v4;
const config = require('../../../config');

module.exports = class UploadModel extends Model {
constructor(...args) {
super(...args);
this.set('id', uuid());
}

async save() {
const result = await new Promise((resolve, reject) => {
const attributes = {
url: config.upload.hostname
};
const reqConf = url.parse(this.url(attributes));
reqConf.formData = {
document: {
value: this.get('data'),
options: {
filename: this.get('name'),
contentType: this.get('mimetype')
}
}
};
reqConf.method = 'POST';
this.request(reqConf, (err, data) => {
if (err) {
return reject(err);
}
resolve(data);
});
});
this.set({ url: result.url });
return this.unset('data');
}

auth() {
if (!config.keycloak.token) {
// eslint-disable-next-line no-console
console.error('keycloak token url is not defined');
return Promise.resolve({
bearer: 'abc123'
});
}
const tokenReq = {
url: config.keycloak.token,
form: {
username: config.keycloak.username,
password: config.keycloak.password,
grant_type: 'password',
client_id: config.keycloak.clientId,
client_secret: config.keycloak.secret
},
method: 'POST'
};

return new Promise((resolve, reject) => {
this._request(tokenReq, (err, response) => {
const body = JSON.parse(response.body);

if (err || body.error) {
return reject(err || new Error(`${body.error} - ${body.error_description}`));
}

resolve({
bearer: JSON.parse(response.body).access_token
});
});
});
}
};
Loading