File: test_system_info.py

package info (click to toggle)
weevely 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,336 kB
  • sloc: python: 7,732; php: 1,035; sh: 53; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 1,008 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from tests.base_test import BaseTest
from testfixtures import log_capture
from core.weexceptions import ArgparseError
from core import modules
from core.sessions import SessionURL
import os

class SystemInfo(BaseTest):

    def setUp(self):
        session = SessionURL(self.url, self.password, volatile = True)
        modules.load_modules(session)

        self.run_argv = modules.loaded['system_info'].run_argv

    @log_capture()
    def test_commands(self, log_captured):

        # Get all infos, returns a dict
        vectors_names = [v.name for v in modules.loaded['system_info'].vectors ]
        self.assertEqual(set(self.run_argv([ '-extended' ]).keys()), set(vectors_names));

        # Get just one info, returns a string
        self.assertEqual(
                      os.path.split(self.run_argv(["-info", "script"]))[1],
                      os.path.split(self.path)[1]
        );

        # Pass unexistant info
        self.assertRaises(ArgparseError, self.run_argv, ["-info", "BOGUS"]);