tests: Work audit_log CLIENT_IP out from config instead of env var
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 25 Feb 2019 22:06:52 +0000 (11:06 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 4 Mar 2019 21:41:16 +0000 (21:41 +0000)
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 <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/audit_log_base.py
python/samba/tests/audit_log_dsdb.py
python/samba/tests/audit_log_pass_change.py
python/samba/tests/group_audit.py
source4/selftest/tests.py

index d3bc3da063868febe90c415611773c8c6fb1067e..c1223edad84d14a96492ecf760fa6f2e79e2fee5 100644 (file)
@@ -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.
index 0471c22f2435c6e1bb27f3f32a446bb501a07842..2986133251856d27a34c227782f21cfc5da121d9 100644 (file)
@@ -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"]
index d580698b3ba7f8e8a78a6059da012208dd237829..4e25c872d2d31909cd992cf0d19faeb308035edc 100644 (file)
@@ -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"]
index b8c90a325d53d133c821f7d831f5aacacf18f95e..7163c5016a331fdf08640e82d04bbebc4c74bc34 100644 (file)
@@ -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"]
index 0cc3441ae6805de01db6de64f68d107c3c0ea25d..7197a3b4b645b63e54084c81d6d2a3abaf34edc1 100755 (executable)
@@ -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",