community/ufw: enable most tests

This commit is contained in:
Sertonix 2024-07-08 22:31:41 +02:00 committed by Kevin Daudt
parent fce04623c6
commit 2365830cd7
4 changed files with 1418 additions and 3 deletions

View File

@ -0,0 +1,71 @@
From 1889b1c2e2ff877168f1beb6f5c1d0207a0107b4 Mon Sep 17 00:00:00 2001
From: Jamie Strandboge <jdstrand@ubuntu.com>
Date: Thu, 1 Feb 2024 08:08:12 -0600
Subject: [PATCH 1/3] fix: update 're' invocations for 3.12 syntax warnings
---
src/common.py | 2 +-
src/parser.py | 4 ++--
src/util.py | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/common.py b/src/common.py
index 9e8417c..b97cf00 100644
--- a/src/common.py
+++ b/src/common.py
@@ -221,7 +221,7 @@ class UFWRule:
raise UFWError(err_msg)
if int(ran[0]) >= int(ran[1]):
raise UFWError(err_msg)
- elif re.match('^\d+$', p):
+ elif re.match(r'^\d+$', p):
if int(p) < 1 or int(p) > 65535:
raise UFWError(err_msg)
elif re.match(r'^\w[\w\-]+', p):
diff --git a/src/parser.py b/src/parser.py
index b979da2..e2e018f 100644
--- a/src/parser.py
+++ b/src/parser.py
@@ -228,7 +228,7 @@ class UFWCommandRule(UFWCommand):
except ValueError as e:
raise UFWError(e)
- if not re.match('^\d([0-9,:]*\d+)*$', port):
+ if not re.match(r'^\d([0-9,:]*\d+)*$', port):
if ',' in port or ':' in port:
err_msg = _("Port ranges must be numeric")
raise UFWError(err_msg)
@@ -354,7 +354,7 @@ class UFWCommandRule(UFWCommand):
rule.sapp = tmp
else:
rule.dapp = tmp
- elif not re.match('^\d([0-9,:]*\d+)*$', tmp):
+ elif not re.match(r'^\d([0-9,:]*\d+)*$', tmp):
if ',' in tmp or ':' in tmp:
err_msg = _("Port ranges must be numeric")
raise UFWError(err_msg)
diff --git a/src/util.py b/src/util.py
index 98e3c70..a02ddfb 100644
--- a/src/util.py
+++ b/src/util.py
@@ -480,7 +480,7 @@ def _valid_dotted_quads(nm, v6):
return False
else:
if re.match(r'^[0-9]+\.[0-9\.]+$', nm):
- quads = re.split('\.', nm)
+ quads = nm.split('.')
if len(quads) != 4:
return False
for q in quads:
@@ -742,7 +742,7 @@ def get_iptables_version(exe=None):
(rc, out) = cmd([exe, '-V'])
if rc != 0:
raise OSError(errno.ENOENT, "Error running '%s'" % (exe))
- tmp = re.split('\s', out)
+ tmp = out.split()
return re.sub('^v', '', tmp[1])
--
2.45.2

File diff suppressed because it is too large Load Diff

View File

@ -3,17 +3,20 @@
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=ufw
pkgver=0.36.2
pkgrel=1
pkgrel=2
pkgdesc="Uncomplicated CLI tool managing a netfilter firewall"
url="https://launchpad.net/ufw"
arch="noarch"
license="GPL-3.0-or-later"
options="!check" # 3 tests fails
depends="iptables python3"
makedepends="py3-setuptools"
subpackages="$pkgname-doc $pkgname-openrc $pkgname-bash-completion:bashcomp:noarch $pkgname-pyc"
checkdepends="bash"
subpackages="$pkgname-doc $pkgname-openrc $pkgname-bash-completion $pkgname-pyc"
source="https://launchpad.net/ufw/${pkgver%.*}/$pkgver/+download/ufw-$pkgver.tar.gz
$pkgname.initd
0001-syntaxwarning.patch
0002-assertEqual.patch
disable-iptables-test.patch
fix-lib_path.patch
iptables-version.patch
"
@ -35,6 +38,9 @@ package() {
sha512sums="
43c5f31c98681e006b821f30e3d729eec0bbe21eeea833916b6ab18899201e5e243e5077ace32480b2a222b69b2c383ff95b7a50241053d025d68f34c25cd60b ufw-0.36.2.tar.gz
c2f1a4e4f2de3f71ef4626645acb1805df6194ee99bcbcd024092d791ccf1391e65276718f0578b1647fbc8439aa6d962f7485273c4875f5109905d9bca2fe09 ufw.initd
86f20c6c1a0d1efaeff571a8193e5f8267c7880342628c79686893dfbb000a25ae767dd049e8a89ad79a99dbccfc9744d785f8dee1b4b797d570dd9b6778fea6 0001-syntaxwarning.patch
f47d945b359e9f213b550894897e909836b4302db1bad457a9d4ebdf018f4eddaf524efe040cf20d128b95166ec7d94ffd15d694fc1c0d9a096d4b12eb374e83 0002-assertEqual.patch
0c21a46a2f8a652908be706734975f11b8e3dc527fca215847effa8db6291afc14e5938031a1dc20eb55616fe19fdc0f0c211b66c0bb3de3cc19df534348b6dc disable-iptables-test.patch
1f3f884f219dad9f2a8eaa1c02d90e82ac1646910c5a30b37cd70fc228f885aa147ef00b6e45d30bc0bdd7f2f19bc8f4db1fe0b63917ee013c07ab953744006a fix-lib_path.patch
68f86033fc2a98c81d83f65c39b9f4b9417d02b70dbced18bf6f8aa9bb327baf66e33d55b381849363fb9c87a2f757a22588d53fa0e1689f21daf802273096c4 iptables-version.patch
"

View File

@ -0,0 +1,12 @@
Failure in setUp function
--- a/tests/unit/test_backend_iptables.py
+++ b/tests/unit/test_backend_iptables.py
@@ -30,6 +30,7 @@ except ImportError:
from io import StringIO
+@unittest.skip(reason="FileNotFoundError in copytree")
class BackendIptablesTestCase(unittest.TestCase):
def setUp(self):
ufw.common.do_checks = False