mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
test(places): pin no-store on every refusal path and reuse the catch
Tests now check Cache-Control on the proxy's own 400, 405, 429 and transport 502, a geocode 503 with ZERO_RESULTS on both geocode routes, and an upstream 429 with an HTML body on both Places routes; the geocode status cases move to the geocode suite and cover reverse-geocode too. An unreadable Places 200 now throws into the existing catch instead of repeating its 502 reply. Comments and the CURRENT-STATE rule are shorter and match the code.
This commit is contained in:
1 parent
19542baf61
commit
67bead9eb9
5 files changed
+106
-130
No files matched your search
@@ -134,6 +134,7 @@ test('a bad or keyless geocode request never reaches Google', async () => {
|
||||
]) {
|
||||
const response = await invokeRoute(routes.get(path), { url });
|
||||
assert.equal(response.statusCode, 400);
|
||||
assert.equal(response.headers['cache-control'], 'no-store');
|
||||
assert.deepEqual(response.body.results, []);
|
||||
assert.equal(response.body.status, 'REQUEST_DENIED');
|
||||
}
|
||||
@@ -144,6 +145,7 @@ test('a bad or keyless geocode request never reaches Google', async () => {
|
||||
url: '/?address=Austin&lat=30&lon=-97',
|
||||
});
|
||||
assert.equal(rejected.statusCode, 405);
|
||||
assert.equal(rejected.headers['cache-control'], 'no-store');
|
||||
}
|
||||
|
||||
// Keyless is an empty capability, not an outage: a 200 the browser adapters
|
||||
@@ -167,6 +169,33 @@ test('a bad or keyless geocode request never reaches Google', async () => {
|
||||
assert.deepEqual(upstream, []);
|
||||
});
|
||||
|
||||
test('only a Geocoding answer is kept by the browser', async () => {
|
||||
// Google can report a denied key or exhausted quota with HTTP 200.
|
||||
for (const [httpStatus, status, cacheControl] of [
|
||||
[200, 'OK', 'private, max-age=300'],
|
||||
[200, 'ZERO_RESULTS', 'private, max-age=300'],
|
||||
[200, 'REQUEST_DENIED', 'no-store'],
|
||||
[200, 'OVER_QUERY_LIMIT', 'no-store'],
|
||||
[200, 'OVER_DAILY_LIMIT', 'no-store'],
|
||||
[200, 'UNKNOWN_ERROR', 'no-store'],
|
||||
[503, 'ZERO_RESULTS', 'no-store'],
|
||||
]) {
|
||||
const routes = installRoutes({
|
||||
fetchImpl: async () =>
|
||||
Response.json({ status, results: [] }, { status: httpStatus }),
|
||||
});
|
||||
for (const path of ['/api/google/geocode', '/api/google/reverse-geocode']) {
|
||||
const label = `${path} ${httpStatus} ${status}`;
|
||||
const response = await invokeRoute(routes.get(path), {
|
||||
url: '/?address=Austin&lat=30&lon=-97',
|
||||
});
|
||||
assert.equal(response.statusCode, httpStatus, label);
|
||||
assert.equal(response.body.status, status, label);
|
||||
assert.equal(response.headers['cache-control'], cacheControl, label);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('an upstream failure reaches the browser as fixed public text', async () => {
|
||||
const routes = installRoutes({
|
||||
fetchImpl: async () => {
|
||||
@@ -178,6 +207,7 @@ test('an upstream failure reaches the browser as fixed public text', async () =>
|
||||
url: '/?address=Austin&lat=30&lon=-97',
|
||||
});
|
||||
assert.equal(response.statusCode, 502);
|
||||
assert.equal(response.headers['cache-control'], 'no-store');
|
||||
assert.deepEqual(response.body, {
|
||||
status: 'UNKNOWN_ERROR',
|
||||
results: [],
|
||||
|
||||
Reference in new issue
Block a user