Skip to content

Commit dd0cd56

Browse files
authored
Merge pull request #19 from NHSDigital/int-deploy
Uncommented int and sandbox env
2 parents bb21720 + 635b36c commit dd0cd56

10 files changed

Lines changed: 90 additions & 40 deletions

File tree

azure/azure-pr-pipeline.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ variables:
2929
extends:
3030
template: azure/common/apigee-deployment.yml@common
3131
parameters:
32-
service_name: ${{ variables.service_name }}
33-
short_service_name: ${{ variables.short_service_name }}
34-
service_base_path: ${{ variables.service_base_path }}
32+
service_name: ${{ variables.service_name }}
33+
short_service_name: ${{ variables.short_service_name }}
34+
service_base_path: ${{ variables.service_base_path }}
3535
apigee_deployments:
3636
- environment: internal-dev
3737
post_deploy:
3838
- template: ./templates/run-tests.yml
3939
parameters:
4040
full: true
41-
# - environment: internal-dev-sandbox
42-
# proxy_path: sandbox
43-
# post_deploy:
44-
# - template: ./templates/run-tests.yml
41+
- environment: internal-dev-sandbox
42+
proxy_path: sandbox
43+
post_deploy:
44+
- template: ./templates/run-tests.yml

azure/azure-release-pipeline.yml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,30 @@ extends:
3636
- template: ./templates/run-tests.yml
3737
parameters:
3838
full: true
39-
# - environment: internal-dev-sandbox
40-
# proxy_path: sandbox
41-
# post_deploy:
42-
# - template: ./templates/run-tests.yml
43-
# - environment: internal-qa
44-
# post_deploy:
45-
# - template: ./templates/run-tests.yml
46-
# parameters:
47-
# full: true
48-
# - environment: internal-qa-sandbox
49-
# proxy_path: sandbox
50-
# post_deploy:
51-
# - template: ./templates/run-tests.yml
39+
- environment: internal-qa
40+
post_deploy:
41+
- template: ./templates/run-tests.yml
42+
parameters:
43+
full: true
44+
- environment: internal-dev-sandbox
45+
proxy_path: sandbox
46+
post_deploy:
47+
- template: ./templates/run-tests.yml
48+
- environment: internal-qa-sandbox
49+
proxy_path: sandbox
50+
post_deploy:
51+
- template: ./templates/run-tests.yml
52+
- environment: int
53+
depends_on:
54+
- internal_qa
55+
- internal_qa_sandbox
56+
post_deploy:
57+
- template: ./templates/run-tests.yml
58+
parameters:
59+
full: true
60+
test-command: prod
61+
smoketest-command: prod
62+
5263
# - environment: ref
5364
# depends_on:
5465
# - internal_qa
@@ -59,14 +70,4 @@ extends:
5970
# proxy_path: sandbox
6071
# post_deploy:
6172
# - template: ./templates/run-tests.yml
62-
# # Enable int environment when ready by uncommenting:
63-
# - environment: int
64-
# depends_on:
65-
# - internal_qa
66-
# - internal_qa_sandbox
67-
# post_deploy:
68-
# - template: ./templates/run-tests.yml
69-
# parameters:
70-
# full: true
71-
# test-command: prod
72-
# smoketest-command: prod
73+

manifest_template.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ APIGEE_ENVIRONMENTS:
77
has_mock_auth: true
88
- name: internal-qa
99
display_name: Internal QA
10-
has_mock_auth: true
10+
has_mock_auth: true
1111
- name: ref
1212
display_name: Reference
1313
has_mock_auth: true
14+
- name: internal-dev-sandbox
15+
display_name: Internal Development Sandbox
16+
portal_visibility: false
17+
- name: internal-qa-sandbox
18+
display_name: Internal QA Sandbox
19+
portal_visibility: false
20+
- name: int
21+
display_name: Integration Testing
1422
# Enable environments when ready by uncommenting:
15-
# - name: internal-dev-sandbox
16-
# display_name: Internal Development Sandbox
17-
# portal_visibility: false
1823
# - name: internal-qa
1924
# display_name: Internal QA
2025
# has_mock_auth: true
2126
# portal_visibility: false
22-
# - name: internal-qa-sandbox
23-
# display_name: Internal QA Sandbox
24-
# portal_visibility: false
2527
# - name: sandbox
2628
# display_name: Sandbox
2729
# portal_visibility: false
28-
# - name: int
29-
# display_name: Integration Testing
3030
---
3131
meta:
3232
api:

