Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 24 additions & 17 deletions proxies/live/apiproxy/policies/ServiceCallout.GetTargetsKvm.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="ServiceCallout.GetTargetsKvm">
<!-- This is the default (55 seconds). Including it to make explicit. -->
<Timeout>55000</Timeout>
<Request>
<Set>
<Verb>GET</Verb>
<Path>NHSDigital/booking-and-referral-targets/master/targets/{{ APIGEE_ENVIRONMENT }}/targets.json</Path>
</Set>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</Request>
<Response>private.config_raw</Response>
<HTTPTargetConnection>
<SSLInfo>
<Enabled>true</Enabled>
</SSLInfo>
<URL>https://raw.githubusercontent.com</URL>
</HTTPTargetConnection>
</ServiceCallout>
<!-- This is the default (55 seconds). Including it to make explicit. -->
<Timeout>55000</Timeout>
<Request>
<Set>
<Verb>GET</Verb>
<Path>repos/NHSDigital/private-repo-test/contents/targets/internal-dev/targets.json</Path>
<Headers>
<Header name="X-GitHub-Api-Version">2022-11-28</Header>
<Header name="User-Agent">RyanThomas1214</Header>
<Header name="Accept">application/vnd.github+json</Header>
<Header name="Authorization">Bearer</Header>
</Headers>
</Set>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</Request>
<Response>private.config_raw</Response>
<HTTPTargetConnection>
<SSLInfo>
<Enabled>true</Enabled>
</SSLInfo>
<URL>https://api.github.com</URL>
</HTTPTargetConnection>
</ServiceCallout>
2 changes: 1 addition & 1 deletion proxies/live/apiproxy/resources/jsc/BarsLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function get_target_url_from_kvm_nhsd_target_identifier(system, value) {

If there is no value in the kvm it returns null
*/
var location = "booking-and-referral-config.NHSD-Target-Identifier." + system + "." + value;
var location = "b64decodedTarget.NHSD-Target-Identifier." + system + "." + value;
var url = context.getVariable(location);
if(url && url.endsWith('/')){
url = url.replace(/\/$/,"")
Expand Down
6 changes: 4 additions & 2 deletions proxies/live/apiproxy/resources/jsc/UnpackVars.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

var bookingReferralConfig = JSON.parse(context.getVariable("targets"));
set_variables("booking-and-referral-config", bookingReferralConfig)
var bookingReferralConfigRaw = JSON.parse(context.getVariable("targets"));
var bookingReferralConfig = bookingReferralConfigRaw.content

context.setVariable("booking-and-referral-config", bookingReferralConfig)
4 changes: 4 additions & 0 deletions proxies/live/apiproxy/resources/py/DecodeBase64String.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
b64encoded = flow.getVariable("request.header.NHSD-Target-Identifier")
b64decoded = base64.b64decode(b64encoded)

b64encodedTarget = flow.getVariable("booking-and-referral-config")
b64decodedTarget = base64.b64decode(b64encodedTarget)

flow.setVariable("b64decoded", b64decoded)
flow.setVariable("b64decodedTarget", b64decodedTarget)
135 changes: 69 additions & 66 deletions proxies/live/apiproxy/targets/bref-target.xml
Original file line number Diff line number Diff line change
@@ -1,70 +1,73 @@
<TargetEndpoint name="booking-and-referral-target">
<PreFlow>
<Request>
<Step>
<Name>LookupCache.Targets</Name>
</Step>
<Step>
<Name>Python.DecodeBase64</Name>
<Condition>request.header.NHSD-Target-Identifier != null</Condition>
</Step>
<Step>
<Name>Javascript.UnpackVars</Name>
<Condition>targets != null</Condition>
</Step>
<Step>
<Name>Javascript.CheckTargets</Name>
<Condition>targets != null</Condition>
</Step>
<Step>
<Name>ServiceCallout.GetTargetsKvm</Name>
<Condition>targets = null</Condition>
</Step>
<Step>
<Name>PopulateCache.Targets</Name>
<Condition>targets = null</Condition>
</Step>
<Step>
<Name>AssignMessage.Targets</Name>
<Condition>targets = null</Condition>
</Step>
<Step>
<Name>Javascript.UnpackVars</Name>
</Step>
<Step>
<Name>Javascript.SetTargetUrl</Name>
</Step>
<Step>
<Name>RaiseFault.400MalformedTargetIdentifier</Name>
<Condition>idMalformed = true</Condition>
</Step>
<Step>
<Name>RaiseFault.404ProxyNotFound</Name>
<Condition>isError = true</Condition>
</Step>
</Request>
</PreFlow>
<DefaultFaultRule>
<Step>
<Name>ExtractVariables.OperationOutcomeCode</Name>
</Step>
<Step>
<Name>Javascript.HandleErrors</Name>
</Step>
<Step>
<Name>AssignMessage.SetErrorResponse</Name>
</Step>
</DefaultFaultRule>
<HTTPTargetConnection>
<PreFlow>
<Request>
<Step>
<Name>LookupCache.Targets</Name>
</Step>
<Step>
<Name>Javascript.UnpackVars</Name>
<Condition>targets != null</Condition>
</Step>
<Step>
<Name>Python.DecodeBase64</Name>
<Condition>request.header.NHSD-Target-Identifier != null And targets != null</Condition>
</Step>
<Step>
<Name>Javascript.CheckTargets</Name>
<Condition>targets != null</Condition>
</Step>
<Step>
<Name>ServiceCallout.GetTargetsKvm</Name>
<Condition>targets = null</Condition>
</Step>
<Step>
<Name>PopulateCache.Targets</Name>
<Condition>targets = null</Condition>
</Step>
<Step>
<Name>AssignMessage.Targets</Name>
<Condition>targets = null</Condition>
</Step>
<Step>
<Name>Javascript.UnpackVars</Name>
</Step>
<Step>
<Name>Python.DecodeBase64</Name>
</Step>
<Step>
<Name>Javascript.SetTargetUrl</Name>
</Step>
<Step>
<Name>RaiseFault.400MalformedTargetIdentifier</Name>
<Condition>idMalformed = true</Condition>
</Step>
<Step>
<Name>RaiseFault.404ProxyNotFound</Name>
<Condition>isError = true</Condition>
</Step>
</Request>
</PreFlow>
<DefaultFaultRule>
<Step>
<Name>ExtractVariables.OperationOutcomeCode</Name>
</Step>
<Step>
<Name>Javascript.HandleErrors</Name>
</Step>
<Step>
<Name>AssignMessage.SetErrorResponse</Name>
</Step>
</DefaultFaultRule>
<HTTPTargetConnection>
<Properties>
<Property name="io.timeout.millis">32000</Property>
</Properties>
<URL>https://mocktarget.apigee.net</URL>
<SSLInfo>
<Enabled>true</Enabled>
<ClientAuthEnabled>true</ClientAuthEnabled>
<KeyStore>ref://bars-client</KeyStore>
<KeyAlias>cert</KeyAlias>
</SSLInfo>
</HTTPTargetConnection>
</TargetEndpoint>
<URL>https://mocktarget.apigee.net</URL>
<SSLInfo>
<Enabled>true</Enabled>
<ClientAuthEnabled>true</ClientAuthEnabled>
<KeyStore>ref://bars-client</KeyStore>
<KeyAlias>cert</KeyAlias>
</SSLInfo>
</HTTPTargetConnection>
</TargetEndpoint>