vigia/spec/geoip_spec.cr
Rénich Bon Ćirić 9e22c4214f
feat(arch): eliminate typescript, vendorize leaflet, add test suite, and release v0.1.1
- Purge TypeScript, Bun, npm, and package.json build dependencies
- Rewrite frontend logic into native ES2022 JavaScript with JSDoc typing
- Vendorize Leaflet 1.9.4 and compile self-contained vigia.html with pure POSIX Bash
- Add deploy-mirror.bash and make deploy-mirror target for mirrors/vigia sync
- Harden Crystal backend: socket closing, atomic snapshot write, and security headers
- Implement comprehensive spec/ test suite for models, geoip, collector, and server
- Add CHANGELOG.rst and update documentation to v0.1.1 standards

Signed-off-by: Rénich Bon Ćirić <renich@evalinux.com>
Co-authored-by: Antigravity <antigravity@google.com>
2026-10-09 04:16:54 -06:00

29 lines
1 KiB
Crystal

require "./spec_helper"
describe Vigia::GeoIPResolver do
it "rejects invalid IPs gracefully" do
resolver = Vigia::GeoIPResolver.new(db_path: "/nonexistent/db.mmdb")
loc = resolver.resolve("invalid-ip-string")
loc.ip.should eq("invalid-ip-string")
loc.country_code.should be_nil
loc.city_name.should be_nil
end
it "resolves known ecosystem nodes statically" do
resolver = Vigia::GeoIPResolver.new(db_path: "/nonexistent/db.mmdb")
loc = resolver.resolve("38.58.139.30")
loc.ip.should eq("38.58.139.30")
loc.country_code.should eq("MX")
loc.country_name.should eq("México")
loc.city_name.should eq("Querétaro")
loc.asn.should eq(272373_i64)
loc.as_org.should eq("HOBOPS.IO S.A.S. DE C.V., ipfs.mx-os.mx")
end
it "caches resolved IPs in memory" do
resolver = Vigia::GeoIPResolver.new(db_path: "/nonexistent/db.mmdb")
loc1 = resolver.resolve("38.58.139.30")
loc2 = resolver.resolve("38.58.139.30")
loc1.city_name.should eq(loc2.city_name)
end
end