blob: 9843009b620d965d690fde5a2c43fb5f3c3d9cd1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# SPDX-FileCopyrightText: 2025 Johannes Christ
# SPDX-License-Identifier: AGPL-3.0-or-later
defmodule :lithium_spf_test do
use ExUnit.Case
@ip {127, 0, 0, 127}
@sender ~c"mike@localhost"
defp check_domain(domain) do
:lithium_spf.check_host(@ip, domain, @sender)
end
describe "domain validation" do
test "rejects empty domain" do
assert {:none, [invalid_domain: :not_multi_label]} = check_domain(~c"")
end
test "rejects empty label" do
assert {:none, [invalid_domain: :label_empty]} = check_domain(~c".host")
end
test "rejects non-multi label domain name" do
assert {:none, [invalid_domain: :not_multi_label]} = check_domain(~c"host")
end
test "rejects too long label" do
over_sixty_three_chars =
~c"hellojoehellomikesystemworkingseemstobeokayfineletrytrathatagainbutintroduceabug.localhost"
assert {:none, [invalid_domain: :label_too_long]} = check_domain(over_sixty_three_chars)
end
end
end
|