Skip to content

Commit

Permalink
python/tests: make it possible to specific TARGET_HOSTNAME to raw_pro…
Browse files Browse the repository at this point in the history
…tocol.py

SMB_CONF_PATH=/dev/null \
  SERVER=w2012r2-188.w2012r2-l6.base \
  USERNAME=administrator PASSWORD=A1b2C3d4 \
  python/samba/tests/dcerpc/raw_protocol.py -v -f TestDCERPC_BIND

or

SMB_CONF_PATH=/dev/null \
  SERVER=172.31.9.188 TARGET_HOSTNAME=w2012r2-188.w2012r2-l6.base \
  USERNAME=administrator PASSWORD=A1b2C3d4 \
  python/samba/tests/dcerpc/raw_protocol.py -v -f TestDCERPC_BIND

Signed-off-by: Stefan Metzmacher <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
  • Loading branch information
metze-samba authored and cryptomilk committed Oct 26, 2016
1 parent d5b58bb commit b6569bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions python/samba/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,16 @@ def env_loadparm():
return lp


def env_get_var_value(var_name):
def env_get_var_value(var_name, allow_missing=False):
"""Returns value for variable in os.environ
Function throws AssertionError if variable is defined.
Unit-test based python tests require certain input params
to be set in environment, otherwise they can't be run
"""
if allow_missing:
if var_name not in os.environ.keys():
return None
assert var_name in os.environ.keys(), "Please supply %s in environment" % var_name
return os.environ[var_name]

Expand Down Expand Up @@ -267,11 +270,14 @@ def setUp(self):
self.do_hexdump = False

self.host = samba.tests.env_get_var_value('SERVER')
self.target_hostname = samba.tests.env_get_var_value('TARGET_HOSTNAME', allow_missing=True)
if self.target_hostname is None:
self.target_hostname = self.host
self.tcp_port = 135

self.settings = {}
self.settings["lp_ctx"] = self.lp_ctx = samba.tests.env_loadparm()
self.settings["target_hostname"] = self.host
self.settings["target_hostname"] = self.target_hostname

self.connect()

Expand Down
2 changes: 1 addition & 1 deletion python/samba/tests/dcerpc/raw_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ def _get_netlogon_ctx(self):
self.assertNDRSyntaxEquals(rep.u.ctx_list[0].syntax, ndr32)
self.assertEquals(rep.u.auth_info, '\0' * 0)

server = '\\\\' + self.host
server = '\\\\' + self.target_hostname
server_utf16 = unicode(server, 'utf-8').encode('utf-16-le')
computer = 'UNKNOWNCOMPUTER'
computer_utf16 = unicode(computer, 'utf-8').encode('utf-16-le')
Expand Down

0 comments on commit b6569bd

Please sign in to comment.