proxies/sandbox/apiproxy/policies/javascript.CaptureproxyHostName.xml renamed to proxies/live/apiproxy/policies/javascript.CaptureProxyHostName.xml

File renamed without changes.

proxies/live/apiproxy/proxies/default.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@
4545
<Condition>(proxy.pathsuffix MatchesPath "/_status") and ((request.verb = "GET") or (request.verb = "HEAD"))
4646
</Condition>
4747
</Flow>
48+
<Flow name="CaptureProxyHostName">
49+
<Request>
50+
<Step>
51+
<Condition>(proxy.pathsuffix != "/_status") and (proxy.pathsuffix != "/_ping")</Condition>
52+
<Name>javascript.CaptureProxyHostName</Name>
53+
</Step>
54+
</Request>
55+
</Flow>
4856
</Flows>
4957
<PostClientFlow name="PostClientFlow">
5058
<Response>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const env_regex = /^([a-zA-Z0-9-]+\.)?api\.service\.nhs\.uk/gm;
2+
var hostname_env = request.headers.host;
3+
hostname_env = hostname_env.match(env_regex, request.headers.host)[0];
4+
context.setVariable("request_hostname_env", hostname_env);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="javascript.CaptureProxyHostName">
3+
<DisplayName>javascript.CaptureProxyHostName</DisplayName>
4+
<Properties/>
5+
<ResourceURL>jsc://CaptureProxyHostName.js</ResourceURL>
6+
</Javascript>

proxies/sandbox/apiproxy/proxies/default.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
<Condition>(proxy.pathsuffix MatchesPath "/_status") and ((request.verb = "GET") or (request.verb = "HEAD"))
3939
</Condition>
4040
</Flow>
41+
<Flow name="CaptureProxyHostName">
42+
<Request>
43+
<Step>
44+
<Condition>(proxy.pathsuffix != "/_status") and (proxy.pathsuffix != "/_ping")</Condition>
45+
<Name>javascript.CaptureProxyHostName</Name>
46+
</Step>
47+
</Request>
48+
</Flow>
4149
</Flows>
4250
<PreFlow/>
4351
<PostClientFlow name="PostClientFlow">
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const env_regex = /^([a-zA-Z0-9-]+\.)?api\.service\.nhs\.uk/gm;
2+
var hostname_env = request.headers.host;
3+
hostname_env = hostname_env.match(env_regex, request.headers.host)[0];
4+
context.setVariable("request_hostname_env", hostname_env);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var response = context.getVariable("response.content");
2+
var json = JSON.parse(response);
3+
4+
if (json.place) {
5+
// Loop over each item in the search result array, re-writing the hostname to that of the initial request
6+
json.place.forEach(value => {
7+
var request_hostname = context.getVariable("request_hostname_env");
8+
// Annoyingly, Apigee's version of JS doesn't support regex look-behinds,
9+
// so we grab the env string including https:// prefix
10+
var hostname_regex = /(^https:\/\/([a-zA-Z\-]+\.)+)nhs\.uk/gm;
11+
var rewritten_url = value.url.replace(hostname_regex, "https://" + request_hostname);
12+
value.url = rewritten_url;
13+
// value.url = value.url.replace("api-version=1", "api-version=2");
14+
// value.url = value.url.replace("service-search", "service-search-api");
15+
});
16+
17+
// Update the response payload with the corrected urls
18+
context.setVariable("message.content", JSON.stringify(json));
19+
}

0 commit comments

Comments
 (0)