# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=mitmproxy
pkgver=11.0.0
pkgrel=0
pkgdesc="Interactive TLS-capable intercepting HTTP proxy"
url="https://mitmproxy.org/"
license="MIT"
arch="noarch"
depends="
	py3-aioquic
	py3-asgiref
	py3-brotli
	py3-certifi
	py3-cryptography
	py3-flask
	py3-h11
	py3-h2
	py3-hyperframe
	py3-kaitaistruct
	py3-ldap3
	py3-mitmproxy-rs
	py3-msgpack
	py3-passlib
	py3-protobuf
	py3-openssl
	py3-parsing
	py3-pyperclip
	py3-ruamel.yaml
	py3-sortedcontainers
	py3-tornado
	py3-urwid
	py3-wsproto
	py3-publicsuffix2
	py3-zstandard
	"
makedepends="
	py3-gpep517
	py3-installer
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-hypothesis
	py3-parver
	py3-pytest
	py3-pytest-asyncio
	py3-requests
	"
subpackages="$pkgname-pyc"
source="https://github.com/mitmproxy/mitmproxy/archive/v$pkgver/mitmproxy-$pkgver.tar.gz
	skip-test-optmanager-x86.patch
	"

# secfixes:
#   7.0.3-r0:
#     - CVE-2021-39214

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	pytest \
		--deselect "test/mitmproxy/test_version.py::test_get_version" \
		--deselect "test/mitmproxy/proxy/test_mode_servers.py::test_wireguard" \
		--deselect "test/mitmproxy/addons/test_script.py::test_order"
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/mitmproxy-$pkgver-py3-none-any.whl
}

sha512sums="
d3c85736499d12f2d9a9f7821048af14fbc300aef29bc3b1b3b020a087dd9190a04143d175c78302d389207968b903e5694643c348dcf6a9f8d170d211f6bde7  mitmproxy-11.0.0.tar.gz
1baa88dae9f664af4bed62f89a7f5d13685b42774ea19563eba7298ef09fa07fafb4d5f1650e044561a5d304451d916e6c9833ad9755204d424bea6ed3bdb4fd  skip-test-optmanager-x86.patch
"
