# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=py3-certauth
pkgver=1.3.0
pkgrel=1
pkgdesc="Simple CertificateAuthority and host certificate creation, useful for man-in-the-middle HTTPS proxy"
url="https://github.com/ikreymer/certauth"
arch="noarch"
license="MIT"
depends="python3 py3-openssl py3-tldextract"
makedepends="py3-gpep517 py3-setuptools py3-wheel"
checkdepends="py3-pytest py3-pytest-cov"
subpackages="$pkgname-pyc"
source="py3-certauth-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/c/certauth/certauth-$pkgver.tar.gz"
builddir="$srcdir/certauth-$pkgver"

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

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	# test_file_ipv6_wildcard_ignore: testfile is good on github, but has unnesesary '\n' on pypi.org
	# test_custom_not_before_not_after, test_ca_cert_in_mem: https://github.com/ikreymer/certauth/issues/23
	.testenv/bin/python3 -m pytest --cov certauth -v test/ \
		-k 'not test_file_ipv6_wildcard_ignore and not test_custom_not_before_not_after and not test_ca_cert_in_mem'
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
03a483461c90ae4b91ca60e0240a67f5b9ea50642c589d83c762b168095b137a0d9726ce24e0c1fe4eb91d7dd064e42755107b5fdf60be1addaa4b7e166dc01e  py3-certauth-1.3.0.tar.gz
"
