Plug that extracts test namespace from HTTP headers for sandbox isolation.
When a request includes the x-paper-tiger-namespace header, this plug
sets the namespace in the process dictionary so that all PaperTiger
operations scope data to that namespace.
Usage in Tests
# In your test setup
setup :checkout_paper_tiger
# When making HTTP requests, include the namespace header
Req.post(url,
headers: [
{"authorization", "Bearer sk_test_mock"},
{"x-paper-tiger-namespace", inspect(self())}
]
)
# Or use the helper from PaperTiger.Test
Req.post(url, headers: PaperTiger.Test.sandbox_headers())How It Works
- Client sends
x-paper-tiger-namespaceheader with the test PID as a string - This plug parses the PID and sets it in the process dictionary
- All subsequent store operations in this request use that namespace
- Data is isolated from other concurrent tests