Adds tests across previously-uncovered or under-covered modules: - Mix tasks: backfill_checks, copy_mibs, import_mibs (new test files) - Status pages: StatusIncident changeset (new file) - Webhook signature verification on AgentReleaseWebhookController - CloudflareBanWorker: HTTP-stubbed success / 5xx / transport-error paths - FirmwareVersionFetcherWorker: stubbed perform/0 success + non-200 + tx error - Geoip.Import: production --production code path (HTTP-stubbed) - AgentLive.Show: superuser restart_agent + update_agent + non-superuser paths - NetworkMapLive: node_clicked, deep-link node, topology_updated PubSub - PreseemInsightsLive: toggle_select, deselect_all, filter, dismiss-twice - AlertQuery: 1-arity defaults variants - ProfileWatcher: yaml + reload-trigger event passthrough - MobileAuthController: verify_qr_token success + get/revoke session - HealthController: redis-configured branch - RedisHealthCheck: un-tag :integration tests now that Redis is local - FourOhFourTracker: un-skip module (Redis available) - PingExecutor: un-tag local-only tests + KeyError surface + clamp branch - CheckExecutorWorker: dispatch tcp/dns/ssl/ping branches - UserResetPasswordController: drop dead edit/update + their template Also removes dead code: edit/update actions on UserResetPasswordController and the unused edit.html.heex template — both routed via LiveView.
96 lines
2.7 KiB
Elixir
96 lines
2.7 KiB
Elixir
defmodule Mix.Tasks.CopyMibsTest do
|
|
use ExUnit.Case, async: false
|
|
|
|
import ExUnit.CaptureLog
|
|
|
|
alias Mix.Tasks.CopyMibs
|
|
|
|
@moduletag :tmp_dir
|
|
|
|
describe "run/1" do
|
|
test "raises when --source-path is missing" do
|
|
assert_raise RuntimeError, ~r/Missing --source-path/, fn ->
|
|
CopyMibs.run([])
|
|
end
|
|
end
|
|
|
|
test "raises when source path does not exist", %{tmp_dir: tmp_dir} do
|
|
missing = Path.join(tmp_dir, "does-not-exist")
|
|
target = Path.join(tmp_dir, "target")
|
|
|
|
assert_raise RuntimeError, ~r/MIB directory not found/, fn ->
|
|
CopyMibs.run([
|
|
"--source-path",
|
|
missing,
|
|
"--target-dir",
|
|
target
|
|
])
|
|
end
|
|
end
|
|
|
|
test "copies all files when no --vendors flag is given", %{tmp_dir: tmp_dir} do
|
|
source = Path.join(tmp_dir, "source")
|
|
target = Path.join(tmp_dir, "target")
|
|
File.mkdir_p!(Path.join(source, "mikrotik"))
|
|
File.write!(Path.join([source, "mikrotik", "FOO-MIB.txt"]), "FOO\n")
|
|
File.write!(Path.join(source, "ROOT-MIB.txt"), "ROOT\n")
|
|
|
|
capture_log(fn ->
|
|
CopyMibs.run([
|
|
"--source-path",
|
|
source,
|
|
"--target-dir",
|
|
target
|
|
])
|
|
end)
|
|
|
|
assert File.exists?(Path.join(target, "ROOT-MIB.txt"))
|
|
assert File.exists?(Path.join([target, "mikrotik", "FOO-MIB.txt"]))
|
|
end
|
|
|
|
test "only copies named vendors when --vendors is given", %{tmp_dir: tmp_dir} do
|
|
source = Path.join(tmp_dir, "source")
|
|
target = Path.join(tmp_dir, "target")
|
|
File.mkdir_p!(Path.join(source, "cisco"))
|
|
File.mkdir_p!(Path.join(source, "ubiquiti"))
|
|
File.write!(Path.join([source, "cisco", "C-MIB.txt"]), "C\n")
|
|
File.write!(Path.join([source, "ubiquiti", "U-MIB.txt"]), "U\n")
|
|
|
|
capture_log(fn ->
|
|
CopyMibs.run([
|
|
"--source-path",
|
|
source,
|
|
"--target-dir",
|
|
target,
|
|
"--vendors",
|
|
"cisco,unknown_vendor"
|
|
])
|
|
end)
|
|
|
|
# Cisco copied, unknown_vendor logged as missing, ubiquiti not copied
|
|
assert File.exists?(Path.join([target, "cisco", "C-MIB.txt"]))
|
|
refute File.exists?(Path.join([target, "ubiquiti", "U-MIB.txt"]))
|
|
refute File.exists?(Path.join([target, "unknown_vendor"]))
|
|
end
|
|
|
|
test "treats empty --vendors as :all", %{tmp_dir: tmp_dir} do
|
|
source = Path.join(tmp_dir, "source")
|
|
target = Path.join(tmp_dir, "target")
|
|
File.mkdir_p!(source)
|
|
File.write!(Path.join(source, "X.txt"), "x\n")
|
|
|
|
capture_log(fn ->
|
|
CopyMibs.run([
|
|
"--source-path",
|
|
source,
|
|
"--target-dir",
|
|
target,
|
|
"--vendors",
|
|
""
|
|
])
|
|
end)
|
|
|
|
assert File.exists?(Path.join(target, "X.txt"))
|
|
end
|
|
end
|
|
end
|