Updated test & requirements filename

Thanks for your PR! I was wondering why everyone kept complaining about
`bcrypt`, when my local tests were succeeding just fine, so I spent
some time making the docker test script replicate the error.

Turns out the `.htpasswd` files I was generating were using md5, so they
were not triggering the error. The htpasswd file in this update does
use bcrypt encryption, so it triggers a 500 error on the previous
version of the Dockerfile.

I also updated the test to be a bit more thorough, validating an
authenticated upload in addition to just making sure the server is
running.

The only other change I made was to move `requirements.txt` into a more
specific `docker-requirements.txt` file, just to make it clear that its
intention is to be a part of the docker build and not the normal install
process.
This commit is contained in:
Matthew Planchard 2019-01-30 19:58:47 -06:00 committed by Ron Nabuurs
parent 7b9d0ef285
commit d162d660c4
No known key found for this signature in database
GPG Key ID: AE92F68123254628
6 changed files with 39 additions and 8 deletions

@ -11,7 +11,7 @@ python:
- pypy3
install:
- pip install -U setuptools pip sphinx tox tox-travis
- pip install -U setuptools twine pip sphinx tox tox-travis
script:
- ./bin/test-docker.sh

@ -17,7 +17,7 @@ FROM base as builder
# Copy the requirements and install them
# Do this in a separate image in a separate directory
# to not have all the pip stuff in the final image
COPY requirements.txt /requirements.txt
COPY docker-requirements.txt /requirements.txt
# Install python packages
RUN apk add --no-cache py2-pip \

Binary file not shown.

@ -5,15 +5,44 @@
set -xe # exit on any error, show debug output
DIR="$( cd "$( dirname "$0" )" >/dev/null 2>&1 && pwd )"
docker build . -t pypiserver:test
docker run pypiserver:test --help
docker run pypiserver:test --help > /dev/null
CONTAINER_ID=$(docker run -d -p 8080:8080 pypiserver:test)
# Mount our htpasswd file, which contains a test user with a bcrypt-encrypted
# "test" password
CONTAINER_ID=$(docker run \
-d \
-v "${DIR}/test.htpasswd:/data/.htpasswd" \
-p 8080:8080 \
pypiserver:test -a "list,update,download" -P /data/.htpasswd packages)
sleep 5 # give the contaienr some time to get going
trap "docker container stop $CONTAINER_ID" EXIT
# Ensure our home page is returning something
curl localhost:8080 | grep -q "pypiserver"
sleep 5 # give the container some time to get going
docker container stop "$CONTAINER_ID"
# Ensure we can authenticate locally
RET=$(curl localhost:8080)
echo $RET
echo $RET | grep -q "pypiserver"
RET=$(curl localhost:8080/packages/)
echo $RET
echo $RET | grep -q "401"
RET=$(curl test:test@localhost:8080/packages/)
echo $RET
echo $RET | grep -q "Index of packages"
twine upload \
-u test \
-p test \
--repository-url http://localhost:8080 \
"${DIR}/pypiserver-1.2.6-py2.py3-none-any.whl"
RET=$(curl test:test@localhost:8080/packages/)
echo $RET
echo $RET | grep -q "pypiserver-1.2.6"

2
bin/test.htpasswd Normal file

@ -0,0 +1,2 @@
test:$2y$05$0wU8vmgucWeyLyqxB.mm1OOPf660/exARXPN5uC.gHaWziv7C4t/m