Beispiel #1
0
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
     acc = ItemsAccumulator()
     acc.new_item()
     self.results = {'Win32_SystemEnclosure': acc.items,
                     'Win32_ComputerSystem': acc.items,
                     'Win32_OperatingSystem': acc.items,
                     'exchange_version': Mock(stdout=['15'])}
Beispiel #2
0
class TestOddWMIClasses(BaseTestCase):
    '''
    Test if a device is a domain controller
    '''
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()

    def test_empty_wmi_process(self):
        acc = ItemsAccumulator()
        acc.new_item()
        self.results = {'Win32_SystemEnclosure': acc.items,
                        'Win32_ComputerSystem': acc.items,
                        'Win32_OperatingSystem': acc.items,
                        'exchange_version': Mock(stdout=['15'])}
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].snmpDescr, 'Unknown')
        self.assertEquals(data[0].snmpContact, 'Unknown')
        self.assertEquals(data[0].snmpSysName, 'Unknown')

        self.assertEquals(data[1].tag, 'Unknown')

    def test_contact_none_process(self):
        # ZPS-3227 test for situation where PrimaryOwnerName
        # of Win32_ComputerSystem is None
        acc = ItemsAccumulator()
        acc.new_item()
        cs_acc = ItemsAccumulator()
        cs_acc.new_item()
        cs_acc.add_property('Name', None)
        cs_acc.add_property('PrimaryOwnerName', None)
        cs_acc.add_property('Caption', None)
        cs_acc.add_property('Domain', 'domain')
        cs_acc.add_property('Model', 'model')
        cs_acc.add_property('Manufacturer', 'Microsoft')
        cs_acc.add_property('DomainRole', '0')
        os_acc = ItemsAccumulator()
        os_acc.new_item()
        os_acc.add_property('CSName', None)
        os_acc.add_property('RegisteredUser', None)
        os_acc.add_property('Caption', None)
        os_acc.add_property('ProductType', '0')
        os_acc.add_property('SerialNumber', 'model')
        os_acc.add_property('Manufacturer', 'Microsoft')
        os_acc.add_property('TotalVisibleMemorySize', '1')
        os_acc.add_property('TotalVirtualMemorySize', '1')
        os_acc.add_property('CSDVersion', '1')
        self.results = {'Win32_SystemEnclosure': acc.items,
                        'Win32_ComputerSystem': cs_acc.items,
                        'Win32_OperatingSystem': os_acc.items,
                        'exchange_version': Mock(stdout=['15'])}
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].snmpDescr, 'Unknown')
        self.assertEquals(data[0].snmpContact, 'Unknown')
        self.assertEquals(data[0].snmpSysName, 'Unknown')
Beispiel #3
0
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
     self.results = StringAttributeObject()
     self.results.MSCluster = ()
     self.results.Win32_SystemEnclosure = [StringAttributeObject()]
     self.results.Win32_ComputerSystem = [StringAttributeObject({'blah': 'blah'})]
     self.results.Win32_OperatingSystem = [StringAttributeObject()]
     self.results.exchange_version = Mock(stdout=['15'])
     self.results.ActiveDirectory = [StringAttributeObject()]
     for k in ('TotalVisibleMemorySize', 'TotalVirtualMemorySize'):
         setattr(self.results.Win32_OperatingSystem[0], k, 1)
class TestOperatingSystem(BaseTestCase):
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()
        self.results = StringAttributeObject()
        self.results.MSCluster = ()
        self.results.Win32_SystemEnclosure = [StringAttributeObject()]
        self.results.Win32_ComputerSystem = [StringAttributeObject()]
        self.results.Win32_OperatingSystem = [StringAttributeObject()]
        self.results.exchange_version = Mock(stdout=['15'])
        for k in ('TotalVisibleMemorySize', 'TotalVirtualMemorySize'):
            setattr(self.results.Win32_OperatingSystem[0], k, 1)

    @patch('socket.gethostbyaddr', Mock(return_value=("FQDN", [], ["8.8.8.8"])))
    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].ip_and_hostname, ['8.8.8.8', 'FQDN'])
        self.assertEquals(data[0].domain_controller, True)
        self.assertEquals(data[0].msexchangeversion, 'MSExchange2013IS')
        self.assertEquals(data[0].setClusterMachines, [])
        self.assertEquals(data[0].snmpContact, 'PrimaryOwnerName')
        self.assertEquals(data[0].snmpDescr, 'Caption')
        self.assertEquals(data[0].snmpSysName, 'Name')
        self.assertEquals(data[1].serialNumber, 'SerialNumber')
        self.assertEquals(data[1].tag, 'Tag')
        self.assertEquals(data[1].totalMemory, 1024)
        self.assertEquals(data[2].totalSwap, 1024)
