|
|
|
@ -139,6 +139,34 @@ defmodule GcIndexRelay.Nostr.ValidatorTest do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe "validate_not_protected/1" do |
|
|
|
|
|
|
|
test "returns {:ok, event} for a normal event with no tags" do |
|
|
|
|
|
|
|
event = valid_pub_event_fixture() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, ^event} = Validator.validate_not_protected(event) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "returns {:ok, event} for an event with other tags but no protection tag" do |
|
|
|
|
|
|
|
event = valid_pub_event_fixture(tags: [["e", "abc123"], ["p", "def456"]]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert {:ok, ^event} = Validator.validate_not_protected(event) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "returns {:error, message} for an event with the [\"-\"] protection tag" do |
|
|
|
|
|
|
|
event = valid_pub_event_fixture(tags: [["-"]]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert {:error, message} = Validator.validate_not_protected(event) |
|
|
|
|
|
|
|
assert message =~ "auth-required" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "returns {:error, message} when [\"-\"] is mixed with other tags" do |
|
|
|
|
|
|
|
event = valid_pub_event_fixture(tags: [["e", "abc123"], ["-"], ["p", "def456"]]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert {:error, message} = Validator.validate_not_protected(event) |
|
|
|
|
|
|
|
assert message =~ "auth-required" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "static reference test" do |
|
|
|
describe "static reference test" do |
|
|
|
test "validates against known-good pre-computed event" do |
|
|
|
test "validates against known-good pre-computed event" do |
|
|
|
event = static_valid_pub_event() |
|
|
|
event = static_valid_pub_event() |
|
|
|
|