-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfa39fe
commit 3a8eeaf
Showing
17 changed files
with
509 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/flightdata.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<APIProxy name="flightdata"> | ||
<ConfigurationVersion majorVersion="4" minorVersion="0"/> | ||
<CreatedAt>1491498008040</CreatedAt> | ||
<Description/> | ||
<DisplayName>flightdata</DisplayName> | ||
<LastModifiedAt>1491517153495</LastModifiedAt> | ||
<Policies/> | ||
<Resources/> | ||
<Spec/> | ||
<TargetServers/> | ||
<validate>false</validate> | ||
</APIProxy> |
20 changes: 20 additions & 0 deletions
20
...tures/resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-Clean-Response-Headers.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<AssignMessage name='AM-Clean-Response-Headers'> | ||
<Remove> | ||
<Headers> | ||
<Header name='X-Robots-Tag'/> | ||
<Header name='Cache-Control'/> | ||
<Header name='Pragma'/> | ||
<Header name='Expires'/> | ||
<Header name='P3P'/> | ||
<Header name='Content-Security-Policy'/> | ||
<Header name='X-Content-Type-Options'/> | ||
<Header name='X-XSS-Protection'/> | ||
<Header name='Server'/> | ||
<Header name='Set-Cookie'/> | ||
<Header name='Accept-Ranges'/> | ||
<Header name='Vary'/> | ||
<Header name='Content-Disposition'/> | ||
</Headers> | ||
</Remove> | ||
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> | ||
</AssignMessage> |
7 changes: 7 additions & 0 deletions
7
...resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-Inject-Proxy-Revision-Header.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<AssignMessage name='AM-Inject-Proxy-Revision-Header'> | ||
<Set> | ||
<Headers> | ||
<Header name='apiproxy'>{apiproxy.name} r{apiproxy.revision}</Header> | ||
</Headers> | ||
</Set> | ||
</AssignMessage> |
6 changes: 6 additions & 0 deletions
6
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-PreparedQuery-1.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<AssignMessage name='AM-PreparedQuery-1'> | ||
<AssignVariable> | ||
<Name>bq_query</Name> | ||
<Template>SELECT airline, code FROM [bigquery-samples.airline_ontime_data.airline_id_codes] WHERE airline != 'Description' group by airline, code order by airline limit 32</Template> | ||
</AssignVariable> | ||
</AssignMessage> |
6 changes: 6 additions & 0 deletions
6
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-PreparedQuery-2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<AssignMessage name='AM-PreparedQuery-2'> | ||
<AssignVariable> | ||
<Name>bq_query</Name> | ||
<Template>SELECT airline, code FROM [bigquery-samples.airline_ontime_data.airline_id_codes] WHERE airline != 'Description' group by airline, code order by airline limit 100</Template> | ||
</AssignVariable> | ||
</AssignMessage> |
6 changes: 6 additions & 0 deletions
6
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-PreparedQuery-3.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<AssignMessage name='AM-PreparedQuery-3'> | ||
<AssignVariable> | ||
<Name>bq_query</Name> | ||
<Template>SELECT airline, code FROM [bigquery-samples.airline_ontime_data.airline_id_codes] WHERE airline != 'Description' group by airline, code order by airline limit 500</Template> | ||
</AssignVariable> | ||
</AssignMessage> |
6 changes: 6 additions & 0 deletions
6
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-PreparedQuery-4.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<AssignMessage name='AM-PreparedQuery-4'> | ||
<AssignVariable> | ||
<Name>bq_query</Name> | ||
<Template>SELECT airline, count(*) AS total_count FROM [bigquery-samples.airline_ontime_data.flights] WHERE departure_airport = '{param1}' AND date = '{param2}' GROUP BY airline</Template> | ||
</AssignVariable> | ||
</AssignMessage> |
15 changes: 15 additions & 0 deletions
15
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/AM-Query.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<AssignMessage name='AM-Query'> | ||
<AssignTo>request</AssignTo> | ||
<AssignVariable> | ||
<Name>target.copy.pathsuffix</Name> | ||
<Value>false</Value> | ||
</AssignVariable> | ||
<Set> | ||
<Headers> | ||
<Header name='Accept'>application/json</Header> | ||
</Headers> | ||
<Payload contentType='application/json'>{"query": "{bq_query}"} | ||
</Payload> | ||
<Verb>POST</Verb> | ||
</Set> | ||
</AssignMessage> |
7 changes: 7 additions & 0 deletions
7
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/EV-PathParams-4.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ExtractVariables name='EV-PathParams-4'> | ||
<Source>request</Source> | ||
<URIPath> | ||
<Pattern ignoreCase="true">/airports/{param1}/counts/{param2}</Pattern> | ||
</URIPath> | ||
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> | ||
</ExtractVariables> |
21 changes: 21 additions & 0 deletions
21
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/JS-Convert-Response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Javascript name='JS-Convert-Response'> | ||
<Source><![CDATA[ | ||
var c = JSON.parse(context.getVariable('response.content')); | ||
if (Number(c.totalRows) >0) { | ||
var fieldnames = c.schema.fields.map(function(field){ | ||
return field.name; | ||
}); | ||
var rows = c.rows.map(function(row) { | ||
var values = row.f.map(function(f){ return f.v; }); | ||
var result = {}; | ||
fieldnames.forEach(function(name, ix){ result[name] = values[ix]; }); | ||
return result; | ||
}); | ||
c.rows = rows; | ||
} | ||
delete c.kind; | ||
delete c.jobReference; | ||
context.setVariable('response.content', JSON.stringify(c,null,2)+'\n'); | ||
]]> | ||
</Source> | ||
</Javascript> |
16 changes: 16 additions & 0 deletions
16
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/policies/RF-Unknown-Request.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<RaiseFault name='RF-Unknown-Request'> | ||
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> | ||
<FaultResponse> | ||
<Set> | ||
<Payload contentType='application/json'>{ | ||
"error" : { | ||
"code" : 404.01, | ||
"message" : "that request was unknown; try a different request." | ||
} | ||
} | ||
</Payload> | ||
<StatusCode>404</StatusCode> | ||
<ReasonPhrase>Not Found</ReasonPhrase> | ||
</Set> | ||
</FaultResponse> | ||
</RaiseFault> |
122 changes: 122 additions & 0 deletions
122
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/proxies/endpoint1.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
<ProxyEndpoint name="endpoint1"> | ||
|
||
<HTTPProxyConnection> | ||
<BasePath>/flightdata</BasePath> | ||
<Properties/> | ||
<VirtualHost>secure</VirtualHost> | ||
</HTTPProxyConnection> | ||
|
||
<FaultRules/> | ||
<DefaultFaultRule name="default-fault-rule"> | ||
<Step> | ||
<Name>AM-Inject-Proxy-Revision-Header</Name> | ||
</Step> | ||
<AlwaysEnforce>true</AlwaysEnforce> | ||
</DefaultFaultRule> | ||
|
||
<PreFlow name="PreFlow"> | ||
<Request> | ||
</Request> | ||
<Response/> | ||
</PreFlow> | ||
|
||
<PostFlow name="PostFlow"> | ||
<Request/> | ||
<Response> | ||
<Step> | ||
<Name>JS-Convert-Response</Name> | ||
</Step> | ||
<Step> | ||
<Name>AM-Inject-Proxy-Revision-Header</Name> | ||
</Step> | ||
</Response> | ||
</PostFlow> | ||
|
||
<PostClientFlow name="PostFlow"> | ||
<Request/> | ||
<Response> | ||
</Response> | ||
</PostClientFlow> | ||
|
||
<Flows> | ||
|
||
<!-- emit one flow for each item in the config --> | ||
|
||
|
||
<Flow name="airlines32"> | ||
<Request> | ||
<!-- if query is parameterized, extract the fields --> | ||
|
||
<Step> | ||
<Name>AM-PreparedQuery-1</Name> | ||
</Step> | ||
</Request> | ||
<Response> | ||
</Response> | ||
<Condition>proxy.pathsuffix MatchesPath "/airlines32" and request.verb = "GET"</Condition> | ||
</Flow> | ||
|
||
|
||
<Flow name="airlines100"> | ||
<Request> | ||
<!-- if query is parameterized, extract the fields --> | ||
|
||
<Step> | ||
<Name>AM-PreparedQuery-2</Name> | ||
</Step> | ||
</Request> | ||
<Response> | ||
</Response> | ||
<Condition>proxy.pathsuffix MatchesPath "/airlines100" and request.verb = "GET"</Condition> | ||
</Flow> | ||
|
||
|
||
<Flow name="airlines500"> | ||
<Request> | ||
<!-- if query is parameterized, extract the fields --> | ||
|
||
<Step> | ||
<Name>AM-PreparedQuery-3</Name> | ||
</Step> | ||
</Request> | ||
<Response> | ||
</Response> | ||
<Condition>proxy.pathsuffix MatchesPath "/airlines500" and request.verb = "GET"</Condition> | ||
</Flow> | ||
|
||
|
||
<Flow name="airport-counts"> | ||
<Request> | ||
<!-- if query is parameterized, extract the fields --> | ||
|
||
<Step> | ||
<Name>EV-PathParams-4</Name> | ||
</Step> | ||
|
||
<Step> | ||
<Name>AM-PreparedQuery-4</Name> | ||
</Step> | ||
</Request> | ||
<Response> | ||
</Response> | ||
<Condition>proxy.pathsuffix MatchesPath "/airports/*/counts/*" and request.verb = "GET"</Condition> | ||
</Flow> | ||
|
||
|
||
<Flow name="unknown request"> | ||
<Request> | ||
<Step> | ||
<Name>RF-Unknown-Request</Name> | ||
</Step> | ||
</Request> | ||
<Response> | ||
</Response> | ||
</Flow> | ||
|
||
</Flows> | ||
|
||
<RouteRule name="default"> | ||
<TargetEndpoint>target-1</TargetEndpoint> | ||
</RouteRule> | ||
|
||
</ProxyEndpoint> |
42 changes: 42 additions & 0 deletions
42
test/fixtures/resources/TD003-TargetEndpoint-name/apiproxy/targets/target-1.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<TargetEndpoint name="target-1"> | ||
<PreFlow name="PreFlow"> | ||
<Request> | ||
<Step> | ||
<Name>AM-Query</Name> | ||
</Step> | ||
</Request> | ||
<Response> | ||
<Step> | ||
<Name>AM-Clean-Response-Headers</Name> | ||
</Step> | ||
</Response> | ||
</PreFlow> | ||
|
||
<PostFlow name="PostFlow"> | ||
<Request/> | ||
<Response> | ||
</Response> | ||
</PostFlow> | ||
|
||
<Flows/> | ||
|
||
<HTTPTargetConnection> | ||
|
||
<!-- tell Apigee to invoke this with a Google Access Token --> | ||
<Authentication> | ||
<GoogleAccessToken> | ||
<Scopes> | ||
<Scope>https://www.googleapis.com/auth/cloud-platform</Scope> | ||
</Scopes> | ||
</GoogleAccessToken> | ||
</Authentication> | ||
|
||
<SSLInfo> | ||
<Enabled>true</Enabled> | ||
<IgnoreValidationErrors>false</IgnoreValidationErrors> | ||
</SSLInfo> | ||
<Properties/> | ||
<!-- assemble the target path --> | ||
<URL>https://bigquery.googleapis.com/bigquery/v2/projects/infinite-chain-292422/queries</URL> | ||
</HTTPTargetConnection> | ||
</TargetEndpoint> |
Oops, something went wrong.