Beispiel #5
0
class TestOperatingSystem(BaseTestCase):
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()
        self.results = StringAttributeObject()
        self.results.MSCluster = ()
        self.results.Win32_SystemEnclosure = [StringAttributeObject()]
        self.results.Win32_ComputerSystem = [StringAttributeObject({'blah': 'blah'})]
        self.results.Win32_OperatingSystem = [StringAttributeObject()]
        self.results.exchange_version = Mock(stdout=['15'])
        self.results.ActiveDirectory = [StringAttributeObject()]
        for k in ('TotalVisibleMemorySize', 'TotalVirtualMemorySize'):
            setattr(self.results.Win32_OperatingSystem[0], k, 1)

    @patch('socket.gethostbyaddr', Mock(return_value=("FQDN", [], ["8.8.8.8"])))
    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].ip_and_hostname, ['8.8.8.8', 'FQDN'])
        self.assertEquals(data[0].domain_controller, False)
        self.assertEquals(data[0].msexchangeversion, 'MSExchange2013IS')
        self.assertEquals(data[0].setClusterMachines, [])
        self.assertEquals(data[0].snmpContact, 'PrimaryOwnerName')
        self.assertEquals(data[0].snmpDescr, 'Caption')
        self.assertEquals(data[0].snmpSysName, 'Name')
        self.assertEquals(data[1].serialNumber, 'SerialNumber')
        self.assertEquals(data[1].tag, 'Tag')
        self.assertEquals(data[1].totalMemory, 1024)
        self.assertEquals(data[2].totalSwap, 1024)
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
     self.results = StringAttributeObject()
     self.results.MSCluster = ()
     self.results.Win32_SystemEnclosure = [StringAttributeObject()]
     self.results.Win32_ComputerSystem = [StringAttributeObject()]
     self.results.Win32_OperatingSystem = [StringAttributeObject()]
     self.results.exchange_version = Mock(stdout=['15'])
     for k in ('TotalVisibleMemorySize', 'TotalVirtualMemorySize'):
         setattr(self.results.Win32_OperatingSystem[0], k, 1)
class TestDomainController(BaseTestCase):
    '''
    Test if a device is a domain controller
    '''
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = load_pickle(self, 'device')
        self.results = load_pickle(self, 'results')

    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].domain_controller, True)
Beispiel #8
0
class TestDomainController(BaseTestCase):
    '''
    Test if a device is a domain controller
    '''
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = load_pickle(self, 'device')
        self.results = load_pickle(self, 'results')

    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].domain_controller, True)
class TestEmptyWin32_ComputerSystem(BaseTestCase):
    """
    Test if a device is a domain controller
    """
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()
        self.results = load_pickle_file(self, 'OperatingSystem_process_103136')[0]

    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'Name'))
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'PrimaryOwnerName'))
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'Caption'))
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'DomainRole'))
        self.assertEquals(data[0].snmpDescr, 'Microsoft Windows Server 2016 Standard')
        self.assertEquals(data[0].snmpSysName, 'WIN2016-KDC-01')
        self.assertTrue(data[0].domain_controller)
Beispiel #10
0
class TestEmptyWin32_ComputerSystem(BaseTestCase):
    """
    Test if a device is a domain controller
    """
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()
        self.results = load_pickle_file(self, 'OperatingSystem_process_103136')[0]

    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'Name'))
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'PrimaryOwnerName'))
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'Caption'))
        self.assertFalse(hasattr(self.results['Win32_ComputerSystem'][0], 'DomainRole'))
        self.assertEquals(data[0].snmpDescr, 'Microsoft Windows Server 2016 Standard')
        self.assertEquals(data[0].snmpSysName, 'WIN2016-KDC-01')
        self.assertTrue(data[0].domain_controller)
