2015-09-25 12:01:46 +02:00
|
|
|
VIRTUALENV = virtualenv
|
|
|
|
|
VENV := $(shell echo $${VIRTUAL_ENV-.venv})
|
|
|
|
|
PYTHON = $(VENV)/bin/python
|
|
|
|
|
DEV_STAMP = $(VENV)/.dev_env_installed.stamp
|
|
|
|
|
INSTALL_STAMP = $(VENV)/.install.stamp
|
|
|
|
|
|
|
|
|
|
.IGNORE: clean
|
|
|
|
|
.PHONY: all install dev-requirements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
all: build
|
|
|
|
|
|
|
|
|
|
build:
|
2015-09-06 21:46:29 -04:00
|
|
|
python setup.py build
|
2015-09-06 17:20:34 -04:00
|
|
|
|
2015-09-25 12:01:46 +02:00
|
|
|
install: $(INSTALL_STAMP)
|
|
|
|
|
|
|
|
|
|
$(INSTALL_STAMP): $(PYTHON) setup.py
|
|
|
|
|
$(VENV)/bin/pip install -U pip
|
|
|
|
|
$(VENV)/bin/pip install -Ue .
|
|
|
|
|
touch $(INSTALL_STAMP)
|
2015-09-06 17:20:34 -04:00
|
|
|
|
2015-09-25 12:01:46 +02:00
|
|
|
dev-requirements: $(INSTALL_STAMP) $(DEV_STAMP)
|
|
|
|
|
$(DEV_STAMP): $(PYTHON) dev-requirements.txt
|
|
|
|
|
$(VENV)/bin/pip install tox
|
|
|
|
|
$(VENV)/bin/pip install -Ur dev-requirements.txt
|
|
|
|
|
touch $(DEV_STAMP)
|
2015-09-06 17:20:34 -04:00
|
|
|
|
2015-09-25 12:01:46 +02:00
|
|
|
virtualenv: $(PYTHON)
|
|
|
|
|
$(PYTHON):
|
|
|
|
|
virtualenv $(VENV)
|
2015-09-06 17:20:34 -04:00
|
|
|
|
2015-09-25 12:01:46 +02:00
|
|
|
tests: dev-requirements
|
|
|
|
|
$(VENV)/bin/tox
|
2015-09-25 11:48:32 +02:00
|
|
|
|
2015-09-25 12:01:46 +02:00
|
|
|
tests-once: install dev-requirements
|
2015-09-25 12:29:46 +02:00
|
|
|
$(VENV)/bin/py.test --cov-report term-missing --cov sops tests/
|
2015-09-06 17:20:34 -04:00
|
|
|
|
2015-10-08 15:43:15 -04:00
|
|
|
functional-tests:
|
|
|
|
|
gpg --import tests/sops_functional_tests_key.asc 2>&1 1>/dev/null || exit 0
|
|
|
|
|
for type in yaml json txt; do \
|
|
|
|
|
for ver in 2.6 2.7 3.4; do \
|
|
|
|
|
echo "Testing Python$$ver $$type decryption" && \
|
|
|
|
|
python$$ver sops/__init__.py -d example.$$type > /tmp/testdata.$$type && \
|
|
|
|
|
echo "Testing Python$$ver $$type encryption" && \
|
2015-10-26 14:17:38 -04:00
|
|
|
python$$ver sops/__init__.py -e -p "1022470DE3F0BC54BC6AB62DE05550BC07FB1A0A" /tmp/testdata.$$type > /tmp/testdata$$ver.$$type; \
|
2015-10-08 15:43:15 -04:00
|
|
|
done && \
|
|
|
|
|
echo "Testing Python2.6 decryption of a 2.7 $$type file" && \
|
|
|
|
|
python2.6 sops/__init__.py -d /tmp/testdata2.7.$$type > /dev/null && \
|
|
|
|
|
echo "Testing Python2.6 decryption of a 3.4 $$type file" && \
|
|
|
|
|
python2.6 sops/__init__.py -d /tmp/testdata3.4.$$type > /dev/null && \
|
|
|
|
|
echo "Testing Python2.7 decryption of a 2.6 $$type file" && \
|
|
|
|
|
python2.7 sops/__init__.py -d /tmp/testdata2.6.$$type > /dev/null && \
|
|
|
|
|
echo "Testing Python2.7 decryption of a 3.4 $$type file" && \
|
|
|
|
|
python2.7 sops/__init__.py -d /tmp/testdata3.4.$$type > /dev/null && \
|
|
|
|
|
echo "Testing Python3.4 decryption of a 2.6 $$type file" && \
|
|
|
|
|
python3.4 sops/__init__.py -d /tmp/testdata2.6.$$type > /dev/null && \
|
|
|
|
|
echo "Testing Python3.4 decryption of a 2.7 $$type file" && \
|
|
|
|
|
python3.4 sops/__init__.py -d /tmp/testdata2.7.$$type > /dev/null || exit 1; \
|
2015-10-26 14:17:38 -04:00
|
|
|
done && \
|
|
|
|
|
for ver in 2.6 2.7 3.4; do \
|
2015-10-08 15:43:15 -04:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
functional-tests-once:
|
|
|
|
|
gpg --import tests/sops_functional_tests_key.asc 2>&1 1>/dev/null || exit 0
|
|
|
|
|
for type in yaml json txt; do \
|
2016-04-19 12:22:32 -04:00
|
|
|
echo "Testing $$type decryption"; \
|
|
|
|
|
python sops/__init__.py -d example.$$type > /tmp/testdata.$$type; \
|
|
|
|
|
echo "Testing $$type encryption" ; \
|
2015-10-26 14:17:38 -04:00
|
|
|
python sops/__init__.py -e -p "1022470DE3F0BC54BC6AB62DE05550BC07FB1A0A" /tmp/testdata.$$type > /tmp/testdataenc.$$type; \
|
2016-04-19 12:22:32 -04:00
|
|
|
echo "Testing $$type re-decryption" ; \
|
|
|
|
|
python sops/__init__.py -d /tmp/testdataenc.$$type > /dev/null ; \
|
|
|
|
|
echo "Testing removing PGP key to $$type encrypted file" ; \
|
|
|
|
|
python sops/__init__.py -r --rm-pgp 85D77543B3D624B63CEA9E6DBC17301B491B3F21 /tmp/testdataenc.$$type ; \
|
2015-10-08 15:43:15 -04:00
|
|
|
done
|
2016-04-19 12:22:32 -04:00
|
|
|
echo "Testing round-trip on binary file"
|
|
|
|
|
dd if=/dev/urandom of=/tmp/testdata-randomfile bs=1024 count=1024 2>&1 1>/dev/null
|
|
|
|
|
python sops/__init__.py -e -p "1022470DE3F0BC54BC6AB62DE05550BC07FB1A0A" /tmp/testdata-randomfile > /tmp/testdata-randomfile.enc
|
|
|
|
|
python sops/__init__.py -d /tmp/testdata-randomfile.enc > /tmp/testdata-randomfile.dec
|
2017-07-26 08:54:58 -07:00
|
|
|
if [ $$(shasum -a 256 /tmp/testdata-randomfile | cut -d ' ' -f 1) != $$(shasum -a 256 /tmp/testdata-randomfile.dec | cut -d ' ' -f 1) ]; then \
|
2016-04-19 12:22:32 -04:00
|
|
|
echo "Binary file roundtrip failed, checksum doesn't match"; exit 0; \
|
|
|
|
|
else \
|
|
|
|
|
echo "Binary file roundtrip succeeded"; \
|
|
|
|
|
fi;
|
Fix --extract on Python 3
Previously, `--extract` would fail on Python 3:
```
Traceback (most recent call last):
File "/Users/andy/.virtualenvs/sops-py3/bin/sops", line 11, in <module>
load_entry_point('sops', 'console_scripts', 'sops')()
File "/Users/andy/forks/sops/sops/__init__.py", line 278, in main
write_file(tree, path=dest, filetype=otype)
File "/Users/andy/forks/sops/sops/__init__.py", line 1321, in write_file
sys.stdout.write(tree.encode('utf-8'))
TypeError: write() argument must be str, not bytes
```
2018-11-27 10:25:14 -08:00
|
|
|
echo "Testing --extract"
|
|
|
|
|
python sops/__init__.py -d --extract '["firstName"]' example.json
|
2018-11-27 10:48:56 -08:00
|
|
|
[ $$(python sops/__init__.py -d --extract '["firstName"]' example.json) = $$(python sops/__init__.py -d example.json | grep firstName | cut -d '"' -f 4) ]
|
2015-10-08 15:43:15 -04:00
|
|
|
|
2016-03-24 09:57:39 -04:00
|
|
|
pypi:
|
2015-09-25 12:01:46 +02:00
|
|
|
$(PYTHON) setup.py sdist check upload --sign
|
2015-09-06 17:20:34 -04:00
|
|
|
|
|
|
|
|
clean:
|
2015-09-25 11:48:32 +02:00
|
|
|
rm -rf *.pyc sops/*.pyc
|
|
|
|
|
rm -rf __pycache__ sops/__pycache__
|
|
|
|
|
rm -rf build/ dist/
|
2015-09-25 12:01:46 +02:00
|
|
|
rm -fr .tox/ .venv/
|
2015-09-25 12:29:46 +02:00
|
|
|
rm -fr .coverage
|