oidc_tokenOIDC

Mock Jutsu HOW-TO | UK

The oidc_token function within the mock-jutsu library provides developers with a streamlined method for generating high-quality mock data for OpenID Connect authentication flows. In modern software engineering, securing APIs and microservices often requires valid JSON Web Tokens (JWTs) to simulate user sessions and permission sets. By utilising mock-jutsu, engineering teams can quickly produce tokens that adhere to industry standards without the administrative overhead of configuring a live identity provider or a dedicated authorisation server. This utility is essential for creating realistic test data during the initial stages of development or when performing rigorous integration testing.

From a technical perspective, the oidc_token function generates a JWT signed with the HS256 algorithm. This symmetric signing approach is particularly advantageous for testing environments because it offers high-speed generation and eliminates the need for managing complex RSA or ECDSA public-private key pairs. Each generated token includes a comprehensive set of standard OIDC claims, specifically the issuer (iss), subject (sub), audience (aud), expiration time (exp), issued at (iat), and a unique JWT ID (jti). These claims ensure that the oidc_token behaves exactly like a production credential, allowing security middleware to validate the payload structure and time-based constraints effectively.

Versatility is a core strength of mock-jutsu, and the oidc_token can be seamlessly integrated across various development environments. Python developers can call the function directly within their test suites using jutsu.generate('oidc_token'), while DevOps engineers can utilise the command-line interface via mockjutsu generate oidc_token for rapid scripting and automation. Furthermore, for performance testing and load simulation, the library supports JMeter integration through the ${__mockjutsu(oidc_token,)} syntax. This flexibility makes it an ideal tool for verifying how applications handle expired tokens, unauthorised access attempts, or high-concurrency login scenarios.

Ultimately, the oidc_token function simplifies the developer experience by removing the friction often associated with authentication mock data. By providing a fast, reliable, and standards-compliant way to generate tokens, mock-jutsu helps teams maintain high development velocity without compromising on the depth of their security testing. Whether you are building a simple prototype or a complex enterprise architecture, having access to predictable OIDC test data ensures that your authentication logic is robust, secure, and ready for production deployment.

CLI Usage
mockjutsu generate oidc_tokenmockjutsu bulk oidc_token --count 10mockjutsu export oidc_token --count 10 --format jsonmockjutsu export oidc_token --count 10 --format csvmockjutsu export oidc_token --count 10 --format sql# --mask: regulation-compliant output (PCI DSS / GDPR / KVKK)mockjutsu generate oidc_token --maskmockjutsu bulk oidc_token --count 5 --mask
Python API
from mockjutsu import jutsujutsu.generate('oidc_token')jutsu.bulk('oidc_token', count=10)jutsu.template(['oidc_token'], count=5)# mask=True: regulation-compliant outputjutsu.generate('oidc_token', mask=True)jutsu.bulk('oidc_token', count=5, mask=True)
JMeter
${__mockjutsu_oidc(oidc_token)}# JMeter Function: __mockjutsu_oidc# Parameter 1: oidc_token# Parameter 2: (not required for this function)# Add 'mask' keyword to get a regulation-compliant masked value${__mockjutsu_oidc(oidc_token,mask)}
REST API
GET /generate/oidc_token# → {"type":"oidc_token","result":"...","status":"ok"}GET /bulk/oidc_token?count=10POST /template {"types":["oidc_token"],"count":1}# mask=true: regulation-compliant outputGET /generate/oidc_token?mask=trueGET /bulk/oidc_token?count=5&mask=true

Parameters

Parameter Values Description
--mask true | false Return a regulation-compliant masked value (PCI DSS, GDPR, KVKK…)

Other Languages