From c4d2ec525b2f844451c8aa8f7e61d683a08e2a20 Mon Sep 17 00:00:00 2001 From: Benjamin Graham Date: Wed, 27 May 2020 09:49:50 -0400 Subject: [PATCH] Added test for pause button and config file saving Added the tests `testPlaybackPause` and `testSessionRecordingConf` --- test/check-application | 113 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/test/check-application b/test/check-application index 5af1ad5..74d546b 100755 --- a/test/check-application +++ b/test/check-application @@ -131,6 +131,119 @@ class TestApplication(MachineCase): b.click("#player-skip-frame") b.wait_in_text(term_first_line, "localhost") + def testPlaybackPause(self): + import time + + term_first_line = ".xterm-accessibility-tree div:nth-child(1)" + b = self.browser + m = self.machine + self.login_and_go("/session-recording") + b.wait_present(".content-header-extra") + b.wait_present("#user") + b.click(".listing-ct-item") + # Start and pause the player + b.click("#player-restart") + b.click("#player-play-pause") + b.click("#player-play-pause") + time.sleep(10) + # Make sure it didn't keep playing + b.wait_not_in_text(term_first_line, "whoami") + # Test if it can start playing again + b.click("#player-play-pause") + + def testSessionRecordingConf(self): + import json, configparser + + b = self.browser + m = self.machine + self.login_and_go("/session-recording") + b.wait_present(".content-header-extra") + b.wait_present("#user") + # Ensure that the button leads to the config page + b.click("#btn-config") + b.enter_page("/session-recording/config") + + # TLOG config + conf_file_path = "/etc/tlog/" + conf_file = f"{conf_file_path}tlog-rec-session.conf" + save_file = "/tmp/tlog-rec-session.conf" + test_file = "/tmp/test-tlog-rec-session.conf" + # Save the existing config + m.download(conf_file, save_file) + # Change all of the fields + b.set_input_text("#shell", "/test/path/shell") + b.set_input_text("#notice", "Test Notice") + b.set_input_text("#latency", "1") + b.set_input_text("#payload", "2") + b.set_checked("#log_input", True) + b.set_checked("#log_output", False) + b.set_checked("#log_window", False) + b.set_input_text("#limit_rate", "3") + b.set_input_text("#limit_burst", "4") + b.set_val("#limit_action", "drop") + b.set_input_text("#file_path", "/test/path/file") + b.set_input_text("#syslog_facility", "testfac") + b.set_val("#syslog_priority", "info") + b.set_val("#journal_priority", "info") + b.set_checked("#journal_augment", False) + b.set_val("#writer", "file") + b.click("#btn-save-tlog-conf") + m.download(conf_file, test_file) + # Revert to the previous config before testing to ensure test continuity + m.upload([save_file], conf_file_path) + # Check that the config reflects the changes + conf = json.load(open(test_file, "r")) + assert json.dumps(conf) == json.dumps( + { + "shell": "/test/path/shell", + "notice": "Test Notice", + "latency": 1, + "payload": 2, + "log": {"input": True, "output": False, "window": False}, + "limit": {"rate": 3, "burst": 4, "action": "drop"}, + "file": {"path": "/test/path/file"}, + "syslog": {"facility": "testfac", "priority": "info"}, + "journal": {"priority": "info", "augment": False}, + "writer": "file", + } + ) + + # SSSD config + conf_file_path = "/etc/sssd/conf.d/" + conf_file = f"{conf_file_path}sssd-session-recording.conf" + save_file = "/tmp/sssd-session-recording.conf" + test_none_file = "/tmp/test-none-sssd-session-recording.conf" + test_some_file = "/tmp/test-some-sssd-session-recording.conf" + test_all_file = "/tmp/test-all-sssd-session-recording.conf" + # Save the existing config + m.download(conf_file, save_file) + # Download test with scope 'None' + b.set_val("#scope", "none") + b.click("#btn-save-sssd-conf") + m.download(conf_file, test_none_file) + # Download test with scope 'Some' + b.set_val("#scope", "some") + b.set_input_text("#users", "test users") + b.set_input_text("#groups", "test groups") + b.click("#btn-save-sssd-conf") + m.download(conf_file, test_some_file) + # Download test with scope 'All' + b.set_val("#scope", "all") + b.click("#btn-save-sssd-conf") + m.download(conf_file, test_all_file) + # Revert to the previous config before testing to ensure test continuity + m.upload([save_file], conf_file_path) + # Check that the configs reflected the changes + conf = configparser.ConfigParser() + conf.read_file(open(test_none_file, "r")) + assert conf["session_recording"]["scope"] == "none" + conf.read_file(open(test_some_file, "r")) + assert conf["session_recording"]["scope"] == "some" + assert conf["session_recording"]["users"] == "test users" + assert conf["session_recording"]["groups"] == "test groups" + conf.read_file(open(test_all_file, "r")) + assert conf["session_recording"]["scope"] == "all" + if __name__ == "__main__": test_main()