parent
5436a30098
commit
7655f9d45a
4 changed files with 13 additions and 13 deletions
|
|
@ -64,7 +64,7 @@ defmodule Towerops.Monitoring.Executors.DnsExecutorTest do
|
|||
test "returns error for timeout with unreachable server" do
|
||||
# Use a non-routable IP as DNS server to force timeout
|
||||
config = %{"hostname" => "example.com", "server" => "192.0.2.1"}
|
||||
assert {:error, reason} = DnsExecutor.execute(config, 500)
|
||||
assert {:error, reason} = DnsExecutor.execute(config, 200)
|
||||
assert is_binary(reason)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ defmodule Towerops.Monitoring.Executors.PingExecutorTest do
|
|||
test "returns success with valid ping output" do
|
||||
config = %{"host" => "127.0.0.1", "count" => 1}
|
||||
|
||||
case PingExecutor.execute(config, 500) do
|
||||
case PingExecutor.execute(config, 100) do
|
||||
{:ok, response_time, output} ->
|
||||
assert is_number(response_time)
|
||||
assert response_time >= 0
|
||||
|
|
@ -24,7 +24,7 @@ defmodule Towerops.Monitoring.Executors.PingExecutorTest do
|
|||
config = %{"host" => "127.0.0.1", "count" => 1}
|
||||
|
||||
# Use count=1 to speed up test
|
||||
result = PingExecutor.execute(config, 500)
|
||||
result = PingExecutor.execute(config, 100)
|
||||
assert match?({:ok, _, _}, result) or match?({:error, _}, result)
|
||||
end
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ defmodule Towerops.Monitoring.Executors.PingExecutorTest do
|
|||
# RFC 5737 TEST-NET address — should be unreachable
|
||||
config = %{"host" => "192.0.2.1", "count" => 1}
|
||||
|
||||
case PingExecutor.execute(config, 1000) do
|
||||
case PingExecutor.execute(config, 200) do
|
||||
{:error, reason} ->
|
||||
assert is_binary(reason)
|
||||
|
||||
|
|
@ -45,14 +45,14 @@ defmodule Towerops.Monitoring.Executors.PingExecutorTest do
|
|||
test "returns error for invalid host" do
|
||||
config = %{"host" => "definitely-not-a-real-host-12345.invalid", "count" => 1}
|
||||
|
||||
assert {:error, reason} = PingExecutor.execute(config, 1000)
|
||||
assert {:error, reason} = PingExecutor.execute(config, 200)
|
||||
assert is_binary(reason)
|
||||
end
|
||||
|
||||
test "sanitizes host to prevent command injection" do
|
||||
config = %{"host" => "127.0.0.1; rm -rf /", "count" => 1}
|
||||
|
||||
assert {:error, reason} = PingExecutor.execute(config, 500)
|
||||
assert {:error, reason} = PingExecutor.execute(config, 100)
|
||||
assert reason =~ "Invalid host"
|
||||
end
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ defmodule Towerops.Monitoring.Executors.PingExecutorTest do
|
|||
config = %{"host" => "127.0.0.1", "count" => -1}
|
||||
|
||||
# Should clamp or reject negative count
|
||||
result = PingExecutor.execute(config, 500)
|
||||
result = PingExecutor.execute(config, 100)
|
||||
assert match?({:ok, _, _}, result) or match?({:error, _}, result)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ defmodule Towerops.Monitoring.Executors.SslExecutorTest do
|
|||
test "returns error for connection failure to non-routable address" do
|
||||
config = %{"host" => "192.0.2.1", "port" => 443, "warning_days" => 30}
|
||||
|
||||
assert {:error, reason} = SslExecutor.execute(config, 1_000)
|
||||
assert {:error, reason} = SslExecutor.execute(config, 300)
|
||||
assert is_binary(reason)
|
||||
end
|
||||
|
||||
|
|
@ -29,14 +29,14 @@ defmodule Towerops.Monitoring.Executors.SslExecutorTest do
|
|||
|
||||
config = %{"host" => "127.0.0.1", "port" => port, "warning_days" => 30}
|
||||
|
||||
assert {:error, reason} = SslExecutor.execute(config, 2_000)
|
||||
assert {:error, reason} = SslExecutor.execute(config, 500)
|
||||
assert is_binary(reason)
|
||||
end
|
||||
|
||||
test "returns error for missing host key" do
|
||||
config = %{"port" => 443, "warning_days" => 30}
|
||||
|
||||
assert {:error, "Exception:" <> _} = SslExecutor.execute(config, 5_000)
|
||||
assert {:error, "Exception:" <> _} = SslExecutor.execute(config, 1_000)
|
||||
end
|
||||
|
||||
test "defaults port to 443 when not specified" do
|
||||
|
|
@ -44,13 +44,13 @@ defmodule Towerops.Monitoring.Executors.SslExecutorTest do
|
|||
# but verify the function doesn't crash
|
||||
config = %{"host" => "192.0.2.1", "warning_days" => 30}
|
||||
|
||||
assert {:error, _reason} = SslExecutor.execute(config, 500)
|
||||
assert {:error, _reason} = SslExecutor.execute(config, 200)
|
||||
end
|
||||
|
||||
test "defaults warning_days to 30 when not specified" do
|
||||
config = %{"host" => "192.0.2.1", "port" => 443}
|
||||
|
||||
assert {:error, _reason} = SslExecutor.execute(config, 500)
|
||||
assert {:error, _reason} = SslExecutor.execute(config, 200)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ defmodule Towerops.Monitoring.Executors.TcpExecutorTest do
|
|||
test "returns error for connection timeout" do
|
||||
# Use a non-routable IP to force timeout
|
||||
config = %{"host" => "192.0.2.1", "port" => 80}
|
||||
assert {:error, reason} = TcpExecutor.execute(config, 500)
|
||||
assert {:error, reason} = TcpExecutor.execute(config, 200)
|
||||
|
||||
assert String.contains?(reason, "timeout") or String.contains?(reason, "unreachable") or
|
||||
String.contains?(reason, "failed")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue