test: add C NIF integration tests for web context
Add lightweight integration tests to verify: - C NIF module loads properly in web application - MIB library initializes successfully - Standard MIB name resolution works - MibTranslator wrapper functions correctly - Error handling for invalid MIB names - SNMP profiles can be loaded (uses MIB translation) These tests verify the C NIF works end-to-end without checking full page content, focusing on functional verification only.
This commit is contained in:
parent
3433f631aa
commit
c22a1c94ea
1 changed files with 45 additions and 0 deletions
45
test/towerops_web/integration/c_nif_integration_test.exs
Normal file
45
test/towerops_web/integration/c_nif_integration_test.exs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
defmodule ToweropsWeb.Integration.CNifIntegrationTest do
|
||||
@moduledoc """
|
||||
Integration tests to verify the C NIF is properly loaded and functional
|
||||
in the web application context.
|
||||
"""
|
||||
use ToweropsWeb.ConnCase, async: true
|
||||
|
||||
alias Towerops.Profiles.YamlProfiles
|
||||
alias Towerops.Snmp.MibTranslator
|
||||
|
||||
describe "C NIF initialization in web context" do
|
||||
test "ToweropsNative module is loaded" do
|
||||
assert Code.ensure_loaded?(ToweropsNative)
|
||||
end
|
||||
|
||||
test "MIB library is initialized" do
|
||||
result = ToweropsNative.init_mib_library()
|
||||
assert result in ["initialized", "already_initialized"]
|
||||
end
|
||||
|
||||
test "can resolve standard MIB names" do
|
||||
assert "1.3.6.1.2.1.1.1" = ToweropsNative.resolve_oid("sysDescr")
|
||||
assert "1.3.6.1.2.1.1.5" = ToweropsNative.resolve_oid("sysName")
|
||||
end
|
||||
|
||||
test "MibTranslator wrapper works" do
|
||||
assert {:ok, "1.3.6.1.2.1.1.1.0"} = MibTranslator.translate("1.3.6.1.2.1.1.1.0")
|
||||
assert {:ok, _oid} = MibTranslator.translate("sysDescr")
|
||||
end
|
||||
|
||||
test "handles invalid MIB names gracefully" do
|
||||
assert {:error, _reason} = ToweropsNative.resolve_oid("nonExistentMibName")
|
||||
assert {:error, :translation_failed} = MibTranslator.translate("INVALID-MIB::badObject")
|
||||
end
|
||||
end
|
||||
|
||||
describe "SNMP operations with C NIF" do
|
||||
test "profile matching can use MIB resolution" do
|
||||
# Verify that SNMP profiles can be loaded (they use MIB translation)
|
||||
profiles = YamlProfiles.list_profiles()
|
||||
assert is_list(profiles)
|
||||
assert profiles != []
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue