From: Tim Beale Date: Mon, 25 Feb 2019 22:06:52 +0000 (+1300) Subject: tests: Work audit_log CLIENT_IP out from config instead of env var X-Git-Tag: talloc-2.2.0~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c185bf1dcf84b2f86af2b79190a479dbc61b3cd3;p=thirdparty%2Fsamba.git tests: Work audit_log CLIENT_IP out from config instead of env var Instead of passing the CLIENT_IP to the audit_log tests, we can just work out the source-IP that the client will use from its smb.conf file. Because the audit_log tests are all run on the non-local testenv, they'll already use the client.conf and the 127.0.0.11 address. The main advantage of this change is it avoids having hardcoded IP addresses in the selftest framework. Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/audit_log_base.py b/python/samba/tests/audit_log_base.py index d3bc3da0638..c1223edad84 100644 --- a/python/samba/tests/audit_log_base.py +++ b/python/samba/tests/audit_log_base.py @@ -54,6 +54,17 @@ class AuditLogTestBase(samba.tests.TestCase): self.msg_ctx = Messaging((1,), lp_ctx=lp_ctx) self.msg_ctx.irpc_add_name(self.event_type) + # Now switch back to using the client-side smb.conf. The tests will + # use the first interface in the client.conf (we need to strip off + # the subnet mask portion) + lp_ctx = self.get_loadparm() + client_ip_and_mask = lp_ctx.get('interfaces')[0] + client_ip = client_ip_and_mask.split('/')[0] + + # the messaging ctx is the server's view of the world, so our own + # client IP will be the remoteAddress when connections are logged + self.remoteAddress = client_ip + # # Check the remote address of a message against the one beimg used # for the tests. diff --git a/python/samba/tests/audit_log_dsdb.py b/python/samba/tests/audit_log_dsdb.py index 0471c22f243..29861332518 100644 --- a/python/samba/tests/audit_log_dsdb.py +++ b/python/samba/tests/audit_log_dsdb.py @@ -43,7 +43,6 @@ class AuditLogDsdbTests(AuditLogTestBase): self.event_type = DSDB_EVENT_NAME super(AuditLogDsdbTests, self).setUp() - self.remoteAddress = os.environ["CLIENT_IP"] self.server_ip = os.environ["SERVER_IP"] host = "ldap://%s" % os.environ["SERVER"] diff --git a/python/samba/tests/audit_log_pass_change.py b/python/samba/tests/audit_log_pass_change.py index d580698b3ba..4e25c872d2d 100644 --- a/python/samba/tests/audit_log_pass_change.py +++ b/python/samba/tests/audit_log_pass_change.py @@ -48,7 +48,6 @@ class AuditLogPassChangeTests(AuditLogTestBase): self.event_type = DSDB_PWD_EVENT_NAME super(AuditLogPassChangeTests, self).setUp() - self.remoteAddress = os.environ["CLIENT_IP"] self.server_ip = os.environ["SERVER_IP"] host = "ldap://%s" % os.environ["SERVER"] diff --git a/python/samba/tests/group_audit.py b/python/samba/tests/group_audit.py index b8c90a325d5..7163c5016a3 100644 --- a/python/samba/tests/group_audit.py +++ b/python/samba/tests/group_audit.py @@ -50,7 +50,6 @@ class GroupAuditTests(AuditLogTestBase): self.event_type = DSDB_GROUP_EVENT_NAME super(GroupAuditTests, self).setUp() - self.remoteAddress = os.environ["CLIENT_IP"] self.server_ip = os.environ["SERVER_IP"] host = "ldap://%s" % os.environ["SERVER"] diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index 0cc3441ae68..7197a3b4b64 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -738,14 +738,11 @@ if have_heimdal_support: "samba.tests.auth_log_winbind", extra_args=['-U"$DC_USERNAME%$DC_PASSWORD"']) planoldpythontestsuite("ad_dc", "samba.tests.audit_log_pass_change", - extra_args=['-U"$USERNAME%$PASSWORD"'], - environ={'CLIENT_IP': '127.0.0.11'}) + extra_args=['-U"$USERNAME%$PASSWORD"']) planoldpythontestsuite("ad_dc", "samba.tests.audit_log_dsdb", - extra_args=['-U"$USERNAME%$PASSWORD"'], - environ={'CLIENT_IP': '127.0.0.11'}) + extra_args=['-U"$USERNAME%$PASSWORD"']) planoldpythontestsuite("ad_dc", "samba.tests.group_audit", - extra_args=['-U"$USERNAME%$PASSWORD"'], - environ={'CLIENT_IP': '127.0.0.11'}) + extra_args=['-U"$USERNAME%$PASSWORD"']) planoldpythontestsuite("fl2008r2dc:local", "samba.tests.getdcname",