You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fuzz_test.go 911B

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