def tearDown(self): logger.info("Deletion of the created user...") result = executor("bash -c \"userdel test_user\"") if not result: logger.info("\t\tUser deleted.") else: errors_logger.info(result.strip()) logger.info("\t\tUser haven't been deleted. Check enviro.log.")
def setUp(self): logger.info("______NFS folder user access permission test began______") logger.info("New client user creation.") result = executor( "bash -c \"useradd test_user; echo -e \'test\ntest\' | passwd test_user\"") if "successfull" in result: errors_logger.info(result.strip()) logger.info("\t\tUser created.") else: errors_logger.info(result.strip()) logger.info("\t\tUser haven't been created. Check enviro.log.")
def test_third_delete(self): logger.info("File deletion test began.") delete = True errors_getter = executor("rm /mnt/test_nfs/creation_check") if 'no such file' in errors_getter.lower(): delete = False errors_logger.info(errors_getter.strip()) logger.info("\t\tTest passed.") elif not errors_getter: logger.info("\t\tTest failed.") else: errors_logger.info(errors_getter.strip()) logger.info("\t\tTest failed.") self.assertEqual(delete, False)
def test_second_edit(self): logger.info("File edition test began.") edit = True errors_getter = executor("bash -c \'echo check >> /mnt/test_ro_nfs/edition_check\'") if 'read-only' in errors_getter.lower(): edit = False errors_logger.info(errors_getter.strip()) logger.info("\t\tTest passed.") elif not errors_getter: logger.info("\t\tTest failed.") else: errors_logger.info(errors_getter.strip()) logger.info("\t\tTest failed.") self.assertEqual(edit, False)
def test_first_create(self): logger.info("______NFS folder \"read-only\" attributes test began______") logger.info("File creation test began.") create = True errors_getter = executor("bash -c \'> /mnt/test_ro_nfs/creation_check\'") if 'read-only' in errors_getter.lower(): create = False errors_logger.info(errors_getter.strip()) logger.info("\t\tTest passed.") elif not errors_getter: logger.info("\t\tTest failed.") else: errors_logger.info(errors_getter.strip()) logger.info("\t\tTest failed.") self.assertEqual(create, False)
def test_user(self): logger.info("Newly created user permission test began.") edit = True errors_getter = executor( "runuser -l test_user -c \"bash -c \'echo check >> /mnt/test_nfs/edition_check\'\"") if 'denied' in errors_getter.lower(): edit = False errors_logger.info(errors_getter.strip()) logger.info("\t\tTest passed.") elif not errors_getter: logger.info("\t\tTest failed.") else: errors_logger.info(errors_getter.strip()) logger.info("\t\tTest failed.") self.assertEqual(edit, False)