summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLadue, David (dl3158) <dl3158@att.com>2018-09-14 12:36:11 -0400
committerVijay Venkatesh Kumar <vv770d@att.com>2018-09-14 22:45:39 +0000
commitaeae5597c7dcfa4cf432009c4668dd77aa6b84a1 (patch)
tree649ae039cf0f6c51539d538fd78ac881202a86cc /tests
parent09b8dc81f96a1eecca0c3908a02705218a80354d (diff)
v3 changes and netsnmp compat update
Change-Id: Ia69f70c5e128e800623feb7c1473b6729e52ba29 Issue-ID: DCAEGEN2-630 Signed-off-by: Ladue, David (dl3158) <dl3158@att.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_trapd_vb_types.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_trapd_vb_types.py b/tests/test_trapd_vb_types.py
new file mode 100644
index 0000000..4af9235
--- /dev/null
+++ b/tests/test_trapd_vb_types.py
@@ -0,0 +1,45 @@
+import pytest
+import json
+import unittest
+import os
+
+from onap_dcae_cbs_docker_client.client import get_config
+from trapd_exit import cleanup_and_exit
+from trapd_io import stdout_logger, ecomp_logger
+import trapd_settings as tds
+import trapd_snmpv3
+
+from pysnmp.entity import engine, config
+
+class test_trapd_vb_types(unittest.TestCase):
+ """
+ Test snmpv3 module
+ """
+
+ def trapd_vb_type_conversions(self):
+ """
+ Test that pysnmp varbind types convert to netsnmp
+ """
+ # del os.environ['CBS_SIM_JSON']
+ # result = trapd_get_cbs_config.get_cbs_config()
+ # print("result: %s" % result)
+ # compare = str(result).startswith("{'snmptrap': ")
+ # self.assertEqual(compare, False)
+
+ tds.c_config = json.loads("{ \"snmptrapd\": { \"version\": \"1.4.0\", \"title\": \"ONAP SNMP Trap Receiver\" }, \"protocols\": { \"transport\": \"udp\", \"ipv4_interface\": \"0.0.0.0\", \"ipv4_port\": 6162, \"ipv6_interface\": \"::1\", \"ipv6_port\": 6162 }, \"cache\": { \"dns_cache_ttl_seconds\": 60 }, \"publisher\": { \"http_timeout_milliseconds\": 1500, \"http_retries\": 3, \"http_milliseconds_between_retries\": 750, \"http_primary_publisher\": \"true\", \"http_peer_publisher\": \"unavailable\", \"max_traps_between_publishes\": 10, \"max_milliseconds_between_publishes\": 10000 }, \"streams_publishes\": { \"sec_fault_unsecure\": { \"type\": \"message_router\", \"aaf_password\": null, \"dmaap_info\": { \"location\": \"mtl5\", \"client_id\": null, \"client_role\": null, \"topic_url\": \"http://localhost:3904/events/ONAP-COLLECTOR-SNMPTRAP\" }, \"aaf_username\": null } }, \"files\": { \"runtime_base_dir\": \"/tmp/opt/app/snmptrap\", \"log_dir\": \"logs\", \"data_dir\": \"data\", \"pid_dir\": \"tmp\", \"arriving_traps_log\": \"snmptrapd_arriving_traps.log\", \"snmptrapd_diag\": \"snmptrapd_prog_diag.log\", \"traps_stats_log\": \"snmptrapd_stats.csv\", \"perm_status_file\": \"snmptrapd_status.log\", \"eelf_base_dir\": \"/tmp/opt/app/snmptrap/logs\", \"eelf_error\": \"error.log\", \"eelf_debug\": \"debug.log\", \"eelf_audit\": \"audit.log\", \"eelf_metrics\": \"metrics.log\", \"roll_frequency\": \"day\", \"minimum_severity_to_log\": 2 }, \"trap_config\": { \"sw_interval_in_seconds\": 60, \"notify_oids\": { \".1.3.6.1.4.1.9.0.1\": { \"sw_high_water_in_interval\": 102, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.2\": { \"sw_high_water_in_interval\": 101, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.3\": { \"sw_high_water_in_interval\": 102, \"sw_low_water_in_interval\": 7, \"category\": \"logonly\" }, \".1.3.6.1.4.1.9.0.4\": { \"sw_high_water_in_interval\": 10, \"sw_low_water_in_interval\": 3, \"category\": \"logonly\" } } } }")
+
+ # del os.environ['CBS_SIM_JSON']
+ # result = trapd_get_cbs_config.get_cbs_config()
+ # print("result: %s" % result)
+ # compare = str(result).startswith("{'snmptrap': ")
+ # self.assertEqual(compare, False)
+
+ good_varbind_types = ["Integer", "Unsigned32", "Counter32", "OctetString", "ObjectIdentifier", "TimeTicks", "IpAddress"]
+ result = pysnmp_to_netsnmp_varbind_convert("Integer")
+
+ assert pytest_wrapped_sys_exit.type == SystemExit
+ self.assertEqual(result, "integer")
+
+
+if __name__ == '__main__':
+ unittest.main()