aboutsummaryrefslogtreecommitdiffstats
path: root/test/lithium_spf_test.exs
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2025-04-21 18:17:33 +0200
committerGravatar Johannes Christ <[email protected]>2025-04-30 21:03:42 +0200
commit8e07e0005c4c440ee118d4673bb9962954683532 (patch)
tree0eb3718929a2842b5af98642112be2e71bc516cd /test/lithium_spf_test.exs
parentAdd GNU Guix manifest for development (diff)
WIP: RFC 7208 Sender Policy Framework implementationspf-bootstrap
Diffstat (limited to 'test/lithium_spf_test.exs')
-rw-r--r--test/lithium_spf_test.exs33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/lithium_spf_test.exs b/test/lithium_spf_test.exs
new file mode 100644
index 0000000..9843009
--- /dev/null
+++ b/test/lithium_spf_test.exs
@@ -0,0 +1,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