Skip to content

Commit b0bd0f4

Browse files
committed
apm-1486: switch to egress proxy
1 parent 25bd7ca commit b0bd0f4

8 files changed

Lines changed: 6232 additions & 10 deletions

File tree

docker/async-slowapp/package-lock.json

Lines changed: 3096 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/sync-wrap/package-lock.json

Lines changed: 3093 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/sync-wrap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"uuid": "^8.3.2"
1515
},
1616
"devDependencies": {
17-
"chai": "^4 .2.0",
17+
"chai": "^4.2.0",
1818
"mocha": "^7.2.0",
1919
"mocha-junit-reporter": "^1.23.3",
2020
"mocha-multi": "^1.1.3",

docker/sync-wrap/src/app.google.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe("express with google upstream and botli decompress", function () {
1919
env = process.env;
2020
let app = require("./app");
2121
app.setup({
22-
UPSTREAM: "https://www.google.co.uk",
22+
UPSTREAM: "www.google.co.uk",
2323
LOG_LEVEL: "DEBUG",
2424
UNBOTLI: "true"
2525
});
@@ -88,7 +88,11 @@ describe("express with google upstream without botli decompress", function () {
8888
env = process.env;
8989

9090
let app = require("./app");
91-
app.setup({UPSTREAM: "https://www.google.co.uk", LOG_LEVEL: (process.env.NODE_ENV === "test" ? "warn": "debug"), UNBOTLI: "false"});
91+
app.setup({
92+
UPSTREAM: "www.google.co.uk",
93+
LOG_LEVEL: (process.env.NODE_ENV === "test" ? "warn": "debug"),
94+
UNBOTLI: "false"
95+
});
9296
server = app.start();
9397
});
9498

docker/sync-wrap/src/app.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,26 @@ const app = express();
55
const log = require("loglevel");
66
const uuid = require('uuid');
77

8+
9+
function stripchars(str, chars) {
10+
var start = 0, end = str.length;
11+
12+
while(start < end && chars.indexOf(str[start]) >= 0)
13+
++start;
14+
15+
while(end > start && chars.indexOf(str[end - 1]) >= 0)
16+
--end;
17+
18+
return (start > 0 || end < str.length) ? str.substring(start, end) : str;
19+
}
20+
21+
822
function setup(options) {
923
options = options || {};
1024
app.locals.app_name = options.APP_NAME || 'sync-wrap';
11-
app.locals.upstream = new URL(options.UPSTREAM || "http://localhost:9003");
25+
let upstream = stripchars(options.UPSTREAM || 'http://localhost:9003', ': /');
26+
upstream = upstream.startsWith('http') ? upstream : `https://${upstream}`
27+
app.locals.upstream = new URL(upstream);
1228
app.locals.version_info = JSON.parse(options.VERSION_INFO || '{}');
1329
app.locals.base_path = app.locals.upstream.pathname === "/" ? "" : app.locals.upstream.pathname;
1430
log.setLevel(options.LOG_LEVEL || "info");

docker/sync-wrap/src/app.postman.spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ describe("express with fake domain", function () {
1010
before(function () {
1111
env = process.env;
1212
let app = require("./app");
13-
app.setup({UPSTREAM: "https://localhost:1234", ALLOW_INSECURE: "true", LOG_LEVEL: (process.env.NODE_ENV === "test" ? "warn": "debug")});
13+
app.setup({
14+
UPSTREAM: "localhost:1234",
15+
ALLOW_INSECURE: "true",
16+
LOG_LEVEL: (process.env.NODE_ENV === "test" ? "warn": "debug")
17+
});
1418
server = app.start();
1519
});
1620

@@ -38,7 +42,10 @@ describe("express with postman-echo", function () {
3842
before(function () {
3943
env = process.env;
4044
let app = require("./app");
41-
app.setup({UPSTREAM: "https://postman-echo.com", LOG_LEVEL: (process.env.NODE_ENV === "test" ? "warn": "debug")});
45+
app.setup({
46+
UPSTREAM: "postman-echo.com",
47+
LOG_LEVEL: (process.env.NODE_ENV === "test" ? "warn": "debug")
48+
});
4249
server = app.start();
4350
});
4451

e2e/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
[project]
2+
python = "^3.8"
3+
14
[tool.poetry]
25
name = "async-slowapp-e2e"
36
version = "0.1.0"
47
description = ""
58
authors = ["Matthew Mercer <matt.mercer@nhs.net>"]
9+
readme = 'README.md'
610
license = "MIT"
11+
repository = "https://github.com/NHSDigital/sync-wrap"
12+
homepage = ""
13+
keywords = ["nhs"]
714

815
[tool.poetry.dependencies]
916
python = "^3.8"

ecs-proxies-deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ docker_service:
2222
value: production
2323
- name: LOG_LEVEL
2424
value: "{{ 'debug' if APIGEE_ENVIRONMENT == 'internal-dev' else 'info' }}"
25-
- name: UPSTREAM
26-
value: "{{ apigee_uri }}"
2725
- name: VERSION_INFO
2826
value: "{{ version_info | to_json }}"
27+
secrets:
28+
- name: UPSTREAM
29+
valueFrom: "/{{ account }}/platform-common/egress/hosts/apigee-{{ APIGEE_ENVIRONMENT }}"
2930
health_check:
3031
matcher: "200"
3132
path: "/_ping"

0 commit comments

Comments
 (0)