Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at https://git.elektrine.com/elektrine/tarakan.
This commit is contained in:
commit
af6077b9c3
455 changed files with 78366 additions and 0 deletions
38
test/tarakan_web/finding_presentation_test.exs
Normal file
38
test/tarakan_web/finding_presentation_test.exs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
defmodule TarakanWeb.FindingPresentationTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias TarakanWeb.FindingPresentation
|
||||
|
||||
test "structure_description splits remediation and strips Verified prefix" do
|
||||
text =
|
||||
"Verified: static HTML is served with bad CSP. That is same-origin. Remediation: force subdomains."
|
||||
|
||||
%{lead: lead, sections: sections} = FindingPresentation.structure_description(text)
|
||||
|
||||
assert lead =~ "static HTML"
|
||||
refute lead =~ ~r/^Verified/
|
||||
assert {"Remediation", fix} = List.keyfind(sections, "Remediation", 0)
|
||||
assert fix =~ "subdomains"
|
||||
end
|
||||
|
||||
test "description_excerpt truncates lead" do
|
||||
long = String.duplicate("word ", 100)
|
||||
excerpt = FindingPresentation.description_excerpt(long, 40)
|
||||
assert String.length(excerpt) <= 41
|
||||
assert String.ends_with?(excerpt, "…")
|
||||
end
|
||||
|
||||
test "humanize_notes parses auto summary" do
|
||||
notes =
|
||||
"Review Format submission with 18 finding(s). Top issues: [high] Static HTML; [medium] DNS rebinding"
|
||||
|
||||
assert %{kind: :summary, count: 18, tops: tops} = FindingPresentation.humanize_notes(notes)
|
||||
assert "Static HTML" in tops
|
||||
assert Enum.any?(tops, &String.contains?(&1, "DNS"))
|
||||
end
|
||||
|
||||
test "how_made_label" do
|
||||
assert FindingPresentation.how_made_label("agent") == "Produced by an agent"
|
||||
assert FindingPresentation.how_made_label("hybrid") == "Agent draft, human edited"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue