The jwks function within the mock-jutsu library provides developers with a streamlined method for generating high-quality mock data for OpenID Connect and OAuth 2.0 testing. By invoking this function, users can instantly produce a standalone JSON Web Key Set that perfectly mimics the structure of a standard well-known jwks endpoint. This is particularly useful for teams building decentralised identity solutions or microservices that require robust signature verification mechanisms without the overhead of connecting to a live identity provider during the initial stages of development.
Technically, the function generates a fresh P-256 Elliptic Curve public key, adhering strictly to the ES256 algorithm standard. Each output includes essential parameters such as the key type, curve, usage, and algorithm, ensuring that the generated test data is compliant with modern cryptographic requirements. Because the mock-jutsu implementation focuses on the P-256 curve, it offers a secure and efficient alternative to legacy RSA keys, making it an ideal choice for testing modern mobile and web applications that prioritise performance and contemporary security protocols.
Incorporating this function into your development lifecycle offers significant benefits, primarily by eliminating the dependency on external authentication servers. Whether you are performing unit tests in Python, running load tests in JMeter, or generating quick snippets via the command-line interface, mock-jutsu ensures that your environment remains isolated and predictable. This allows developers to simulate various authentication scenarios, such as key rotation or signature validation success, by controlling the jwks response directly within their local or continuous integration test suites.
To get started, developers can access the function through multiple interfaces depending on their specific workflow. In a Python environment, a simple call to the generate method returns the required JSON structure, while the CLI tool provides a quick way to output keys for manual inspection or configuration files. Furthermore, the JMeter integration allows performance testers to inject dynamic jwks data into their functional scripts seamlessly. By leveraging these versatile tools, engineering teams can significantly reduce the time spent on manual infrastructure configuration and focus on building resilient, secure applications with reliable mock data.
mockjutsu generate jwksmockjutsu bulk jwks --count 10mockjutsu export jwks --count 10 --format jsonmockjutsu export jwks --count 10 --format csvmockjutsu export jwks --count 10 --format sqlfrom mockjutsu import jutsujutsu.generate('jwks')jutsu.bulk('jwks', count=10)jutsu.template(['jwks'], count=5)${__mockjutsu_oidc(jwks)}# JMeter Function: __mockjutsu_oidc# Parameter 1: jwks# Parameter 2: (not required for this function)GET /generate/jwks# → {"type":"jwks","result":"...","status":"ok"}GET /bulk/jwks?count=10POST /template {"types":["jwks"],"count":1}