Skip to content

Commit

Permalink
Use unique event log for Winlogbeat system tests (#8006)
Browse files Browse the repository at this point in the history
This changes the Winlogbeat system tests to use a unique event log for each test case.
The event log name and the registered source applications will each be suffixed with
a short hash created from the Windows API name (eventlogging or wineventlog) and the
python test name.

This should help isolate the test cases from one another.

Fixes #7902
  • Loading branch information
andrewkroh authored and ruflin committed Aug 20, 2018
1 parent 7637a42 commit 4da32c4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions winlogbeat/tests/system/winlogbeat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import hashlib
import os
import platform
import sys
Expand All @@ -14,6 +15,10 @@

from beat.beat import TestCase

PROVIDER = "WinlogbeatTestPython"
APP_NAME = "SystemTest"
OTHER_APP_NAME = "OtherSystemTestApp"


class BaseTest(TestCase):

Expand All @@ -25,15 +30,24 @@ def setUpClass(self):


class WriteReadTest(BaseTest):
providerName = "WinlogbeatTestPython"
applicationName = "SystemTest"
otherAppName = "OtherSystemTestApp"
providerName = PROVIDER
applicationName = APP_NAME
otherAppName = OTHER_APP_NAME
testSuffix = None
sid = None
sidString = None
api = None

def setUp(self):
super(WriteReadTest, self).setUp()

# Every test will use its own event log and application names to ensure
# isolation.
self.testSuffix = "_" + hashlib.sha256(self.api + self._testMethodName).hexdigest()[:5]
self.providerName = PROVIDER + self.testSuffix
self.applicationName = APP_NAME + self.testSuffix
self.otherAppName = OTHER_APP_NAME + self.testSuffix

win32evtlogutil.AddSourceToRegistry(self.applicationName,
"%systemroot%\\system32\\EventCreate.exe",
self.providerName)
Expand Down

0 comments on commit 4da32c4

Please sign in to comment.