TestNew | Basic middleware initialization | Generates nonce, stores in context, sets CSP header with nonce |
TestWithOptions_CustomLength | Custom nonce byte length (32 bytes) | Generates longer nonce (~43 base64 characters) |
TestWithOptions_CustomDirectives | Custom CSP directives (script-src only) | CSP includes only script-src, excludes style-src |
TestWithOptions_BasePolicy | Extending existing CSP policy | Preserves base policy directives and adds nonce to specified directives |
TestWithOptions_CustomGenerator | Custom nonce generator function | Uses provided generator instead of default random generation |
TestScriptTag | Script tag nonce attribute helper | Returns properly formatted nonce="..." attribute |
TestStyleTag | Style tag nonce attribute helper | Returns properly formatted nonce="..." attribute |
TestForScripts | Scripts-only preset middleware | CSP contains script-src directive with nonce |
TestForStyles | Styles-only preset middleware | CSP contains style-src directive with nonce |
TestReportOnly | Report-only mode | Sets Content-Security-Policy-Report-Only header instead |
TestUniqueNonce | Nonce uniqueness across requests | Each request generates a unique nonce (no duplicates in 10 requests) |
TestGetWithoutMiddleware | Get() without middleware | Returns empty string when middleware not applied |