From: Aleksei Nikiforov <darktemplar@altlinux.org> To: devel@lists.altlinux.org Cc: Aleksei Nikiforov <darktemplar@altlinux.org> Subject: [devel] [PATCH for apt 36/38] Add http and https methods tests Date: Tue, 10 Dec 2019 18:23:41 +0300 Message-ID: <20191210152343.33867-37-darktemplar@altlinux.org> (raw) In-Reply-To: <20191210152343.33867-1-darktemplar@altlinux.org> --- apt/test/integration/framework | 104 +++++++++++++++++- apt/test/integration/test-apt-method-http | 29 +++++ apt/test/integration/test-apt-method-https | 56 ++++++++++ ...est-apt-method-https-invalid-cert-hostname | 41 +++++++ 4 files changed, 229 insertions(+), 1 deletion(-) create mode 100755 apt/test/integration/test-apt-method-http create mode 100755 apt/test/integration/test-apt-method-https create mode 100755 apt/test/integration/test-apt-method-https-invalid-cert-hostname diff --git a/apt/test/integration/framework b/apt/test/integration/framework index fa9672d..6098089 100644 --- a/apt/test/integration/framework +++ b/apt/test/integration/framework @@ -519,7 +519,7 @@ generaterepository() { --suite="${GB_REPO_SUITE:-$label}" \ --version="${GB_REPO_VERSION:-$date_s}" \ --topdir="$REPO_DIR" \ - --flat --no-oldhashfile --no-bz2 --no-xz --mapi \ + --flat --no-oldhashfile --bz2 --xz --mapi \ $dir $comps if [ -n "$REPO_DATE" ] ; then @@ -552,3 +552,105 @@ ENDSCRIPT chmod +x $TMPWORKINGDIRECTORY/bash/scripts/${SCRIPTFILENAME}.sh } + +nginxsetuphttp() { + mkdir -p $TMPWORKINGDIRECTORY/nginx ||: + mkdir -p $TMPWORKINGDIRECTORY/nginx/tmp ||: + +cat >> $TMPWORKINGDIRECTORY/nginx/nginx.conf << ENDCONFIG +worker_processes 1; +error_log $TMPWORKINGDIRECTORY/nginx/error.log; +daemon off; +pid $TMPWORKINGDIRECTORY/nginx/nginx.pid; + +events { + worker_connections 1024; +} + +http { + client_body_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/client_body; + fastcgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/fastcgi_temp; + proxy_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/proxy_temp; + scgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/scgi_temp; + uwsgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/uwsgi_temp; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + + keepalive_timeout 65; + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_prefer_server_ciphers on; + access_log $TMPWORKINGDIRECTORY/nginx/http.access.log; + error_log $TMPWORKINGDIRECTORY/nginx/http.error.log; + + server { + listen 8080; + server_name localhost localhost.localdomain; + + location / { + root $TMPWORKINGDIRECTORY/nginx/repo; + autoindex on; + } + } +} +ENDCONFIG +} + +nginxsetuphttps() { + mkdir -p $TMPWORKINGDIRECTORY/nginx ||: + mkdir -p $TMPWORKINGDIRECTORY/nginx/tmp ||: + + cat >> $TMPWORKINGDIRECTORY/nginx/nginx.conf << ENDCONFIG +worker_processes 1; +error_log $TMPWORKINGDIRECTORY/nginx/error.log; +daemon off; +pid $TMPWORKINGDIRECTORY/nginx/nginx.pid; + +events { + worker_connections 1024; +} + +http { + client_body_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/client_body; + fastcgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/fastcgi_temp; + proxy_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/proxy_temp; + scgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/scgi_temp; + uwsgi_temp_path $TMPWORKINGDIRECTORY/nginx/tmp/uwsgi_temp; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + + keepalive_timeout 65; + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_prefer_server_ciphers on; + access_log $TMPWORKINGDIRECTORY/nginx/http.access.log; + error_log $TMPWORKINGDIRECTORY/nginx/http.error.log; + + server { + listen 8080; + server_name localhost localhost.localdomain; + + ssl_certificate $TMPWORKINGDIRECTORY/nginx/cert.crt; + ssl_certificate_key $TMPWORKINGDIRECTORY/nginx/cert.key; + + ssl on; + + ssl_session_cache builtin:1000 shared:SSL:10m; + ssl_protocols TLSv1.2; + ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4; + ssl_prefer_server_ciphers on; + + location / { + root $TMPWORKINGDIRECTORY/nginx/repo; + autoindex on; + } + } +} +ENDCONFIG +} diff --git a/apt/test/integration/test-apt-method-http b/apt/test/integration/test-apt-method-http new file mode 100755 index 0000000..0872c99 --- /dev/null +++ b/apt/test/integration/test-apt-method-http @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment + +nginxsetuphttp + +buildpackage "simple-package" + +generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/nginx/repo" + +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list << END +rpm http://localhost:8080/ $(getarchitecture) apt-tests +rpm http://localhost:8080/ noarch apt-tests +END + +/usr/sbin/nginx -c $TMPWORKINGDIRECTORY/nginx/nginx.conf -p $TMPWORKINGDIRECTORY &>> $TMPWORKINGDIRECTORY/nginx/process-stderr.log & +NGINXPID=$! + +addtrap 'prefix' "kill -SIGTERM $NGINXPID; [ \"$EXIT_CODE\" = '0' ] || cat $TMPWORKINGDIRECTORY/nginx/process-stderr.log;" + +testsuccess aptget update + +testpkgnotinstalled "simple-package" +testsuccess aptget install simple-package +testpkginstalled "simple-package" diff --git a/apt/test/integration/test-apt-method-https b/apt/test/integration/test-apt-method-https new file mode 100755 index 0000000..29e4d2d --- /dev/null +++ b/apt/test/integration/test-apt-method-https @@ -0,0 +1,56 @@ +#!/bin/bash +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment + +nginxsetuphttps + +# generate key +openssl req -x509 -newkey rsa:4096 -keyout $TMPWORKINGDIRECTORY/nginx/cert.key -out $TMPWORKINGDIRECTORY/nginx/cert.crt -nodes -days 365 -subj '/CN=localhost' &>/dev/null + +# add key to apt's config. Also pin the key +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/80https.conf << END +Acquire::https::CaInfo "$TMPWORKINGDIRECTORY/nginx/cert.crt"; +END + +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/81https-pinning.conf << END +Acquire::https::PinnedCert "$TMPWORKINGDIRECTORY/nginx/cert.crt"; +END + +buildpackage "simple-package" +buildpackage "conflicting-package-one" + +generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/nginx/repo" + +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list << END +rpm https://localhost:8080/ $(getarchitecture) apt-tests +rpm https://localhost:8080/ noarch apt-tests +END + +/usr/sbin/nginx -c $TMPWORKINGDIRECTORY/nginx/nginx.conf -p $TMPWORKINGDIRECTORY &>> $TMPWORKINGDIRECTORY/nginx/process-stderr.log & +NGINXPID=$! + +addtrap 'prefix' "kill -SIGTERM $NGINXPID; [ \"$EXIT_CODE\" = '0' ] || cat $TMPWORKINGDIRECTORY/nginx/process-stderr.log;" + +testsuccess aptget update + +testpkgnotinstalled "simple-package" +testsuccess aptget install simple-package +testpkginstalled "simple-package" + +# generate another key, and pin apt to it. Check key pinning +msgmsg "Pinning invalid key in apt" +openssl req -x509 -newkey rsa:4096 -keyout $TMPWORKINGDIRECTORY/nginx/cert.invalid.key -out $TMPWORKINGDIRECTORY/nginx/cert.invalid.crt -nodes -days 365 -subj '/CN=localhost' &>/dev/null + +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/81https-pinning.conf << END +Acquire::https::PinnedCert "$TMPWORKINGDIRECTORY/nginx/cert.invalid.crt"; +END + +testfailure aptget update + +testpkgnotinstalled "conflicting-package-one" +testfailure aptget install conflicting-package-one +testpkgnotinstalled "conflicting-package-one" diff --git a/apt/test/integration/test-apt-method-https-invalid-cert-hostname b/apt/test/integration/test-apt-method-https-invalid-cert-hostname new file mode 100755 index 0000000..33e80b6 --- /dev/null +++ b/apt/test/integration/test-apt-method-https-invalid-cert-hostname @@ -0,0 +1,41 @@ +#!/bin/bash +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment + +nginxsetuphttps + +# generate key +openssl req -x509 -newkey rsa:4096 -keyout $TMPWORKINGDIRECTORY/nginx/cert.key -out $TMPWORKINGDIRECTORY/nginx/cert.crt -nodes -days 365 -subj '/CN=wronghost' &>/dev/null + +# add key to apt's config. Also pin the key +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/80https.conf << END +Acquire::https::CaInfo "$TMPWORKINGDIRECTORY/nginx/cert.crt"; +END + +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/apt.conf.d/81https-pinning.conf << END +Acquire::https::PinnedCert "$TMPWORKINGDIRECTORY/nginx/cert.crt"; +END + +buildpackage "simple-package" + +generaterepository "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS" "$TMPWORKINGDIRECTORY/nginx/repo" + +cat > $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list << END +rpm https://localhost:8080/ $(getarchitecture) apt-tests +rpm https://localhost:8080/ noarch apt-tests +END + +/usr/sbin/nginx -c $TMPWORKINGDIRECTORY/nginx/nginx.conf -p $TMPWORKINGDIRECTORY &>> $TMPWORKINGDIRECTORY/nginx/process-stderr.log & +NGINXPID=$! + +addtrap 'prefix' "kill -SIGTERM $NGINXPID; [ \"$EXIT_CODE\" = '0' ] || cat $TMPWORKINGDIRECTORY/nginx/process-stderr.log;" + +testfailure aptget update + +testpkgnotinstalled "conflicting-package-one" +testfailure aptget install conflicting-package-one +testpkgnotinstalled "conflicting-package-one" -- 2.24.0
next prev parent reply other threads:[~2019-12-10 15:23 UTC|newest] Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-10 15:23 [devel] [PATCH for apt 00/38] Various fixes for Apt and basic integration test suite Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 01/38] Replace post-increments with pre-increments Aleksei Nikiforov 2019-12-10 18:21 ` Alexey Tourbin 2019-12-11 7:51 ` Aleksei Nikiforov 2019-12-11 8:11 ` Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 02/38] Use correct types and type specifiers Aleksei Nikiforov 2019-12-10 22:45 ` Dmitry V. Levin 2019-12-11 7:56 ` Aleksei Nikiforov 2019-12-11 23:48 ` Dmitry V. Levin 2019-12-12 9:57 ` [devel] [PATCH for apt v2 00/21] Various fixes for Apt and basic integration test suite Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 01/21] Replace post-increments with pre-increments Aleksei Nikiforov 2019-12-12 21:32 ` Andrey Savchenko 2019-12-13 8:29 ` Aleksei Nikiforov 2019-12-13 9:11 ` [devel] [PATCH for apt v3 " Aleksei Nikiforov 2019-12-13 9:12 ` [devel] [PATCH for apt v4 09/21] Rework identical conditions Aleksei Nikiforov 2019-12-13 9:18 ` [devel] [PATCH for apt v4] Additional loops improvements and beautification Aleksei Nikiforov 2019-12-13 9:20 ` Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 02/21] Use correct types and type specifiers Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 03/21] Fix potential memory corruption in pkgCache::DepIterator::AllTargets() Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 04/21] Get rid of nullptr dereference Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 05/21] Fix memory access outside of allocated buffer ranges Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 06/21] Get rid of hardcoded array size Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 07/21] Use signed types to detect IO errors Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 08/21] Use 'explicit' keyword for constructors with one argument Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 09/21] Rework identical conditions Aleksei Nikiforov 2019-12-12 19:55 ` Andrey Savchenko 2019-12-13 8:10 ` Aleksei Nikiforov 2019-12-13 8:21 ` [devel] [PATCH for apt v3 " Aleksei Nikiforov 2019-12-13 8:23 ` [devel] [PATCH for apt v3] DoList: optimize status modification loop Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 10/21] Improve member variable initialization Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 11/21] Remove useless variable shadowing Aleksei Nikiforov 2019-12-12 21:19 ` Andrey Savchenko 2019-12-12 9:57 ` [devel] [PATCH for apt v2 12/21] Fortify against buffer overflows Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 13/21] Cacheiterators: sanitize increment operators and end() function Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 14/21] Fix memory leaks Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 15/21] Fix incorrect delete operator Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 16/21] Don't access uninitialized data Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 17/21] Fix access after free error Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 18/21] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 19/21] Don't use uninitialized value Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 20/21] Get rid of dangling invalid pointer Aleksei Nikiforov 2019-12-12 9:57 ` [devel] [PATCH for apt v2 21/21] Fix invalid check of Queue against zero Aleksei Nikiforov 2019-12-12 19:08 ` Andrey Savchenko 2019-12-13 7:25 ` Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 03/38] Fix potential memory corruption in pkgCache::DepIterator::AllTargets() Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 04/38] Get rid of nullptr dereference Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 05/38] Fix memory access outside of allocated buffer ranges Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 06/38] Get rid of hardcoded array size Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 07/38] Use signed types to detect IO errors Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 08/38] Use 'explicit' keyword for constructors with one argument Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 09/38] Rework identical conditions Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 10/38] Improve member variable initialization Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 11/38] Remove useless variable shadowing Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 12/38] Fortify against buffer overflows Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 13/38] Cacheiterators: sanitize increment operators and end() function Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 14/38] Fix memory leaks Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 15/38] Fix incorrect delete operator Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 16/38] Don't access uninitialized data Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 17/38] Fix access after free error Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 18/38] Apt-pipe: ensure mainloop function doesn't return uninitialized or garbage value Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 19/38] Don't use uninitialized value Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 20/38] Get rid of dangling invalid pointer Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 21/38] Fix invalid check of Queue against zero Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 22/38] Fix iterators comparison Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 23/38] Fortify ParseQuoteWord function Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 24/38] Improve ipv6 address handling Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 25/38] Check subsecond modification time for cached files Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 26/38] Fix warning about truncation of value of pkgCache::Header::HeaderSz Aleksei Nikiforov 2019-12-10 22:57 ` Dmitry V. Levin 2019-12-11 7:51 ` Aleksei Nikiforov 2019-12-11 23:41 ` Dmitry V. Levin 2019-12-12 7:38 ` Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 27/38] FileFd: all files are closed automatically Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 28/38] Fix resource leaks in pkgCacheFile class Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 29/38] Fix off by one error in dynamic mmap leading to resource leak Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 30/38] pkgCacheFile: call Close() function in destructor Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 31/38] pkgCacheFile: don't regenerate cache if it was already built Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 32/38] Add support for rpm's dbpath configuration Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 33/38] Import integration tests framework from Debian Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 34/38] Add initial integration tests Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 35/38] Add basic tests to ensure that lua and rpm scripts are called Aleksei Nikiforov 2019-12-10 15:23 ` Aleksei Nikiforov [this message] 2019-12-10 15:23 ` [devel] [PATCH for apt 37/38] Enable integration test suite during package build Aleksei Nikiforov 2019-12-10 15:23 ` [devel] [PATCH for apt 38/38] Add code coverage support Aleksei Nikiforov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191210152343.33867-37-darktemplar@altlinux.org \ --to=darktemplar@altlinux.org \ --cc=devel@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git