what is the best solution to Mock <permit.io> in l...
# permit-saas
m
what is the best solution to Mock permit.io in local for allowing e2e testing in a context of automatic devellpment
a
Hi @Maxime Leduc, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
The best solution for local E2E testing with Permit.io is to run a local *Edge PDP (Policy Decision Point) * container using Docker (1) . This provides a fully functional authorization microservice that runs on your machine without requiring cloud connectivity during tests . ​*Setup Steps:*​ 1. Pull the PDP container:
Copy code
docker pull permitio/pdp-v2:latest
2. Run the container locally:
Copy code
docker run -it -p 7766:7000 --env PDP_API_KEY=<your-permit-api-key> --env PDP_DEBUG=True permitio/pdp-v2:latest
3. Configure your SDK to point to the local PDP:
Copy code
from permit import Permit

permit = Permit(
    token="[your-api-key]",
    pdp="<http://localhost:7766>",
)
(2) ​*Why This Works for E2E Testing:*​ The PDP runs as a self-contained microservice that evaluates authorization policies locally (1) . Permission checks are performed against this local container, meaning your user data never leaves your system (2) . This setup offers minimal latency and keeps security high . ​*Additional Testing Support:*​ The Permit CLI provides E2E test generation capabilities. You can use
permit test generate e2e
to generate end-to-end policy test configurations and test data (3) . You can also run
permit test run audit
to audit your policy decisions against recent logs . This approach gives you a production-like authorization environment running locally, perfect for automated testing pipelines.
To learn more, see the sources I considered: [[1] Permit's PDP (Policy Decision Point)](https://docs.permit.io/concepts/pdp/overview) [[2] Python Quickstart Async](https://docs.permit.io/sdk/python/quickstart-python) [[3] CLI Overview | Permit.io Documentation](https://docs.permit.io/how-to/permit-cli)
m
do this approche call the cloud version ?
o
@Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
When you run a local ​*Edge PDP container*​ with Docker, it ​*does communicate with Permit.io Cloud*​ to fetch policies and configuration, but ​*authorization decisions themselves are made locally*​ (1) . Here's how it works: ​*What the local PDP does:*​ • The PDP container connects to Permit.io Cloud using your API key to receive policy updates and configuration • Authorization checks (
permit.check()
) are evaluated ​*locally*​ on your machine with minimal latency (2) • Your user data ​*never goes outside your system*​ during permission checks ​*Network architecture:*​ The local PDP is powered by OPAL (Open Policy Administration Layer) , which features a built-in separation of the data plane from the control plane (1) . This means: • ​*Control plane*​ (Permit.io Cloud) : Manages policies and configuration • ​*Data plane*​ (your local PDP) : Makes authorization decisions without depending on cloud availability ​*For completely offline E2E testing:*​ If you need ​*zero*​ cloud calls during tests, you would need to pre-configure your policies and run the PDP in a way that doesn't require real-time policy sy
To learn more, see the sources I considered: [[1] Permit's PDP (Policy Decision Point)](https://docs.permit.io/concepts/pdp/overview) [[2] Python Quickstart Async](https://docs.permit.io/sdk/python/quickstart-python)