Beispiel #11
0
class TestEmptyWMIClasses(BaseTestCase):
    '''
    Test if a device is a domain controller
    '''
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()
        acc = ItemsAccumulator()
        acc.new_item()
        self.results = {'Win32_SystemEnclosure': acc.items,
                        'Win32_ComputerSystem': acc.items,
                        'Win32_OperatingSystem': acc.items,
                        'exchange_version': Mock(stdout=['15'])}

    def test_process(self):
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].snmpDescr, 'Unknown')
        self.assertEquals(data[0].snmpContact, 'Unknown')
        self.assertEquals(data[0].snmpSysName, 'Unknown')

        self.assertEquals(data[1].tag, 'Unknown')
Beispiel #12
0
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
     self.results = load_pickle_file(self, 'OperatingSystem_process_103136')[0]
Beispiel #13
0
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = load_pickle(self, 'device')
     self.results = load_pickle(self, 'results')
class TestOddWMIClasses(BaseTestCase):
    '''
    Test if a device is a domain controller
    '''
    def setUp(self):
        self.plugin = OperatingSystem()
        self.device = StringAttributeObject()

    def test_empty_sysenclosure_process(self):
        acc = ItemsAccumulator()
        acc.new_item()
        self.results = {'Win32_SystemEnclosure': [],
                        'Win32_ComputerSystem': acc.items,
                        'Win32_OperatingSystem': acc.items,
                        'exchange_version': Mock(stdout=['15'])}
        try:
            self.plugin.process(self.device, self.results, Mock())
        except IndexError:
            self.fail('Failed to detect empty Win32_SystemEnclosure results.')

    def test_empty_wmi_process(self):
        acc = ItemsAccumulator()
        acc.new_item()
        self.results = {'Win32_SystemEnclosure': acc.items,
                        'Win32_ComputerSystem': acc.items,
                        'Win32_OperatingSystem': acc.items,
                        'exchange_version': Mock(stdout=['15'])}
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].snmpDescr, 'Unknown')
        self.assertEquals(data[0].snmpContact, 'Unknown')
        self.assertEquals(data[0].snmpSysName, 'Unknown')

        self.assertEquals(data[1].tag, 'Unknown')

    def test_contact_none_process(self):
        # ZPS-3227 test for situation where PrimaryOwnerName
        # of Win32_ComputerSystem is None
        acc = ItemsAccumulator()
        acc.new_item()
        cs_acc = ItemsAccumulator()
        cs_acc.new_item()
        cs_acc.add_property('Name', None)
        cs_acc.add_property('PrimaryOwnerName', None)
        cs_acc.add_property('Caption', None)
        cs_acc.add_property('Domain', 'domain')
        cs_acc.add_property('Model', 'model')
        cs_acc.add_property('Manufacturer', 'Microsoft')
        cs_acc.add_property('DomainRole', '0')
        os_acc = ItemsAccumulator()
        os_acc.new_item()
        os_acc.add_property('CSName', None)
        os_acc.add_property('RegisteredUser', None)
        os_acc.add_property('Caption', None)
        os_acc.add_property('ProductType', '0')
        os_acc.add_property('SerialNumber', 'model')
        os_acc.add_property('Manufacturer', 'Microsoft')
        os_acc.add_property('TotalVisibleMemorySize', '1')
        os_acc.add_property('TotalVirtualMemorySize', '1')
        os_acc.add_property('CSDVersion', '1')
        self.results = {'Win32_SystemEnclosure': acc.items,
                        'Win32_ComputerSystem': cs_acc.items,
                        'Win32_OperatingSystem': os_acc.items,
                        'exchange_version': Mock(stdout=['15'])}
        data = self.plugin.process(self.device, self.results, Mock())
        self.assertEquals(data[0].snmpDescr, 'Unknown')
        self.assertEquals(data[0].snmpContact, 'Unknown')
        self.assertEquals(data[0].snmpSysName, 'Unknown')
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
     self.results = load_pickle_file(self, 'OperatingSystem_process_103136')[0]
Beispiel #17
0
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = StringAttributeObject()
 def setUp(self):
     self.plugin = OperatingSystem()
     self.device = load_pickle(self, 'device')
     self.results = load_pickle(self, 'results')