package test

import "github.com/zmap/zlint/v3/test"

Index

Functions

func ReadTestCert

func ReadTestCert(inPath string) *x509.Certificate

ReadTestCert loads a x509.Certificate from the given inPath which is assumed to be relative to `testdata/`.

Important: ReadTestCert is only appropriate for unit tests. It will panic if the inPath file can not be loaded.

func ReadTestOCSPResponse

func ReadTestOCSPResponse(tb testing.TB, inPath string) *ocsp.Response

ReadTestOCSPResponse loads a ocsp.Response from the given inPath which is assumed to be relative to `testdata/`. The OCSP file must contain the OCSP response in Base64 encoding. openssl ocsp -resp_text -respin <(base64 -d the_filename) To decode it using OpenSSL, store the base64-encoded in string in a file, and run: Important: ReadTestOCSPResponse is only appropriate for unit tests. It will panic if the inPath file can not be loaded.

func ReadTestRevocationList

func ReadTestRevocationList(tb testing.TB, inPath string) *x509.RevocationList

ReadTestRevocationList loads a x509.RevocationList from the given inPath which is assumed to be relative to `testdata/`.

Important: ReadTestRevocationList is only appropriate for unit tests. It will panic if the inPath file can not be loaded.

func TestLint

func TestLint(lintName string, testCertFilename string) *lint.LintResult

TestLint executes the given lintName against a certificate read from a testcert data file with the given filename. Filenames should be relative to `testdata/` and not absolute file paths.

Important: TestLint is only appropriate for unit tests. It will panic if the lintName is not known or if the testCertFilename can not be loaded, or if the lint result is nil.

func TestLintCert

func TestLintCert(lintName string, cert *x509.Certificate, ctx lint.Configuration) *lint.LintResult

TestLintCert executes a lint with the given name against an already parsed certificate. This is useful when a unit test reads a certificate from disk and then mutates it in some way before trying to lint it.

Important: TestLintCert is only appropriate for unit tests. It will panic if the lintName is not known or if the lint result is nil.

func TestLintOCSPResponse

func TestLintOCSPResponse(tb testing.TB, lintName string, ocspResponse *ocsp.Response, ctx lint.Configuration) *lint.LintResult

TestLintOCSPResponse executes a lint with the given name against an already parsed OCSP Response. This is useful when a unit test reads a OCSP Response from disk and then mutates it in some way before trying to lint it.

func TestLintRevocationList

func TestLintRevocationList(tb testing.TB, lintName string, crl *x509.RevocationList, ctx lint.Configuration) *lint.LintResult

TestLintRevocationList executes a lint with the given name against an already parsed revocation list. This is useful when a unit test reads a revocation list from disk and then mutates it in some way before trying to lint it.

func TestLintWithConfig

func TestLintWithConfig(lintName string, testCertFilename string, configuration string) *lint.LintResult

func TestOCSPResponseLint

func TestOCSPResponseLint(tb testing.TB, lintName string, testOCSPResponseFilename string) *lint.LintResult

TestOCSPResponseLint executes the given lintName against a OCSP Response read from a testocspresponse data file with the given filename. Filenames should be relative to `testdata/` and not absolute file paths.

func TestOCSPResponseLintWithConfig

func TestOCSPResponseLintWithConfig(tb testing.TB, lintName string, testOCSPResponseFilename string, configuration string) *lint.LintResult

func TestRevocationListLint

func TestRevocationListLint(tb testing.TB, lintName string, testCRLFilename string) *lint.LintResult

TestRevocationListLint executes the given lintName against a CRL read from a testcrl data file with the given filename. Filenames should be relative to `testdata/` and not absolute file paths.

func TestRevocationListLintWithConfig

func TestRevocationListLintWithConfig(tb testing.TB, lintName string, testCRLFilename string, configuration string) *lint.LintResult

Source Files

helpers.go

Version
v3.6.6 (latest)
Published
Apr 19, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
4 days ago

Tools for package owners.