From 626ae1f95c29fd0ed92872c8a3af4e629e8684d9 Mon Sep 17 00:00:00 2001 From: "Markus Kitsinger (SwooshyCueb)" Date: Wed, 2 Nov 2022 16:16:53 -0400 Subject: [PATCH] [#28] Remove stomp-based test suite --- CMakeLists.txt | 8 --- packaging/postinst | 2 - packaging/run_audit_plugin_test.py | 5 -- packaging/test_plugin_audit_amqp.py | 102 ---------------------------- 4 files changed, 117 deletions(-) delete mode 100644 packaging/run_audit_plugin_test.py delete mode 100644 packaging/test_plugin_audit_amqp.py diff --git a/CMakeLists.txt b/CMakeLists.txt index c66f6f3eb..9c7791636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,7 +97,6 @@ install(TARGETS ${PLUGIN} LIBRARY DESTINATION ${IRODS_PLUGINS_DIRECTORY}/rule_en install( FILES - ${CMAKE_SOURCE_DIR}/packaging/test_plugin_audit_amqp.py ${CMAKE_SOURCE_DIR}/packaging/test_audit_plugin.py ${CMAKE_SOURCE_DIR}/packaging/audit_plugin_message_worker.py ${CMAKE_SOURCE_DIR}/packaging/message_broker_consumer.py @@ -106,13 +105,6 @@ install( PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) -install( - FILES - ${CMAKE_SOURCE_DIR}/packaging/run_audit_plugin_test.py - DESTINATION ${IRODS_HOME_DIRECTORY}/scripts - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - ) - install( FILES ${CMAKE_SOURCE_DIR}/scripts/add_audit_rule_engine_to_rule_engines.py DESTINATION ${IRODS_HOME_DIRECTORY}/scripts diff --git a/packaging/postinst b/packaging/postinst index cbb80fca5..2946e1599 100644 --- a/packaging/postinst +++ b/packaging/postinst @@ -10,11 +10,9 @@ chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test -chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test/test_plugin_audit_amqp.py chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test/test_audit_plugin.py chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test/audit_plugin_message_worker.py chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test/message_broker_consumer.py chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/irods/test/queue_listener.py chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /usr/lib/irods/plugins/rule_engines/libirods_rule_engine_plugin-audit_amqp.so -chown $IRODS_SERVICE_ACCOUNT_NAME:$IRODS_SERVICE_GROUP_NAME /var/lib/irods/scripts/run_audit_plugin_test.py diff --git a/packaging/run_audit_plugin_test.py b/packaging/run_audit_plugin_test.py deleted file mode 100644 index 54e91659d..000000000 --- a/packaging/run_audit_plugin_test.py +++ /dev/null @@ -1,5 +0,0 @@ -import subprocess - -if __name__ == "__main__": - subprocess.call(['sudo', 'python', '-m', 'xmlrunner', 'irods.test.test_plugin_audit_amqp' ]) - diff --git a/packaging/test_plugin_audit_amqp.py b/packaging/test_plugin_audit_amqp.py deleted file mode 100644 index 43f712bef..000000000 --- a/packaging/test_plugin_audit_amqp.py +++ /dev/null @@ -1,102 +0,0 @@ -import time, sys, re -import json -import unittest -import subprocess -import stomp - - -class DoNothingListener(stomp.ConnectionListener): - def on_error(self, headers, message): - pass - - def on_message(self, headers, message): - pass - - -class TestListener(stomp.ConnectionListener): - def __init__(self): - - # the following is used for a count of each rule being executed - self.rule_counts = {} - - # the following is used for any summation of values associated with rules - self.rule_summation ={} - - def on_error(self, headers, message): - print('received an error "%s"' % message) - - def on_message(self, headers, message): - rule_name = json.loads(message)['rule_name'] - # print("%s" % rule_name) - - # count the number of entries for this pep - if rule_name in self.rule_counts.keys(): - self.rule_counts[rule_name] = self.rule_counts[rule_name] + 1 - else: - self.rule_counts[rule_name] = 1 - - if rule_name == 'audit_pep_resource_write_post' or rule_name == 'audit_pep_resource_read_post': - if rule_name in self.rule_summation.keys(): - self.rule_summation[rule_name] = self.rule_summation[rule_name] + int(json.loads(message)['int']) - else: - self.rule_summation[rule_name] = int(json.loads(message)['int']) - - -class TestAuditPlugin(unittest.TestCase): - def setUp(self): - # create a test file - subprocess.call(['dd', 'if=/dev/zero', 'of=testfile.dat', 'bs=1M', 'count=1']) - - def purge_queue(self): - conn = stomp.Connection() - conn.set_listener('', DoNothingListener()) - conn.start() - conn.connect('', '', wait=True) - conn.subscribe(destination='/queue/audit_messages', id=1, ack='auto') - time.sleep(2) - conn.disconnect() - - def tearDown(self): - subprocess.call(['rm', 'testfile.dat']) - - def test_put(self): - self.purge_queue() - listener = TestListener() - conn = stomp.Connection() - conn.set_listener('', listener) - conn.start() - conn.connect('', '', wait=True) - conn.subscribe(destination='/queue/audit_messages', id=1, ack='auto') - subprocess.call(['iput', '-f', 'testfile.dat']) - time.sleep(2) - conn.disconnect() - - self.assertTrue('audit_pep_resource_write_post' in listener.rule_counts) - write_pep_count = listener.rule_counts['audit_pep_resource_write_post'] - self.assertTrue(write_pep_count >= 1) - self.assertTrue('audit_pep_auth_agent_auth_request_pre' in listener.rule_counts) - self.assertTrue(listener.rule_counts['audit_pep_auth_agent_auth_request_pre'] >= 1) - self.assertTrue('audit_pep_resource_write_post' in listener.rule_summation) - self.assertEqual(listener.rule_summation['audit_pep_resource_write_post'] / write_pep_count, 1048576) - - def test_get(self): - subprocess.call(['iput', '-f', 'testfile.dat']) - self.purge_queue() - listener = TestListener() - conn = stomp.Connection() - conn.set_listener('', listener) - conn.start() - conn.connect('', '', wait=True) - conn.subscribe(destination='/queue/audit_messages', id=1, ack='auto') - subprocess.call(['iget', '-f', 'testfile.dat']) - time.sleep(2) - conn.disconnect() - - self.assertTrue('audit_pep_resource_read_post' in listener.rule_counts) - read_pep_count = listener.rule_counts['audit_pep_resource_read_post'] - self.assertTrue(read_pep_count >= 1) - self.assertTrue('audit_pep_auth_agent_auth_request_pre' in listener.rule_counts) - self.assertTrue(listener.rule_counts['audit_pep_auth_agent_auth_request_pre'] >= 1) - self.assertTrue('audit_pep_resource_read_post' in listener.rule_summation) - self.assertEqual(listener.rule_summation['audit_pep_resource_read_post'] / read_pep_count, 1048576) -