code.gitea.io/gitea@v1.22.3/tests/fuzz/fuzz_test.go (about)

     1  // Copyright 2023 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package fuzz
     5  
     6  import (
     7  	"bytes"
     8  	"context"
     9  	"io"
    10  	"testing"
    11  
    12  	"code.gitea.io/gitea/modules/markup"
    13  	"code.gitea.io/gitea/modules/markup/markdown"
    14  	"code.gitea.io/gitea/modules/setting"
    15  )
    16  
    17  var renderContext = markup.RenderContext{
    18  	Ctx: context.Background(),
    19  	Links: markup.Links{
    20  		Base: "https://example.com/go-gitea/gitea",
    21  	},
    22  	Metas: map[string]string{
    23  		"user": "go-gitea",
    24  		"repo": "gitea",
    25  	},
    26  }
    27  
    28  func FuzzMarkdownRenderRaw(f *testing.F) {
    29  	f.Fuzz(func(t *testing.T, data []byte) {
    30  		setting.AppURL = "http://localhost:3000/"
    31  		markdown.RenderRaw(&renderContext, bytes.NewReader(data), io.Discard)
    32  	})
    33  }
    34  
    35  func FuzzMarkupPostProcess(f *testing.F) {
    36  	f.Fuzz(func(t *testing.T, data []byte) {
    37  		setting.AppURL = "http://localhost:3000/"
    38  		markup.PostProcess(&renderContext, bytes.NewReader(data), io.Discard)
    39  	})
    40  }