DEBUG: test-storage tool, add SPF example.

master
Philippe Pittoli 2024-02-29 04:52:54 +01:00
parent 98d0c3c28a
commit fcbed27f60
1 changed files with 12 additions and 3 deletions

View File

@ -1,4 +1,4 @@
require "./src/storage.cr" require "../src/storage.cr"
alias DSZ = DNSManager::Storage::Zone alias DSZ = DNSManager::Storage::Zone
@ -7,17 +7,26 @@ storage = DNSManager::Storage.new "STORAGE"
user_data = DNSManager::Storage::UserData.new 1004 user_data = DNSManager::Storage::UserData.new 1004
storage.user_data << user_data rescue nil storage.user_data << user_data rescue nil
zone = DSZ.new "test.my-domain.com" domain = "test.example.com"
zone = DSZ.new domain
a_record = DSZ::A.new "www", 600.to_u32, "127.0.0.1" a_record = DSZ::A.new "www", 600.to_u32, "127.0.0.1"
aaaa_record = DSZ::AAAA.new "www", 600.to_u32, "::1" aaaa_record = DSZ::AAAA.new "www", 600.to_u32, "::1"
mx_record = DSZ::MX.new "mail", 600.to_u32, "127.0.0.1", 5.to_u32 mx_record = DSZ::MX.new "mail", 600.to_u32, "127.0.0.1", 5.to_u32
spf_record = DSZ::SPF.new "test.example.com.", 600.to_u32, "target", "spf2lol",
([] of DSZ::SPF::Mechanism), DSZ::SPF::Qualifier::SoftFail
zone.resources << a_record zone.resources << a_record
zone.resources << aaaa_record zone.resources << aaaa_record
zone.resources << mx_record zone.resources << mx_record
zone.resources << spf_record
storage.new_domain 1004, zone # Add the new domain to the user.
user_data.domains << domain
storage.update_user_data user_data
# Add the new zone in the database.
storage.zones_by_domain.update_or_create domain, zone
pp! storage.user_data pp! storage.user_data
puts "Zones !!!" puts "Zones !!!"