Skip to content

test(cloud-function): cover proxyBSA request handling - #513

Draft
caugner wants to merge 1 commit into
mainfrom
proxy-bsa-tests
Draft

test(cloud-function): cover proxyBSA request handling#513
caugner wants to merge 1 commit into
mainfrom
proxy-bsa-tests

Conversation

@caugner

@caugner caugner commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

Add cloud-function/src/handlers/proxy-bsa.test.js, exercising the BSA handler end-to-end through the real router:

  • 405 for wrong methods, 204 for unknown /pong/ paths.
  • /pong/get: body validation and plusAvailable derived from the viewer country.
  • /pong/click: referer and code signature checks.
  • /pimg/: signature verification, image proxying with hardened headers, content-type allowlist (refuses SVG), uncached upstream errors.

Motivation

Make it safer to auto-merge Dependabot bumps by covering proxy-bsa.js, which was the least-tested request handler (22% line coverage). Its ad and image proxying runs on every page view.

Additional details

The dummy bucket from proxy-helpers.js doubles as the image host, so no request leaves the machine. Cases that would call BuySellAds (/pong/get with valid zones, signed /pong/click and /pong/viewed) are intentionally left out.

Line coverage: proxy-bsa.js 22% -> 92%, internal/pong/image.js 38% -> 92%, internal/pong/coding.js 57% -> 96%.

Related issues and pull requests

Exercise the BSA handler end-to-end through the real router: method
checks, `/pong/get` validation and `plusAvailable`, `/pong/click`
referer and signature checks, and `/pimg/` signature verification plus
image proxying (headers, content-type allowlist, upstream errors).

The dummy bucket doubles as the image host, so no request leaves the
machine. Cases that would call BuySellAds are intentionally left out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants