Beispiel #1
0
 def setUp(self):
     self.plugin = PortCheckDataSourcePlugin()
     self.config = MagicMock(datasources=[
         MagicMock(params=dict(ports='['
                               '{"port": 1, "desc": "Desc"},'
                               '{"port": 2, "desc": "Desc"}'
                               ']'))
     ],
                             manageIp=sentinel.manageIp)
 def test_onSuccess(self):
     data = self.plugin.onSuccess(
         {},
         MagicMock(
             id=sentinel.id,
             datasources=[
                 MagicMock(params={'eventlog': sentinel.eventlog})
             ],
         ))
     self.assertEquals(len(data['events']), 2)
     self.assertEquals("Monitoring ok", data['events'][1]['summary'])
     self.assertIn("is in Unknown state", data['events'][0]['summary'])
Beispiel #3
0
 def test_onSuccess(self):
     self.plugin.collect(self.config)
     self.plugin.scanner = MagicMock()
     self.plugin.scanner.getSuccesses = MagicMock(
         return_value={sentinel.manageIp: [1]})
     self.plugin.scanner.getFailures = MagicMock(
         return_value={sentinel.manageIp: [[2]]})
     data = self.plugin.onSuccess(MagicMock, self.config)
     self.assertEquals(len(data['events']), 2)
     self.assertItemsEqual(
         ['Port 2 is not listening.  Desc', 'Port 1 is listening.  Desc'],
         [e['summary'] for e in data['events']])
Beispiel #4
0
 def test_onError(self):
     f = None
     try:
         f = Failure('foo')
     except TypeError:
         f = Failure()
     data = self.plugin.onError(f, MagicMock(
         id=sentinel.id,
         datasources=[MagicMock(params={'eventlog': sentinel.eventlog})],
     ))
     self.assertEquals(len(data['events']), 1)
     self.assertEquals(data['events'][0]['device'], sentinel.id)
     self.assertIn("IISSite: Failed collection", data['events'][0]['summary'])
Beispiel #5
0
 def test_onSuccess(self):
     results = load_pickle_file(self, 'IISSiteDataSourcePlugin_onSuccess_162344')[0]
     data = self.plugin.onSuccess(results, MagicMock(
         id="windows_test",
         datasources=[MagicMock(datasource='IISSiteDataSource',
                                params={'eventlog': sentinel.eventlog,
                                        'statusname': 'Default Web Site',
                                        'iis_version': u'8.5',
                                        'apppool': 'defaultapppool'})],
     ))
     self.assertEquals(len(data['events']), 5, msg='Expected 5 events: {}'.format(pprint.pformat(data['events'])))
     self.assertEquals("Monitoring ok", data['events'][2]['summary'])
     self.assertIn("is in Running state", data['events'][0]['summary'])
     self.assertIn("is in Running state", data['events'][1]['summary'])
     self.assertEquals(data['values'][data['values'].keys()[0]]['status'], (0, 'N'))
     self.assertEquals(data['values'][data['values'].keys()[0]]['appPoolState'], (3, 'N'))
Beispiel #6
0
    def test_onError_status(self):
        winrm_errors = [Exception(), Exception('foo')]
        kerberos_errors = map(Exception,
                              ['kerberos authGSSClientStep failed',
                               'Server not found in Kerberos database',
                               'kinit error getting initial credentials'])

        config = MagicMock(
            id='127.0.0.1',
            datasources=[MagicMock(params={'eventlog': sentinel.eventlog})],
        )

        for err in winrm_errors:
            data = self.plugin.onError(Failure(err), config)
            self.assertEquals(data['events'][0]['eventClass'], '/Status')

        for err in kerberos_errors:
            data = self.plugin.onError(Failure(err), config)
            self.assertEquals(data['events'][0]['eventClass'],
                              '/Status/Kerberos')
 def test_onError(self):
     f = None
     try:
         f = Failure('foo')
     except TypeError:
         f = Failure()
     data = self.plugin.onError(f, MagicMock(
         id=sentinel.id,
         datasources=self.ds,
     ))
     self.assertEquals(len(data['events']), 1)
     self.assertEquals(data['events'][0]['severity'], 4)
 def test_onSuccess(self):
     data = self.plugin.onSuccess(
         self.success, MagicMock(
             id=sentinel.id,
             datasources=self.ds,
         ))
     self.assertEquals(len(data['events']), 2)
     self.assertEquals(
         data['events'][0]['summary'],
         'Service Alert: aspnet_state has changed to Stopped state')
     self.assertEquals(
         data['events'][1]['summary'],
         'Windows Service Check: successful service collection')
 def test_onSuccess(self):
     data = self.plugin.onSuccess(
         self.success, MagicMock(
             id="windows_test",
             datasources=self.ds,
         ))
     self.assertEquals(len(data['events']), 4)
     self.assertEquals(
         data['events'][0]['summary'],
         'Service Alert: aspnet_state has changed to Stopped state')
     self.assertEquals(
         data['events'][1]['summary'],
         'Windows Service Check: successful service collection')
     self.assertEquals(data['events'][2]['summary'],
                       'Authentication Successful')
     self.assertEquals(data['events'][3]['summary'], 'No Kerberos failures')
    def setUp(self):
        self.success = load_pickle(self, 'results')
        self.config = load_pickle(self, 'config')
        self.plugin = ServicePlugin()
        self.context = {'modes': ['Auto'],
                        'mode': 'Auto',
                        'monitor': True,
                        'severity': 3,
                        'manual': False,
                        'alertifnot': 'Running',
                        }

        self.ds = [MagicMock(params={'eventlog': sentinel.eventlog,
                                     'winservices': self.context,
                                     'usermonitor': False,
                                     'servicename': 'aspnet_state',
                                     'severity': 3,
                                     'alertifnot': 'Running'
                                     })]