fix: stabilize atom-leak test by checking specific keys instead of global atom count
This commit is contained in:
@@ -286,15 +286,16 @@ defmodule BDS.AITest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "model_capabilities does not create atoms from unknown capability keys" do
|
test "model_capabilities does not create atoms from unknown capability keys" do
|
||||||
before = :erlang.system_info(:atom_count)
|
fictive_key = "csm001_fictive_#{:erlang.unique_integer()}"
|
||||||
|
another_key = "another_unknown_#{:erlang.unique_integer()}"
|
||||||
|
|
||||||
malicious_caps =
|
malicious_caps =
|
||||||
Jason.encode!(%{
|
Jason.encode!(%{
|
||||||
"supports_attachment" => true,
|
"supports_attachment" => true,
|
||||||
"supports_tool_calls" => false,
|
"supports_tool_calls" => false,
|
||||||
"disables_reasoning" => false,
|
"disables_reasoning" => false,
|
||||||
"csm001_fictive_#{:erlang.unique_integer()}" => true,
|
fictive_key => true,
|
||||||
"another_unknown_#{:erlang.unique_integer()}" => 42
|
another_key => 42
|
||||||
})
|
})
|
||||||
|
|
||||||
:ok = BDS.AI.SettingsStore.put_setting("ai.model_capabilities.csm-test-model", malicious_caps)
|
:ok = BDS.AI.SettingsStore.put_setting("ai.model_capabilities.csm-test-model", malicious_caps)
|
||||||
@@ -303,8 +304,9 @@ defmodule BDS.AITest do
|
|||||||
assert result.supports_attachment == true
|
assert result.supports_attachment == true
|
||||||
assert result.supports_tool_calls == false
|
assert result.supports_tool_calls == false
|
||||||
|
|
||||||
after_count = :erlang.system_info(:atom_count)
|
# Unknown keys must remain as strings, not converted to atoms
|
||||||
assert after_count == before
|
assert_raise ArgumentError, fn -> String.to_existing_atom(fictive_key) end
|
||||||
|
assert_raise ArgumentError, fn -> String.to_existing_atom(another_key) end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "put_endpoint, get_endpoint, and delete_endpoint manage encrypted endpoint settings" do
|
test "put_endpoint, get_endpoint, and delete_endpoint manage encrypted endpoint settings" do
|
||||||
|
|||||||
Reference in New Issue
Block a user