diff --git a/regression-tests/test_8bit.py b/regression-tests/test_8bit.py index 5b1d0642..edb78f69 100644 --- a/regression-tests/test_8bit.py +++ b/regression-tests/test_8bit.py @@ -21,4 +21,4 @@ def test8Bit(self): print(json.dumps(j)) count = int(j["r_attrs"]["count"]) - self.assertEquals(count, 2) + self.assertEqual(count, 2) diff --git a/regression-tests/test_Attrs.py b/regression-tests/test_Attrs.py index 96449fcc..99014de3 100644 --- a/regression-tests/test_Attrs.py +++ b/regression-tests/test_Attrs.py @@ -11,23 +11,23 @@ def test_Attrs(self): attrs['accountStatus'] = "normal" r = self.allowFuncAttrs('fredbloggs', '127.0.0.1', "1234", attrs) j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() attrs['accountStatus'] = "blocked" r = self.allowFuncAttrs('fredbloggs', '127.0.0.1', "1234", attrs) j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) attrs['accountStatus'] = "normal" attrs['countryList'] = [ "UK", "US" ] r = self.allowFuncAttrs('fredbloggs', '127.0.0.1', "1234", attrs) j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() attrs['countryList'] = [ "UK", "US", "Blockmestan" ] r = self.allowFuncAttrs('fredbloggs', '127.0.0.1', "1234", attrs) j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) diff --git a/regression-tests/test_Basics.py b/regression-tests/test_Basics.py index 60d45336..7416b148 100644 --- a/regression-tests/test_Basics.py +++ b/regression-tests/test_Basics.py @@ -9,11 +9,11 @@ class TestBasics(ApiTestCase): def test_unauth(self): r = requests.get(self.url("/?command=stats")) - self.assertEquals(r.status_code, requests.codes.unauthorized) + self.assertEqual(r.status_code, requests.codes.unauthorized) def test_auth_stats(self): r = self.session.get(self.url("/?command=stats")) - self.assertEquals(r.status_code, requests.codes.ok) + self.assertEqual(r.status_code, requests.codes.ok) def test_ping(self): for _ in range(10): @@ -22,53 +22,53 @@ def test_ping(self): if j['status'] == 'ok': break time.sleep(1) - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') def test_ping_acl_deny(self): self.writeCmdToConsole('setACL({})') r = self.pingFunc() - self.assertEquals(r.status_code, 401) + self.assertEqual(r.status_code, 401) j = r.json() - self.assertEquals(j['status'], 'failure') - self.assertEquals(j['reason'], 'Source IP Address not in ACL') + self.assertEqual(j['status'], 'failure') + self.assertEqual(j['reason'], 'Source IP Address not in ACL') self.writeCmdToConsole('setACL({"0.0.0.0/0"})') def test_getBL(self): r = self.getBLFunc() j = r.json() - self.assertEquals(j['bl_entries'], []) + self.assertEqual(j['bl_entries'], []) def test_customFunc(self): r = self.customFunc("custom1") j = r.json() - self.assertEquals(j['r_attrs']['login'], 'custom1') + self.assertEqual(j['r_attrs']['login'], 'custom1') def test_customGetFunc(self): r = self.customGetFunc("testCustomGet") t = r.text - self.assertEquals(t, '1.2.3.4/32\n') + self.assertEqual(t, '1.2.3.4/32\n') def test_deviceParsing(self): r = self.allowFuncDeviceProtocol('foobar', '127.0.0.1', "12432", '"name" "Mac OS X Mail" "version" "10.0 (3226)" "os" "Mac OS X" "os-version" "10.12 (16A323)" "vendor" "Apple Inc."', "imap") j = r.json() - self.assertRegexpMatches(json.dumps(j), "Mac OS X") + self.assertRegex(json.dumps(j), "Mac OS X") r = self.allowFuncDeviceProtocol('foobar', '127.0.0.1', "12432", 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A', "http") j = r.json() - self.assertRegexpMatches(json.dumps(j), "Mac OS X") + self.assertRegex(json.dumps(j), "Mac OS X") r = self.allowFuncDeviceProtocol('foobar', '127.0.0.1', "12432", 'OpenXchange.Android.Mail/1.0+1234 (OS: 7.0; device: Samsung/GT9700)', "mobileapi") j = r.json() - self.assertRegexpMatches(json.dumps(j), "Android") + self.assertRegex(json.dumps(j), "Android") def test_getDBStats(self): self.reportFunc('dbstats', '1.4.3.2', '1234', False); r = self.getDBStatsLogin('dbstats') j = r.json(); - self.assertRegexpMatches(json.dumps(j), "countLogins") + self.assertRegex(json.dumps(j), "countLogins") r = self.getDBStatsIP('1.4.3.2') j = r.json(); - self.assertRegexpMatches(json.dumps(j), "countLogins") - self.assertRegexpMatches(json.dumps(j), "bl_reason") - self.assertRegexpMatches(json.dumps(j), '"blacklisted": false') + self.assertRegex(json.dumps(j), "countLogins") + self.assertRegex(json.dumps(j), "bl_reason") + self.assertRegex(json.dumps(j), '"blacklisted": false') def chunkGen(self): payload = dict() @@ -85,4 +85,4 @@ def testChunked(self): data=self.chunkGen(), headers={'Content-Type': 'application/json'}) j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') diff --git a/regression-tests/test_Blacklist.py b/regression-tests/test_Blacklist.py index f14346fe..2192649b 100644 --- a/regression-tests/test_Blacklist.py +++ b/regression-tests/test_Blacklist.py @@ -11,137 +11,137 @@ class TestBlacklist(ApiTestCase): def test_NetmaskBlacklist(self): r = self.allowFunc('goodie', '193.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2002:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryNetmask("193.168.0.0/16", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addBLEntryNetmask("2002:503:ba3e::/64", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '193.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() r = self.allowFunc('goodie', '2002:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() time.sleep(11); r = self.allowFunc('goodie', '193.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2002:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_IPBlacklist(self): r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2001:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryIP("192.168.72.14", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addBLEntryIP("2001:503:ba3e::2:30", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() r = self.allowFunc('goodie', '2001:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() time.sleep(11); r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2001:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_LoginBlacklist(self): r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryLogin("goodie", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() time.sleep(11); r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_IPLoginBlacklist(self): r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryIPLogin("192.168.72.14", "goodie", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() r = self.allowFunc('goody', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '192.168.72.15', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() time.sleep(11); r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_PersistBlacklist(self): @@ -151,7 +151,7 @@ def test_PersistBlacklist(self): r = self.addBLEntryIPPersist("99.99.99.99", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') print("Killing process") proc3.terminate() diff --git a/regression-tests/test_Block.py b/regression-tests/test_Block.py index f6e88ccb..87d950d4 100644 --- a/regression-tests/test_Block.py +++ b/regression-tests/test_Block.py @@ -9,7 +9,7 @@ class TestBlock(ApiTestCase): def test_block(self): r = self.allowFunc("baddie", "127.0.0.1", "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(100): @@ -18,6 +18,6 @@ def test_block(self): r = self.allowFunc('baddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r.close() diff --git a/regression-tests/test_GeoIP.py b/regression-tests/test_GeoIP.py index cb79502f..b73938a1 100644 --- a/regression-tests/test_GeoIP.py +++ b/regression-tests/test_GeoIP.py @@ -19,8 +19,8 @@ def test_geoIP(self): # don't allow IPs from Japan (arbitrary) r = self.allowFunc('baddie', '112.78.112.20', "1234") j = r.json() - self.assertEquals(j['status'], -1) - self.assertRegexpMatches(json.dumps(j), "Japan") + self.assertEqual(j['status'], -1) + self.assertRegex(json.dumps(j), "Japan") r.close() # def test_geoIP2City(self): @@ -28,7 +28,7 @@ def test_geoIP(self): # attrs['ip'] = '128.243.1.1' # r = self.customFuncWithName("geoip2", attrs) # j = r.json() -# self.assertRegexpMatches(json.dumps(j), "Nottingham") +# self.assertRegex(json.dumps(j), "Nottingham") # r.close() def test_geoIP2LookupVals(self): @@ -39,6 +39,6 @@ def test_geoIP2LookupVals(self): r = self.customFuncWithName("geoip2_lookupValue", attrs) j = r.json() print(json.dumps(j)) - self.assertRegexpMatches(json.dumps(j['r_attrs']['city']), "Nottingham") - self.assertRegexpMatches(json.dumps(j['r_attrs']['latitude']), "52.9538") + self.assertRegex(json.dumps(j['r_attrs']['city']), "Nottingham") + self.assertRegex(json.dumps(j['r_attrs']['latitude']), "52.9538") r.close() diff --git a/regression-tests/test_Prometheus.py b/regression-tests/test_Prometheus.py index becadaec..50fed0f3 100644 --- a/regression-tests/test_Prometheus.py +++ b/regression-tests/test_Prometheus.py @@ -34,14 +34,14 @@ def parsePrometheusResponse(self, response): def getWforcePrometheusValues(self): r = self.getWforceMetrics() self.assertTrue(r) - self.assertEquals(r.status_code, 200) + self.assertEqual(r.status_code, 200) return self.parsePrometheusResponse(r.text) def getTrackalertPrometheusValues(self): r = self.getTrackalertMetrics() self.assertTrue(r) - self.assertEquals(r.status_code, 200) + self.assertEqual(r.status_code, 200) return self.parsePrometheusResponse(r.text) diff --git a/regression-tests/test_Replication.py b/regression-tests/test_Replication.py index 0998de13..4382d794 100644 --- a/regression-tests/test_Replication.py +++ b/regression-tests/test_Replication.py @@ -12,7 +12,7 @@ def setUp(self): def test_invalidPasswords(self): r = self.allowFunc('ivbaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(22): @@ -22,26 +22,26 @@ def test_invalidPasswords(self): time.sleep(1) r = self.allowFuncReplica('ivbaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('ivbaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(16) r = self.allowFuncReplica('ivbaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('ivbaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_FailedLogins(self): r = self.allowFunc('flbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(32): @@ -51,26 +51,26 @@ def test_FailedLogins(self): time.sleep(1) r = self.allowFuncReplica('flbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('flbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(16) r = self.allowFuncReplica('flbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('flbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_diffIPs(self): r = self.allowFunc('ipbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(12): @@ -80,26 +80,26 @@ def test_diffIPs(self): time.sleep(1) r = self.allowFuncReplica('ipbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('ipbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(16) r = self.allowFuncReplica('ipbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('ipbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_subTest(self): r = self.allowFunc('subbaddiereplication', '228.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(42): @@ -108,26 +108,26 @@ def test_subTest(self): r = self.allowFuncReplica('subbaddiereplication', '228.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('subbaddiereplication', '228.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(15) r = self.allowFuncReplica('subbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('subbaddiereplication', '227.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_Prefixv4(self): r = self.allowFunc('ipv4baddiereplication', '114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -137,26 +137,26 @@ def test_Prefixv4(self): time.sleep(1) r = self.allowFuncReplica('ipv4baddiereplication', '114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('ipv4baddiereplication', '114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(16) r = self.allowFuncReplica('ipv4baddiereplication', '114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('ipv4baddiereplication', '114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_PrefixMappedv4(self): r = self.allowFunc('mappedipv4baddiereplication', '::ffff:114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -166,26 +166,26 @@ def test_PrefixMappedv4(self): time.sleep(1) r = self.allowFuncReplica('mappedipv4baddiereplication', '::ffff:114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('mappedipv4baddiereplication', '::ffff:114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) # Wait for the time windows to clear and then check again time.sleep(16) r = self.allowFuncReplica('mappedipv4baddiereplication', '::ffff:114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('mappedipv4baddiereplication', '::ffff:114.31.193.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_Prefixv6(self): r = self.allowFunc('ipv6baddiereplication', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -195,26 +195,26 @@ def test_Prefixv6(self): time.sleep(1) r = self.allowFuncReplica('ipv6baddiereplication', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('ipv6baddiereplication', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(16) r = self.allowFuncReplica('ipv6baddiereplication', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('ipv6baddiereplication', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_expiry(self): r = self.allowFunc('expirebaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(20): @@ -226,26 +226,26 @@ def test_expiry(self): r = self.allowFuncReplica('expirebaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('expirebaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the expiry thread to delete everything bigger than size (10) and then check again time.sleep(30) r = self.allowFuncReplica('expirebaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('expirebaddiereplication', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_Reset(self): r = self.allowFunc('resetbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(32): @@ -255,57 +255,57 @@ def test_Reset(self): time.sleep(1) r = self.allowFuncReplica('resetbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.allowFuncReplica2('resetbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.resetFunc('resetbaddiereplication', '128.0.0.1') j = r.json() - self.assertEquals(j['status'], "ok") + self.assertEqual(j['status'], "ok") time.sleep(1) r = self.allowFuncReplica('resetbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r = self.allowFuncReplica2('resetbaddiereplication', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_resetField(self): r = self.resetLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') r = self.incLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '1') + self.assertEqual(j['r_attrs']['countLogins'], '1') time.sleep(1) r = self.countLoginsReplica("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '1') + self.assertEqual(j['r_attrs']['countLogins'], '1') r = self.countLoginsReplica2("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '1') + self.assertEqual(j['r_attrs']['countLogins'], '1') r = self.resetLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') time.sleep(1) r = self.countLoginsReplica("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') r = self.countLoginsReplica2("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') def test_BlackWhitelist(self): self.addBLEntryIP('12.12.12.12', 60, "replication bl test") diff --git a/regression-tests/test_TimeWindows.py b/regression-tests/test_TimeWindows.py index 63806548..14499f94 100644 --- a/regression-tests/test_TimeWindows.py +++ b/regression-tests/test_TimeWindows.py @@ -12,7 +12,7 @@ def setUp(self): def test_invalidPasswords(self): r = self.allowFunc('ivbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(25): @@ -21,18 +21,18 @@ def test_invalidPasswords(self): r = self.allowFunc('ivbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('ivbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_FailedLogins(self): r = self.allowFunc('flbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(32): @@ -41,18 +41,18 @@ def test_FailedLogins(self): r = self.allowFunc('flbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('flbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_diffIPs(self): r = self.allowFunc('ipbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(12): @@ -61,18 +61,18 @@ def test_diffIPs(self): r = self.allowFunc('ipbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('ipbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_subTest(self): r = self.allowFunc('subbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(42): @@ -81,18 +81,18 @@ def test_subTest(self): r = self.allowFunc('subbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('subbaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_Prefixv4(self): r = self.allowFunc('ipv4baddie', '114.31.192.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -101,18 +101,18 @@ def test_Prefixv4(self): r = self.allowFunc('ipv4baddie', '114.31.192.200', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('ipv4baddie', '114.31.192.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_PrefixMappedv4(self): r = self.allowFunc('mappedipv4baddie', '::ffff:114.31.192.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -121,18 +121,18 @@ def test_PrefixMappedv4(self): r = self.allowFunc('mappedipv4baddie', '::ffff:114.31.192.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('mappedipv4baddie', '::ffff:114.31.192.200', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_Prefixv6(self): r = self.allowFunc('ipv6baddie', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -141,18 +141,18 @@ def test_Prefixv6(self): r = self.allowFunc('ipv6baddie', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the time windows to clear and then check again time.sleep(20) r = self.allowFunc('ipv6baddie', '2001:c78::1000', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_expiry(self): r = self.allowFunc('expirebaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(50): @@ -161,19 +161,19 @@ def test_expiry(self): r = self.allowFunc('expirebaddie', '127.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) # Wait for the expiry thread to delete everything bigger than size (10) and then check again time.sleep(35) r = self.allowFunc('expirebaddie', '127.0.01', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_Reset(self): time.sleep(16) r = self.allowFunc('resetbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() for i in range(32): @@ -182,29 +182,29 @@ def test_Reset(self): r = self.allowFunc('resetbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], -1) + self.assertEqual(j['status'], -1) r = self.resetFunc('resetbaddie', '128.0.0.1') j = r.json() - self.assertEquals(j['status'], "ok") + self.assertEqual(j['status'], "ok") r = self.allowFunc('resetbaddie', '128.0.0.1', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) def test_ResetField(self): r = self.resetLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') r = self.incLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '1') + self.assertEqual(j['r_attrs']['countLogins'], '1') r = self.resetLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') r = self.countLogins("resetFieldTest") j = r.json() - self.assertEquals(j['r_attrs']['countLogins'], '0') + self.assertEqual(j['r_attrs']['countLogins'], '0') diff --git a/regression-tests/test_Trackalert.py b/regression-tests/test_Trackalert.py index 469dfefa..a958bbe1 100644 --- a/regression-tests/test_Trackalert.py +++ b/regression-tests/test_Trackalert.py @@ -11,13 +11,13 @@ class TestTrackalert(ApiTestCase): def test_auth_stats(self): r = self.session.get(self.ta_url("/?command=stats")) - self.assertEquals(r.status_code, requests.codes.ok) + self.assertEqual(r.status_code, requests.codes.ok) def test_wforceToTrackalert(self): self.writeCmdToConsole("addWebHook(ta_events, tack)") r = self.reportFunc('wforce2trackalert', '1.4.3.2', '1234', False); j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') time.sleep(5) logfile = open('/tmp/trackalert.log', 'r') s = mmap.mmap(logfile.fileno(), 0, access=mmap.ACCESS_READ) @@ -25,7 +25,7 @@ def test_wforceToTrackalert(self): for mystring in [ 'login=wforce2trackalert', 'remote=1.4.3.2' ]: regex = re.escape(mystring) result = re.search(regex, search_str); - self.assertNotEquals(result, None) + self.assertNotEqual(result, None) s.close() logfile.close() @@ -41,7 +41,7 @@ def test_trackalertReport(self): for mystring in [ 'login=tareportuser', 'remote=127.0.0.1' ]: regex = re.escape(mystring) result = re.search(regex, search_str); - self.assertNotEquals(result, None) + self.assertNotEqual(result, None) s.close() logfile.close() @@ -53,11 +53,11 @@ def test_trackalertBackgroundFuncs(self): for mystring in [ 'background1', 'background2' ]: regex = re.escape(mystring) result = re.search(regex, search_str); - self.assertNotEquals(result, None) + self.assertNotEqual(result, None) s.close() logfile.close() def test_trackalertCustomFunc(self): r = self.trackalertCustomFunc("custom1") j = r.json() - self.assertEquals(j['r_attrs']['login'], 'custom1') + self.assertEqual(j['r_attrs']['login'], 'custom1') diff --git a/regression-tests/test_WebHooks.py b/regression-tests/test_WebHooks.py index 0a2c7970..443c9e49 100644 --- a/regression-tests/test_WebHooks.py +++ b/regression-tests/test_WebHooks.py @@ -24,7 +24,7 @@ def test_webhooks(self): for event in [ 'report', 'allow', 'reset', 'addbl', 'delbl', 'expirebl' ]: regex = r"digest_match=True, event=" + re.escape(event) result = re.search(regex, search_str); - self.assertNotEquals(result, None) + self.assertNotEqual(result, None) s.close() logfile.close() @@ -58,7 +58,7 @@ def test_customwebhooks(self): self.writeCmdToConsole("addCustomWebHook(\"customwebhook\", ck)") r = self.customFunc("custom1") j = r.json() - self.assertEquals(j['r_attrs']['login'], 'custom1') + self.assertEqual(j['r_attrs']['login'], 'custom1') time.sleep(5) logfile = open('/tmp/webhook-server.log', 'r') s = mmap.mmap(logfile.fileno(), 0, access=mmap.ACCESS_READ) @@ -66,7 +66,7 @@ def test_customwebhooks(self): for event in [ 'customwebhook' ]: regex = r"digest_match=True, event=" + re.escape(event) result = re.search(regex, search_str); - self.assertNotEquals(result, None) + self.assertNotEqual(result, None) s.close() logfile.close() @@ -81,6 +81,6 @@ def test_namedreportsinks(self): for event in [ 'namedreportsink', 'customargs' ]: regex = r"\"login\": \"" + re.escape(event) result = re.search(regex, search_str); - self.assertNotEquals(result, None) + self.assertNotEqual(result, None) s.close() logfile.close() diff --git a/regression-tests/test_Whitelist.py b/regression-tests/test_Whitelist.py index 7f62f43f..06e77da1 100644 --- a/regression-tests/test_Whitelist.py +++ b/regression-tests/test_Whitelist.py @@ -11,156 +11,156 @@ class TestWhitelist(ApiTestCase): def test_NetmaskWhitelist(self): r = self.allowFunc('goodie', '193.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2002:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryNetmask("193.168.0.0/16", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addBLEntryNetmask("2002:503:ba3e::/64", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addWLEntryNetmask("193.168.0.0/16", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addWLEntryNetmask("2002:503:ba3e::/64", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '193.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2002:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() time.sleep(11); r = self.allowFunc('goodie', '193.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2002:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_IPWhitelist(self): r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2001:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryIP("192.168.72.14", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addBLEntryIP("2001:503:ba3e::2:30", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addWLEntryIP("192.168.72.14", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addWLEntryIP("2001:503:ba3e::2:30", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2001:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() time.sleep(11); r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '2001:503:ba3e::2:30', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_LoginWhitelist(self): r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryLogin("goodie", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addWLEntryLogin("goodie", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() time.sleep(11); r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_IPLoginBlacklist(self): r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.addBLEntryIPLogin("192.168.72.14", "goodie", 10, "test blacklist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.addWLEntryIPLogin("192.168.72.14", "goodie", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() r = self.allowFunc('goodie', '192.168.72.15', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() time.sleep(11); r = self.allowFunc('goodie', '192.168.72.14', "1234") j = r.json() - self.assertEquals(j['status'], 0) + self.assertEqual(j['status'], 0) r.close() def test_PersistWhitelist(self): @@ -170,7 +170,7 @@ def test_PersistWhitelist(self): r = self.addWLEntryIPPersist("99.99.99.99", 10, "test whitelist") j = r.json() - self.assertEquals(j['status'], 'ok') + self.assertEqual(j['status'], 'ok') print("Killing process") proc3.terminate() diff --git a/regression-tests/test_helper.py b/regression-tests/test_helper.py index f8412af7..29a33ad8 100644 --- a/regression-tests/test_helper.py +++ b/regression-tests/test_helper.py @@ -560,4 +560,4 @@ def assert_success_json(self, result): except: print(result.content) raise - self.assertEquals(result.headers['Content-Type'], 'application/json') + self.assertEqual(result.headers['Content-Type'], 'application/json')