diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64b7003..cf5d48b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: if: (matrix.python-version != '3.x' || matrix.platform != 'ubuntu-latest') # && matrix.platform != 'macos-latest' - name: Test with pytest (with code coverage) - run: pytest --cov=test_extract_otp_secret_keys_pytest --junitxml=pytest.xml --cov-report=term-missing | tee pytest-coverage.txt + run: pytest --cov=extract_otp_secrets_test --junitxml=pytest.xml --cov-report=term-missing | tee pytest-coverage.txt if: matrix.python-version == '3.x' && matrix.platform == 'ubuntu-latest' # https://github.com/marketplace/actions/pytest-coverage-comment - name: Pytest coverage comment diff --git a/.github/workflows/ci_docker.yml b/.github/workflows/ci_docker.yml index b5c58fe..b4d1bea 100644 --- a/.github/workflows/ci_docker.yml +++ b/.github/workflows/ci_docker.yml @@ -54,10 +54,10 @@ jobs: # builder: ${{ steps.buildx.outputs.name }} # Note: tags has to be all lower-case tags: | - scit0/extract_otp_secret_keys_no_qr_reader:latest - ghcr.io/scito/extract_otp_secret_keys_no_qr_reader:latest - scit0/extract_otp_secret_keys:latest-no-qreader - ghcr.io/scito/extract_otp_secret_keys:latest-no-qreader + scit0/extract_otp_secrets_no_qr_reader:latest + ghcr.io/scito/extract_otp_secrets_no_qr_reader:latest + scit0/extract_otp_secrets:latest-no-qreader + ghcr.io/scito/extract_otp_secrets:latest-no-qreader # build on feature branches, push only on master branch # TODO push: ${{ github.ref == 'refs/heads/master' }} push: true @@ -74,13 +74,13 @@ jobs: # builder: ${{ steps.buildx.outputs.name }} # Note: tags has to be all lower-case tags: | - scit0/extract_otp_secret_keys:latest - ghcr.io/scito/extract_otp_secret_keys:latest + scit0/extract_otp_secrets:latest + ghcr.io/scito/extract_otp_secrets:latest # build on feature branches, push only on master branch # TODO push: ${{ github.ref == 'refs/heads/master' }} push: true - name: Image digest run: | - echo "extract_otp_secret_keys: ${{ steps.docker_build_qr_reader.outputs.digest }}" - echo "extract_otp_secret_keys_no_qr_reader: ${{ steps.docker_build_no_qr_reader.outputs.digest }}" + echo "extract_otp_secrets: ${{ steps.docker_build_qr_reader.outputs.digest }}" + echo "extract_otp_secrets_no_qr_reader: ${{ steps.docker_build_no_qr_reader.outputs.digest }}" diff --git a/.vscode/launch.json b/.vscode/launch.json index 80c9b3d..762a674 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,20 +5,20 @@ "version": "0.2.0", "configurations": [ { - "name": "Python: extract_otp_secret_keys.py", + "name": "Python: extract_otp_secrets.py", "type": "python", "request": "launch", - "program": "extract_otp_secret_keys.py", + "program": "extract_otp_secrets.py", "args": [ "example_export.txt" ], "console": "integratedTerminal" }, { - "name": "Python: extract_otp_secret_keys.py stdin pic", + "name": "Python: extract_otp_secrets.py stdin pic", "type": "python", "request": "launch", - "program": "extract_otp_secret_keys.py", + "program": "extract_otp_secrets.py", "args": [ "-", "<", @@ -27,10 +27,10 @@ "console": "integratedTerminal" }, { - "name": "Python: extract_otp_secret_keys.py -C", + "name": "Python: extract_otp_secrets.py -C", "type": "python", "request": "launch", - "program": "extract_otp_secret_keys.py", + "program": "extract_otp_secrets.py", "args": [ "-v", ], diff --git a/Dockerfile b/Dockerfile index 2093f99..2912776 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ FROM python:3.11-slim-bullseye # For debugging -# docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secret_keys -# docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro extract_otp_secret_keys +# docker build . -t extract_otp_secrets --pull --build-arg RUN_TESTS=false +# docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secrets +# docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro extract_otp_secrets WORKDIR /extract @@ -16,6 +17,6 @@ RUN apt-get update && apt-get install -y libzbar0 libsm6 python3-opencv nano \ WORKDIR /files -ENTRYPOINT ["python", "/extract/src/extract_otp_secret_keys.py"] +ENTRYPOINT ["python", "/extract/src/extract_otp_secrets.py"] -LABEL org.opencontainers.image.source https://github.com/scito/extract_otp_secret_keys +LABEL org.opencontainers.image.source https://github.com/scito/extract_otp_secrets diff --git a/Dockerfile_no_qr_reader b/Dockerfile_no_qr_reader index 65672e7..9e05ed0 100644 --- a/Dockerfile_no_qr_reader +++ b/Dockerfile_no_qr_reader @@ -1,8 +1,9 @@ FROM python:3.11-alpine # For debugging -# docker run --entrypoint /bin/sh -it --rm -v "$(pwd)":/files:ro extract_otp_secret_keys_no_qr_reader -# docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secret_keys_no_qr_reader test_extract_otp_secret_keys_pytest.py -k "not qreader" --relaxed +# docker build . -t extract_otp_secrets_no_qr_reader -f Dockerfile_no_qr_reader --pull --build-arg RUN_TESTS=false +# docker run --entrypoint /bin/sh -it --rm -v "$(pwd)":/files:ro extract_otp_secrets_no_qr_reader +# docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secrets_no_qr_reader extract_otp_secrets_test.py -k "not qreader" --relaxed WORKDIR /extract @@ -15,10 +16,10 @@ RUN apk add --no-cache nano zlib jpeg \ && if [[ "$(apk --print-arch)" == "aarch64" ]]; then apk add --no-cache --virtual .build-deps gcc libc-dev python3-dev py3-setuptools zlib-dev jpeg-dev; fi \ && pip install --no-cache-dir protobuf qrcode Pillow \ && if [[ "$(apk --print-arch)" == "aarch64" ]]; then apk del .build-deps; fi \ - && if [[ "$RUN_TESTS" == "true" ]]; then /extract/run_pytest.sh tests/test_extract_otp_secret_keys_pytest.py -k "not qreader" --relaxed; else echo "Not running tests..."; fi + && if [[ "$RUN_TESTS" == "true" ]]; then /extract/run_pytest.sh tests/extract_otp_secrets_test.py -k "not qreader" --relaxed; else echo "Not running tests..."; fi WORKDIR /files -ENTRYPOINT ["python", "/extract/src/extract_otp_secret_keys.py"] +ENTRYPOINT ["python", "/extract/src/extract_otp_secrets.py"] -LABEL org.opencontainers.image.source https://github.com/scito/extract_otp_secret_keys +LABEL org.opencontainers.image.source https://github.com/scito/extract_otp_secrets diff --git a/README.md b/README.md index e66ea22..22a9dfa 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ cd extract_otp_secret_keys 3. Point the QR codes to the camera of your computer 4. Call this script with the file as input: - python extract_otp_secret_keys.py + python extract_otp_secrets.py ### With builtin QR decoder from image files @@ -42,7 +42,7 @@ cd extract_otp_secret_keys 5. Transfer the images files to the computer where his script is installed. 6. Call this script with the file as input: - python extract_otp_secret_keys.py example_export.png + python extract_otp_secrets.py example_export.png ### With external QR decoder app from text files @@ -53,11 +53,11 @@ cd extract_otp_secret_keys 5. Transfer the file to the computer where his script is installed. 6. Call this script with the file as input: - python extract_otp_secret_keys.py example_export.txt + python extract_otp_secrets.py example_export.txt ## Program help: arguments and options -
usage: extract_otp_secret_keys.py [-h] [--camera NUMBER] [--json FILE] [--csv FILE] [--keepass FILE] [--printqr] [--saveqr DIR] [--verbose | --quiet] [infile ...]
+
usage: extract_otp_secrets.py [-h] [--camera NUMBER] [--json FILE] [--csv FILE] [--keepass FILE] [--printqr] [--saveqr DIR] [--verbose | --quiet] [infile ...]
 
 Extracts one time password (OTP) secret keys from QR codes, e.g. from Google Authenticator app.
 If no infiles are provided, the QR codes are interactively captured from the camera.
@@ -78,11 +78,11 @@ options:
   --quiet, -q                 no stdout output, except output set by -
 
 examples:
-python extract_otp_secret_keys.py
-python extract_otp_secret_keys.py example_*.txt
-python extract_otp_secret_keys.py - < example_export.txt
-python extract_otp_secret_keys.py --csv - example_*.png | tail -n+2
-python extract_otp_secret_keys.py = < example_export.png
+python extract_otp_secrets.py +python extract_otp_secrets.py example_*.txt +python extract_otp_secrets.py - < example_export.txt +python extract_otp_secrets.py --csv - example_*.png | tail -n+2 +python extract_otp_secrets.py = < example_export.png
## Dependencies @@ -93,7 +93,7 @@ Known to work with * Python 3.10.8, protobuf 4.21.9, qrcode 7.3.1, and pillow 9.2 * Python 3.11.1, protobuf 4.21.12, qrcode 7.3.1, and pillow 9.2 -For protobuf versions 3.14.0 or similar or Python 3.6, use the extract_otp_secret_keys version 1.4.0. +For protobuf versions 3.14.0 or similar or Python 3.6, use the extract_otp_secrets version 1.4.0. ### Shared libs installation for reading QR code images @@ -126,38 +126,38 @@ The zbar DLLs are included with the Windows Python wheels. On other operating sy ### Printing otp secrets form text file - python extract_otp_secret_keys.py example_export.txt + python extract_otp_secrets.py example_export.txt ### Printing otp secrets from image file - python extract_otp_secret_keys.py example_export.png + python extract_otp_secrets.py example_export.png ### Printing otp secrets multiple files - python extract_otp_secret_keys.py example_*.txt - python extract_otp_secret_keys.py example_*.png - python extract_otp_secret_keys.py example_export.* - python extract_otp_secret_keys.py example_*.txt example_*.png + python extract_otp_secrets.py example_*.txt + python extract_otp_secrets.py example_*.png + python extract_otp_secrets.py example_export.* + python extract_otp_secrets.py example_*.txt example_*.png ### Printing otp secrets from stdin (text) - python extract_otp_secret_keys.py - < example_export.txt + python extract_otp_secrets.py - < example_export.txt ### Printing otp secrets from stdin (image) - python extract_otp_secret_keys.py = < example_export.png + python extract_otp_secrets.py = < example_export.png ### Printing otp secrets csv to stdout - python extract_otp_secret_keys.py --csv - example_export.txt + python extract_otp_secrets.py --csv - example_export.txt ### Printing otp secrets csv to stdout without header line - python extract_otp_secret_keys.py --csv - example_*.png | tail -n+2 + python extract_otp_secrets.py --csv - example_*.png | tail -n+2 ### Reading from stdin and printing to stdout - cat example_*.txt | python extract_otp_secret_keys.py --csv - - | tail -n+2 + cat example_*.txt | python extract_otp_secrets.py --csv - - | tail -n+2 ## Features @@ -200,7 +200,7 @@ The zbar DLLs are included with the Windows Python wheels. On other operating sy * Uses UTF-8 on all platforms * Supports Python >= 3.7 * All these features are backed by tests ran nightly -* All functionality in one Python script: extract_otp_secret_keys.py (except protobuf generated code in protobuf_generated_python) +* All functionality in one Python script: extract_otp_secrets.py (except protobuf generated code in protobuf_generated_python) ## KeePass @@ -273,27 +273,27 @@ https://github.com/nipunn1313/mypy-protobuf ``` pip install git+https://github.com/scito/extract_otp_secret_keys -python -m extract_otp_secret_keys +python -m extract_otp_secrets ``` #### For development ``` pip install git+https://github.com/scito/extract_otp_secret_keys@support_img_read -python -m extract_otp_secret_keys +python -m extract_otp_secrets ``` ``` -# pip install -e git+https://github.com/scito/extract_otp_secret_keys@$(git ls-remote git@github.com:scito/extract_otp_secret_keys@support_img_read.git | head -1 | awk '{print $1;}')#egg=extract_otp_secret_keys -pip3.11 install -e git+https://github.com/scito/extract_otp_secret_keys.git@$(git ls-remote git@github.com:scito/extract_otp_secret_keys.git | grep support_img_read | head -1 | awk '{print $1;}')#egg=extract_otp_secret_keys -python -m extract_otp_secret_keys +# pip install -e git+https://github.com/scito/extract_otp_secret_keys@$(git ls-remote git@github.com:scito/extract_otp_secret_keys@support_img_read.git | head -1 | awk '{print $1;}')#egg=extract_otp_secrets +pip3.11 install -e git+https://github.com/scito/extract_otp_secret_keys.git@$(git ls-remote git@github.com:scito/extract_otp_secret_keys.git | grep support_img_read | head -1 | awk '{print $1;}')#egg=extract_otp_secrets +python -m extract_otp_secrets ``` #### Example ``` wget https://raw.githubusercontent.com/scito/extract_otp_secret_keys/master/example_export.txt -python -m extract_otp_secret_keys example_export.txt +python -m extract_otp_secrets example_export.txt ``` ### local pip @@ -304,27 +304,27 @@ pip install -e . ### pipenv -You can you use [Pipenv](https://github.com/pypa/pipenv) for running extract_otp_secret_keys. +You can you use [Pipenv](https://github.com/pypa/pipenv) for running extract_otp_secrets. ``` pipenv --rm pipenv install pipenv shell -python extract_otp_secret_keys.py example_export.txt +python extract_otp_secrets.py example_export.txt ``` ### Visual Studio Code Remote - Containers / VSCode devcontainer -You can you use [VSCode devcontainer](https://code.visualstudio.com/docs/remote/containers-tutorial) for running extract_otp_secret_keys. +You can you use [VSCode devcontainer](https://code.visualstudio.com/docs/remote/containers-tutorial) for running extract_otp_secrets. Requirement: Docker 1. Start VSCode -2. Open extract_otp_secret_keys.code-workspace +2. Open extract_otp_secrets.code-workspace 3. Open VSCode command palette (Ctrl-Shift-P) 4. Type command "Remote-Containers: Reopen in Container" 5. Open integrated bash terminal in VSCode -6. Execute: python extract_otp_secret_keys.py example_export.txt +6. Execute: python extract_otp_secrets.py example_export.txt ### venv @@ -353,36 +353,36 @@ Install [Docker](https://docs.docker.com/get-docker/). Build and run the app within the container: ```bash -docker build . -t extract_otp_secret_keys --pull -docker run --rm -v "$(pwd)":/files:ro extract_otp_secret_keys example_export.txt -docker run --rm -v "$(pwd)":/files:ro extract_otp_secret_keys example_export.png +docker build . -t extract_otp_secrets --pull +docker run --rm -v "$(pwd)":/files:ro extract_otp_secrets example_export.txt +docker run --rm -v "$(pwd)":/files:ro extract_otp_secrets example_export.png ``` -docker run --rm -v "$(pwd)":/files:ro -i extract_otp_secret_keys = < example_export.png -docker run --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro extract_otp_secret_keys -docker run --pull always --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro scit0/extract_otp_secret_keys -docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro extract_otp_secret_keys -docker run --pull always --rm -v "$(pwd)":/files:ro -i scit0/extract_otp_secret_keys +docker run --rm -v "$(pwd)":/files:ro -i extract_otp_secrets = < example_export.png +docker run --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro extract_otp_secrets +docker run --pull always --rm -v "$(pwd)":/files:ro -i --device="/dev/video0:/dev/video0" --env="DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:ro scit0/extract_otp_secrets +docker run --entrypoint /bin/bash -it --rm -v "$(pwd)":/files:ro extract_otp_secrets +docker run --pull always --rm -v "$(pwd)":/files:ro -i scit0/extract_otp_secrets docker login -uscit0 -docker build . -t extract_otp_secret_keys_no_qr_reader -f Dockerfile_no_qr_reader --pull -docker build . -t extract_otp_secret_keys_no_qr_reader -f Dockerfile_no_qr_reader --pull --build-arg RUN_TESTS=false -docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro scit0/extract_otp_secret_keys_no_qr_reader test_extract_otp_secret_keys_pytest.py -k "not qreader" --relaxed -docker run --rm -v "$(pwd)":/files:ro extract_otp_secret_keys_no_qr_reader example_export.txt -docker run --rm -v "$(pwd)":/files:ro -i extract_otp_secret_keys_no_qr_reader - < example_export.txt -docker build . -t extract_otp_secret_keys_no_qr_reader -f Dockerfile_no_qr_reader --pull && docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secret_keys_no_qr_reader test_extract_otp_secret_keys_pytest.py -k "not qreader" -vvv --relaxed -s +docker build . -t extract_otp_secrets_no_qr_reader -f Dockerfile_no_qr_reader --pull +docker build . -t extract_otp_secrets_no_qr_reader -f Dockerfile_no_qr_reader --pull --build-arg RUN_TESTS=false +docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro scit0/extract_otp_secrets_no_qr_reader extract_otp_secrets_test.py -k "not qreader" --relaxed +docker run --rm -v "$(pwd)":/files:ro extract_otp_secrets_no_qr_reader example_export.txt +docker run --rm -v "$(pwd)":/files:ro -i extract_otp_secrets_no_qr_reader - < example_export.txt +docker build . -t extract_otp_secrets_no_qr_reader -f Dockerfile_no_qr_reader --pull && docker run --entrypoint /extract/run_pytest.sh --rm -v "$(pwd)":/files:ro extract_otp_secrets_no_qr_reader extract_otp_secrets_test.py -k "not qreader" -vvv --relaxed -s -docker pull scit0/extract_otp_secret_keys -docker pull scit0/extract_otp_secret_keys_no_qr_reader +docker pull scit0/extract_otp_secrets +docker pull scit0/extract_otp_secrets_no_qr_reader -docker pull ghcr.io/scito/extract_otp_secret_keys -docker pull ghcr.io/scito/extract_otp_secret_keys_no_qr_reader +docker pull ghcr.io/scito/extract_otp_secrets +docker pull ghcr.io/scito/extract_otp_secrets_no_qr_reader ## Tests ### PyTest -There are basic [pytest](https://pytest.org)s, see `test_extract_otp_secret_keys_pytest.py`. +There are basic [pytest](https://pytest.org)s, see `extract_otp_secrets_test.py`. Run tests: @@ -406,7 +406,7 @@ https://docs.pytest.org/en/7.1.x/explanation/pythonpath.html#pytest-vs-python-m- ### unittest -There are basic [unittest](https://docs.python.org/3.10/library/unittest.html)s, see `test_extract_otp_secret_keys_unittest.py`. +There are basic [unittest](https://docs.python.org/3.10/library/unittest.html)s, see `extract_otp_secrets_txt_unit_test.py`. Run tests: @@ -429,7 +429,7 @@ Setup for running the tests in VSCode. ``` pip install -e . -python src/extract_otp_secret_keys.py +python src/extract_otp_secrets.py pip wheel . # --isolated diff --git a/extract_otp_secret_keys.code-workspace b/extract_otp_secret_keys.code-workspace index 3d6220a..b43c67f 100644 --- a/extract_otp_secret_keys.code-workspace +++ b/extract_otp_secret_keys.code-workspace @@ -11,10 +11,10 @@ "version": "0.2.0", "configurations": [ { - "name": "Python: extract_otp_secret_keys.py", + "name": "Python: extract_otp_secrets.py", "type": "python", "request": "launch", - "program": "extract_otp_secret_keys.py", + "program": "extract_otp_secrets.py", "args": [ "example_export.txt" ], diff --git a/pyproject.toml b/pyproject.toml index 622cbe3..20c36d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ requires = [ build-backend = "setuptools.build_meta" [project] -name = "extract_otp_secret_keys" +name = "extract_otp_secrets" # https://pypi.org/classifiers/ classifiers = [ "Development Status :: 5 - Production/Stable", @@ -46,15 +46,15 @@ readme = "README.md" authors = [{name = "scito", email = "info@scito.ch"}] maintainers = [{name = "scito", email = "info@scito.ch"}] requires-python = ">=3.7, <4" -scripts = {extract_otp_secret_keys = "extract_otp_secret_keys:sys_main"} +scripts = {extract_otp_secrets = "extract_otp_secrets:sys_main"} urls = {Project-URL = "https://github.com/scito/extract_otp_secret_keys", Bug-Reports = "https://github.com/scito/extract_otp_secret_keys/issues", Source = "https://github.com/scito/extract_otp_secret_keys" } # [tool.setuptools] # Still in beta, once it is stable move config from setup.cfg to pyproject.toml -# py-modules = ["extract_otp_secret_keys", "protobuf_generated_python.protobuf_generated_python"] +# py-modules = ["extract_otp_secrets", "protobuf_generated_python.protobuf_generated_python"] # [tool.setuptools.dynamic] -# version = {attr = "extract_otp_secret_keys.VERSION"} +# version = {attr = "extract_otp_secrets.VERSION"} [tool.setuptools-git-versioning] enabled = true diff --git a/setup.cfg b/setup.cfg index f5a68a3..e867b90 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [metadata] -name = extract_otp_secret_keys +name = extract_otp_secrets [options] python_requires = >=3.7, <4 -py_modules = extract_otp_secret_keys, protobuf_generated_python.google_auth_pb2 +py_modules = extract_otp_secrets, protobuf_generated_python.google_auth_pb2 package_dir = =src # packages=find: diff --git a/src/extract_otp_secret_keys.py b/src/extract_otp_secrets.py similarity index 98% rename from src/extract_otp_secret_keys.py rename to src/extract_otp_secrets.py index 68096ee..166332d 100644 --- a/src/extract_otp_secret_keys.py +++ b/src/extract_otp_secrets.py @@ -5,7 +5,7 @@ # 2. Read QR codes with QR code reader (e.g. with a second device) # 3. Save the captured QR codes in a text file. Save each QR code on a new line. (The captured QR codes look like "otpauth-migration://offline?data=...") # 4. Call this script with the file as input: -# python extract_otp_secret_keys.py example_export.txt +# python extract_otp_secrets.py example_export.txt # # Requirement: # The protobuf package of Google for proto3 is required for running this script. @@ -41,7 +41,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from __future__ import annotations # for compatibility with Python < 3.11 +from __future__ import annotations # for compatibility with PYTHON < 3.11 import argparse import base64 import csv @@ -124,11 +124,11 @@ def parse_args(sys_args: list[str]) -> Args: if qreader_available: description_text += "\nIf no infiles are provided, the QR codes are interactively captured from the camera." example_text = """examples: -python extract_otp_secret_keys.py -python extract_otp_secret_keys.py example_*.txt -python extract_otp_secret_keys.py - < example_export.txt -python extract_otp_secret_keys.py --csv - example_*.png | tail -n+2 -python extract_otp_secret_keys.py = < example_export.png""" +python extract_otp_secrets.py +python extract_otp_secrets.py example_*.txt +python extract_otp_secrets.py - < example_export.txt +python extract_otp_secrets.py --csv - example_*.png | tail -n+2 +python extract_otp_secrets.py = < example_export.png""" arg_parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=52), description=description_text, diff --git a/tests/test_extract_qrcode_unittest.py b/tests/extract_otp_secrets_img_unit_test.py similarity index 87% rename from tests/test_extract_qrcode_unittest.py rename to tests/extract_otp_secrets_img_unit_test.py index eb19dbc..7bb8664 100644 --- a/tests/test_extract_qrcode_unittest.py +++ b/tests/extract_otp_secrets_img_unit_test.py @@ -1,4 +1,4 @@ -# Unit test for extract_otp_secret_keys.py +# Unit test for extract_otp_secrets.py # Run tests: # python -m unittest @@ -18,17 +18,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from __future__ import annotations # for compatibility with Python < 3.11 +from __future__ import annotations # for compatibility with PYTHON < 3.11 import unittest -import extract_otp_secret_keys +import extract_otp_secrets from utils import Capturing class TestQRImageExtract(unittest.TestCase): def test_img_qr_reader_happy_path(self) -> None: with Capturing() as actual_output: - extract_otp_secret_keys.main(['tests/data/test_googleauth_export.png']) + extract_otp_secrets.main(['tests/data/test_googleauth_export.png']) expected_output =\ ['Name: Test1:test1@example1.com', 'Secret: JBSWY3DPEHPK3PXP', 'Issuer: Test1', 'Type: totp', '', @@ -40,7 +40,7 @@ class TestQRImageExtract(unittest.TestCase): def test_img_qr_reader_no_qr_code_in_image(self) -> None: with Capturing() as actual_output: with self.assertRaises(SystemExit) as context: - extract_otp_secret_keys.main(['tests/data/lena_std.tif']) + extract_otp_secrets.main(['tests/data/lena_std.tif']) expected_output = ['', 'ERROR: Unable to read QR Code from file.', 'input file: tests/data/lena_std.tif'] @@ -50,7 +50,7 @@ class TestQRImageExtract(unittest.TestCase): def test_img_qr_reader_nonexistent_file(self) -> None: with Capturing() as actual_output: with self.assertRaises(SystemExit) as context: - extract_otp_secret_keys.main(['nonexistent.bmp']) + extract_otp_secrets.main(['nonexistent.bmp']) expected_output = ['', 'ERROR: Input file provided is non-existent or not a file.', 'input file: nonexistent.bmp'] @@ -60,7 +60,7 @@ class TestQRImageExtract(unittest.TestCase): def test_img_qr_reader_non_image_file(self) -> None: with Capturing() as actual_output: with self.assertRaises(SystemExit) as context: - extract_otp_secret_keys.main(['tests/data/text_masquerading_as_image.jpeg']) + extract_otp_secrets.main(['tests/data/text_masquerading_as_image.jpeg']) expected_output = [ '', diff --git a/tests/test_extract_otp_secret_keys_pytest.py b/tests/extract_otp_secrets_test.py similarity index 87% rename from tests/test_extract_otp_secret_keys_pytest.py rename to tests/extract_otp_secrets_test.py index 00bc52a..3e11c69 100644 --- a/tests/test_extract_otp_secret_keys_pytest.py +++ b/tests/extract_otp_secrets_test.py @@ -1,4 +1,4 @@ -# pytest for extract_otp_secret_keys.py +# pytest for extract_otp_secrets.py # Run tests: # pytest @@ -18,7 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from __future__ import annotations # for compatibility with Python < 3.11 +from __future__ import annotations # for compatibility with PYTHON < 3.11 import io import os import pathlib @@ -27,18 +27,18 @@ import sys import pytest from pytest_mock import MockerFixture -import extract_otp_secret_keys +import extract_otp_secrets from utils import (file_exits, quick_and_dirty_workaround_encoding_problem, read_binary_file_as_stream, read_csv, read_csv_str, read_file_to_str, read_json, read_json_str, replace_escaped_octal_utf8_bytes_with_str) -qreader_available: bool = extract_otp_secret_keys.qreader_available +qreader_available: bool = extract_otp_secrets.qreader_available def test_extract_stdout(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['example_export.txt']) + extract_otp_secrets.main(['example_export.txt']) # Assert captured = capsys.readouterr() @@ -50,7 +50,7 @@ def test_extract_stdout(capsys: pytest.CaptureFixture[str]) -> None: def test_extract_non_existent_file(capsys: pytest.CaptureFixture[str]) -> None: # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['non_existent_file.txt']) + extract_otp_secrets.main(['non_existent_file.txt']) # Assert captured = capsys.readouterr() @@ -68,7 +68,7 @@ def test_extract_stdin_stdout(capsys: pytest.CaptureFixture[str], monkeypatch: p monkeypatch.setattr('sys.stdin', io.StringIO(read_file_to_str('example_export.txt'))) # Act - extract_otp_secret_keys.main(['-']) + extract_otp_secrets.main(['-']) # Assert captured = capsys.readouterr() @@ -82,7 +82,7 @@ def test_extract_stdin_empty(capsys: pytest.CaptureFixture[str], monkeypatch: py monkeypatch.setattr('sys.stdin', io.StringIO()) # Act - extract_otp_secret_keys.main(['-']) + extract_otp_secrets.main(['-']) # Assert captured = capsys.readouterr() @@ -96,7 +96,7 @@ def test_extract_empty_file_no_qreader(capsys: pytest.CaptureFixture[str]) -> No if qreader_available: # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['tests/data/empty_file.txt']) + extract_otp_secrets.main(['tests/data/empty_file.txt']) # Assert captured = capsys.readouterr() @@ -109,7 +109,7 @@ def test_extract_empty_file_no_qreader(capsys: pytest.CaptureFixture[str]) -> No assert e.type == SystemExit else: # Act - extract_otp_secret_keys.main(['tests/data/empty_file.txt']) + extract_otp_secrets.main(['tests/data/empty_file.txt']) # Assert captured = capsys.readouterr() @@ -124,7 +124,7 @@ def test_extract_stdin_img_empty(capsys: pytest.CaptureFixture[str], monkeypatch monkeypatch.setattr('sys.stdin', io.BytesIO()) # Act - extract_otp_secret_keys.main(['=']) + extract_otp_secrets.main(['=']) # Assert captured = capsys.readouterr() @@ -138,7 +138,7 @@ def test_extract_csv(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path) output_file = str(tmp_path / 'test_example_output.csv') # Act - extract_otp_secret_keys.main(['-q', '-c', output_file, 'example_export.txt']) + extract_otp_secrets.main(['-q', '-c', output_file, 'example_export.txt']) # Assert expected_csv = read_csv('example_output.csv') @@ -154,7 +154,7 @@ def test_extract_csv(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path) def test_extract_csv_stdout(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['-c', '-', 'example_export.txt']) + extract_otp_secrets.main(['-c', '-', 'example_export.txt']) # Assert assert not file_exits('test_example_output.csv') @@ -173,7 +173,7 @@ def test_extract_stdin_and_csv_stdout(capsys: pytest.CaptureFixture[str], monkey monkeypatch.setattr('sys.stdin', io.StringIO(read_file_to_str('example_export.txt'))) # Act - extract_otp_secret_keys.main(['-c', '-', '-']) + extract_otp_secrets.main(['-c', '-', '-']) # Assert assert not file_exits('test_example_output.csv') @@ -193,7 +193,7 @@ def test_keepass_csv(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path) file_name = str(tmp_path / 'test_example_keepass_output.csv') # Act - extract_otp_secret_keys.main(['-q', '-k', file_name, 'example_export.txt']) + extract_otp_secrets.main(['-q', '-k', file_name, 'example_export.txt']) # Assert expected_totp_csv = read_csv('example_keepass_output.totp.csv') @@ -214,7 +214,7 @@ def test_keepass_csv(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path) def test_keepass_csv_stdout(capsys: pytest.CaptureFixture[str]) -> None: '''Two csv files .totp and .htop are generated.''' # Act - extract_otp_secret_keys.main(['-k', '-', 'tests/data/example_export_only_totp.txt']) + extract_otp_secrets.main(['-k', '-', 'tests/data/example_export_only_totp.txt']) # Assert expected_totp_csv = read_csv('example_keepass_output.totp.csv') @@ -232,7 +232,7 @@ def test_keepass_csv_stdout(capsys: pytest.CaptureFixture[str]) -> None: def test_single_keepass_csv(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path) -> None: '''Does not add .totp or .hotp pre-suffix''' # Act - extract_otp_secret_keys.main(['-q', '-k', str(tmp_path / 'test_example_keepass_output.csv'), 'tests/data/example_export_only_totp.txt']) + extract_otp_secrets.main(['-q', '-k', str(tmp_path / 'test_example_keepass_output.csv'), 'tests/data/example_export_only_totp.txt']) # Assert expected_totp_csv = read_csv('example_keepass_output.totp.csv') @@ -253,7 +253,7 @@ def test_extract_json(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path output_file = str(tmp_path / 'test_example_output.json') # Act - extract_otp_secret_keys.main(['-q', '-j', output_file, 'example_export.txt']) + extract_otp_secrets.main(['-q', '-j', output_file, 'example_export.txt']) # Assert expected_json = read_json('example_output.json') @@ -269,7 +269,7 @@ def test_extract_json(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path def test_extract_json_stdout(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['-j', '-', 'example_export.txt']) + extract_otp_secrets.main(['-j', '-', 'example_export.txt']) # Assert expected_json = read_json('example_output.json') @@ -283,7 +283,7 @@ def test_extract_json_stdout(capsys: pytest.CaptureFixture[str]) -> None: def test_extract_not_encoded_plus(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['tests/data/test_plus_problem_export.txt']) + extract_otp_secrets.main(['tests/data/test_plus_problem_export.txt']) # Assert captured = capsys.readouterr() @@ -316,7 +316,7 @@ Type: totp def test_extract_printqr(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['-p', 'example_export.txt']) + extract_otp_secrets.main(['-p', 'example_export.txt']) # Assert captured = capsys.readouterr() @@ -329,7 +329,7 @@ def test_extract_printqr(capsys: pytest.CaptureFixture[str]) -> None: def test_extract_saveqr(capsys: pytest.CaptureFixture[str], tmp_path: pathlib.Path) -> None: # Act - extract_otp_secret_keys.main(['-q', '-s', str(tmp_path), 'example_export.txt']) + extract_otp_secrets.main(['-q', '-s', str(tmp_path), 'example_export.txt']) # Assert captured = capsys.readouterr() @@ -350,7 +350,7 @@ def test_normalize_bytes() -> None: def test_extract_verbose(capsys: pytest.CaptureFixture[str], relaxed: bool) -> None: # Act - extract_otp_secret_keys.main(['-v', 'example_export.txt']) + extract_otp_secrets.main(['-v', 'example_export.txt']) # Assert captured = capsys.readouterr() @@ -372,7 +372,7 @@ def test_extract_verbose(capsys: pytest.CaptureFixture[str], relaxed: bool) -> N def test_extract_debug(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['-vvv', 'example_export.txt']) + extract_otp_secrets.main(['-vvv', 'example_export.txt']) # Assert captured = capsys.readouterr() @@ -387,7 +387,7 @@ def test_extract_debug(capsys: pytest.CaptureFixture[str]) -> None: def test_extract_help(capsys: pytest.CaptureFixture[str]) -> None: with pytest.raises(SystemExit) as e: # Act - extract_otp_secret_keys.main(['-h']) + extract_otp_secrets.main(['-h']) # Assert captured = capsys.readouterr() @@ -403,10 +403,10 @@ def test_extract_no_arguments(capsys: pytest.CaptureFixture[str], mocker: Mocker if qreader_available: # Arrange otps = read_json('example_output.json') - mocker.patch('extract_otp_secret_keys.extract_otps_from_camera', return_value=otps) + mocker.patch('extract_otp_secrets.extract_otps_from_camera', return_value=otps) # Act - extract_otp_secret_keys.main(['-c', '-']) + extract_otp_secrets.main(['-c', '-']) # Assert captured = capsys.readouterr() @@ -419,7 +419,7 @@ def test_extract_no_arguments(capsys: pytest.CaptureFixture[str], mocker: Mocker else: # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main([]) + extract_otp_secrets.main([]) # Assert captured = capsys.readouterr() @@ -435,7 +435,7 @@ def test_extract_no_arguments(capsys: pytest.CaptureFixture[str], mocker: Mocker def test_verbose_and_quiet(capsys: pytest.CaptureFixture[str]) -> None: with pytest.raises(SystemExit) as e: # Act - extract_otp_secret_keys.main(['-v', '-q', 'example_export.txt']) + extract_otp_secrets.main(['-v', '-q', 'example_export.txt']) # Assert captured = capsys.readouterr() @@ -450,7 +450,7 @@ def test_verbose_and_quiet(capsys: pytest.CaptureFixture[str]) -> None: def test_wrong_data(capsys: pytest.CaptureFixture[str]) -> None: with pytest.raises(SystemExit) as e: # Act - extract_otp_secret_keys.main(['tests/data/test_export_wrong_data.txt']) + extract_otp_secrets.main(['tests/data/test_export_wrong_data.txt']) # Assert captured = capsys.readouterr() @@ -469,7 +469,7 @@ data=XXXX def test_wrong_content(capsys: pytest.CaptureFixture[str]) -> None: with pytest.raises(SystemExit) as e: # Act - extract_otp_secret_keys.main(['tests/data/test_export_wrong_content.txt']) + extract_otp_secrets.main(['tests/data/test_export_wrong_content.txt']) # Assert captured = capsys.readouterr() @@ -494,7 +494,7 @@ Probably a wrong file was given def test_wrong_prefix(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['tests/data/test_export_wrong_prefix.txt']) + extract_otp_secrets.main(['tests/data/test_export_wrong_prefix.txt']) # Assert captured = capsys.readouterr() @@ -518,15 +518,15 @@ Type: totp def test_add_pre_suffix(capsys: pytest.CaptureFixture[str]) -> None: - assert extract_otp_secret_keys.add_pre_suffix("name.csv", "totp") == "name.totp.csv" - assert extract_otp_secret_keys.add_pre_suffix("name.csv", "") == "name..csv" - assert extract_otp_secret_keys.add_pre_suffix("name", "totp") == "name.totp" + assert extract_otp_secrets.add_pre_suffix("name.csv", "totp") == "name.totp.csv" + assert extract_otp_secrets.add_pre_suffix("name.csv", "") == "name..csv" + assert extract_otp_secrets.add_pre_suffix("name", "totp") == "name.totp" @pytest.mark.qreader def test_img_qr_reader_from_file_happy_path(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main(['tests/data/test_googleauth_export.png']) + extract_otp_secrets.main(['tests/data/test_googleauth_export.png']) # Assert captured = capsys.readouterr() @@ -538,7 +538,7 @@ def test_img_qr_reader_from_file_happy_path(capsys: pytest.CaptureFixture[str]) @pytest.mark.qreader def test_extract_multiple_files_and_mixed(capsys: pytest.CaptureFixture[str]) -> None: # Act - extract_otp_secret_keys.main([ + extract_otp_secrets.main([ 'example_export.txt', 'tests/data/test_googleauth_export.png', 'example_export.txt', @@ -558,7 +558,7 @@ def test_img_qr_reader_from_stdin(capsys: pytest.CaptureFixture[str], monkeypatc monkeypatch.setattr('sys.stdin', read_binary_file_as_stream('tests/data/test_googleauth_export.png')) # Act - extract_otp_secret_keys.main(['=']) + extract_otp_secrets.main(['=']) # Assert captured = capsys.readouterr() @@ -592,7 +592,7 @@ def test_img_qr_reader_from_stdin_wrong_symbol(capsys: pytest.CaptureFixture[str # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['-']) + extract_otp_secrets.main(['-']) # Assert captured = capsys.readouterr() @@ -612,7 +612,7 @@ def test_extract_stdin_stdout_wrong_symbol(capsys: pytest.CaptureFixture[str], m # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['=']) + extract_otp_secrets.main(['=']) # Assert captured = capsys.readouterr() @@ -629,7 +629,7 @@ def test_extract_stdin_stdout_wrong_symbol(capsys: pytest.CaptureFixture[str], m def test_img_qr_reader_no_qr_code_in_image(capsys: pytest.CaptureFixture[str]) -> None: # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['tests/data/lena_std.tif']) + extract_otp_secrets.main(['tests/data/lena_std.tif']) # Assert captured = capsys.readouterr() @@ -646,7 +646,7 @@ def test_img_qr_reader_no_qr_code_in_image(capsys: pytest.CaptureFixture[str]) - def test_img_qr_reader_nonexistent_file(capsys: pytest.CaptureFixture[str]) -> None: # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['nonexistent.bmp']) + extract_otp_secrets.main(['nonexistent.bmp']) # Assert captured = capsys.readouterr() @@ -662,7 +662,7 @@ def test_img_qr_reader_nonexistent_file(capsys: pytest.CaptureFixture[str]) -> N def test_non_image_file(capsys: pytest.CaptureFixture[str]) -> None: # Act with pytest.raises(SystemExit) as e: - extract_otp_secret_keys.main(['tests/data/text_masquerading_as_image.jpeg']) + extract_otp_secrets.main(['tests/data/text_masquerading_as_image.jpeg']) # Assert captured = capsys.readouterr() diff --git a/tests/test_extract_otp_secret_keys_unittest.py b/tests/extract_otp_secrets_txt_unit_test.py similarity index 87% rename from tests/test_extract_otp_secret_keys_unittest.py rename to tests/extract_otp_secrets_txt_unit_test.py index 6e29a73..9060ad3 100644 --- a/tests/test_extract_otp_secret_keys_unittest.py +++ b/tests/extract_otp_secrets_txt_unit_test.py @@ -1,4 +1,4 @@ -# Unit test for extract_otp_secret_keys.py +# Unit test for extract_otp_secrets.py # Run tests: # python -m unittest @@ -18,14 +18,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from __future__ import annotations # for compatibility with Python < 3.11 +from __future__ import annotations # for compatibility with PYTHON < 3.11 import io import os import sys import unittest from contextlib import redirect_stdout -import extract_otp_secret_keys +import extract_otp_secrets from utils import (Capturing, read_csv, read_file_to_str, read_json, remove_dir_with_files, remove_file) @@ -33,7 +33,7 @@ from utils import (Capturing, read_csv, read_file_to_str, read_json, class TestExtract(unittest.TestCase): def test_extract_csv(self) -> None: - extract_otp_secret_keys.main(['-q', '-c', 'test_example_output.csv', 'example_export.txt']) + extract_otp_secrets.main(['-q', '-c', 'test_example_output.csv', 'example_export.txt']) expected_csv = read_csv('example_output.csv') actual_csv = read_csv('test_example_output.csv') @@ -41,7 +41,7 @@ class TestExtract(unittest.TestCase): self.assertEqual(actual_csv, expected_csv) def test_extract_json(self) -> None: - extract_otp_secret_keys.main(['-q', '-j', 'test_example_output.json', 'example_export.txt']) + extract_otp_secrets.main(['-q', '-j', 'test_example_output.json', 'example_export.txt']) expected_json = read_json('example_output.json') actual_json = read_json('test_example_output.json') @@ -50,7 +50,7 @@ class TestExtract(unittest.TestCase): def test_extract_stdout_1(self) -> None: with Capturing() as output: - extract_otp_secret_keys.main(['example_export.txt']) + extract_otp_secrets.main(['example_export.txt']) expected_output = [ 'Name: pi@raspberrypi', @@ -87,7 +87,7 @@ class TestExtract(unittest.TestCase): def test_extract_stdout_2(self) -> None: out = io.StringIO() with redirect_stdout(out): - extract_otp_secret_keys.main(['example_export.txt']) + extract_otp_secrets.main(['example_export.txt']) actual_output = out.getvalue() expected_output = '''Name: pi@raspberrypi @@ -123,7 +123,7 @@ Type: totp def test_extract_not_encoded_plus(self) -> None: out = io.StringIO() with redirect_stdout(out): - extract_otp_secret_keys.main(['tests/data/test_plus_problem_export.txt']) + extract_otp_secrets.main(['tests/data/test_plus_problem_export.txt']) actual_output = out.getvalue() expected_output = '''Name: SerenityLabs:test1@serenitylabs.co.uk @@ -152,7 +152,7 @@ Type: totp def test_extract_printqr(self) -> None: out = io.StringIO() with redirect_stdout(out): - extract_otp_secret_keys.main(['-p', 'example_export.txt']) + extract_otp_secrets.main(['-p', 'example_export.txt']) actual_output = out.getvalue() expected_output = read_file_to_str('tests/data/printqr_output.txt') @@ -160,7 +160,7 @@ Type: totp self.assertEqual(actual_output, expected_output) def test_extract_saveqr(self) -> None: - extract_otp_secret_keys.main(['-q', '-s', 'testout/qr/', 'example_export.txt']) + extract_otp_secrets.main(['-q', '-s', 'testout/qr/', 'example_export.txt']) self.assertTrue(os.path.isfile('testout/qr/1-piraspberrypi-raspberrypi.png')) self.assertTrue(os.path.isfile('testout/qr/2-piraspberrypi.png')) @@ -171,7 +171,7 @@ Type: totp if sys.implementation.name == 'pypy': self.skipTest("Encoding problems in verbose mode in pypy.") out = io.StringIO() with redirect_stdout(out): - extract_otp_secret_keys.main(['-v', 'example_export.txt']) + extract_otp_secrets.main(['-v', 'example_export.txt']) actual_output = out.getvalue() expected_output = read_file_to_str('tests/data/print_verbose_output.txt') @@ -181,7 +181,7 @@ Type: totp def test_extract_debug(self) -> None: out = io.StringIO() with redirect_stdout(out): - extract_otp_secret_keys.main(['-vvv', 'example_export.txt']) + extract_otp_secrets.main(['-vvv', 'example_export.txt']) actual_output = out.getvalue() expected_stdout = read_file_to_str('tests/data/print_verbose_output.txt') @@ -193,7 +193,7 @@ Type: totp out = io.StringIO() with redirect_stdout(out): try: - extract_otp_secret_keys.main(['-h']) + extract_otp_secrets.main(['-h']) self.fail("Must abort") except SystemExit as e: self.assertEqual(e.code, 0) @@ -207,7 +207,7 @@ Type: totp out = io.StringIO() with redirect_stdout(out): with self.assertRaises(SystemExit) as context: - extract_otp_secret_keys.main(['-h']) + extract_otp_secrets.main(['-h']) actual_output = out.getvalue() @@ -218,7 +218,7 @@ Type: totp def test_extract_help_3(self) -> None: with Capturing() as actual_output: with self.assertRaises(SystemExit) as context: - extract_otp_secret_keys.main(['-h']) + extract_otp_secrets.main(['-h']) self.assertGreater(len(actual_output), 0) self.assertTrue("-h, --help" in "\n".join(actual_output) and "--verbose, -v" in "\n".join(actual_output)) diff --git a/tests/utils.py b/tests/utils.py index 9504904..26390e1 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from __future__ import annotations # for compatibility with Python < 3.11 +from __future__ import annotations # for compatibility with PYTHON < 3.11 import csv import glob import io diff --git a/upgrade_deps.sh b/upgrade_deps.sh index 4615c84..7df198b 100755 --- a/upgrade_deps.sh +++ b/upgrade_deps.sh @@ -256,30 +256,30 @@ cmd="$PIP install -e ." if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="extract_otp_secret_keys example_export.txt" +cmd="extract_otp_secrets example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="extract_otp_secret_keys - < example_export.txt" +cmd="extract_otp_secrets - < example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" # Test -cmd="$PYTHON src/extract_otp_secret_keys.py example_export.txt" +cmd="$PYTHON src/extract_otp_secrets.py example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="$PYTHON src/extract_otp_secret_keys.py - < example_export.txt" +cmd="$PYTHON src/extract_otp_secrets.py - < example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" COVERAGE_OUT="tests/reports/pytest-coverage.txt" -cmd="mkdir -p tests/reports; pytest --cov=test_extract_otp_secret_keys_pytest --junitxml=tests/reports/pytest.xml --cov-report html:tests/reports/html --cov-report=term-missing tests/ | tee $COVERAGE_OUT" +cmd="mkdir -p tests/reports; pytest --cov=extract_otp_secrets_test --junitxml=tests/reports/pytest.xml --cov-report html:tests/reports/html --cov-report=term-missing tests/ | tee $COVERAGE_OUT" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="$PIPENV run pytest --cov=test_extract_otp_secret_keys_pytest tests/" +cmd="$PIPENV run pytest --cov=extract_otp_secrets_test tests/" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" @@ -292,35 +292,35 @@ TOTAL_COVERAGE=$(cat $COVERAGE_OUT | grep 'TOTAL' | perl -ne 'print "$&" if /\b( # Build docker -cmd="docker build . -t extract_otp_secret_keys_no_qr_reader -f Dockerfile_no_qr_reader --pull" +cmd="docker build . -t extract_otp_secrets_no_qr_reader -f Dockerfile_no_qr_reader --pull" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker run --rm -v \"$(pwd)\":/files:ro extract_otp_secret_keys_no_qr_reader example_export.txt" +cmd="docker run --rm -v \"$(pwd)\":/files:ro extract_otp_secrets_no_qr_reader example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker run --rm -i -v \"$(pwd)\":/files:ro extract_otp_secret_keys_no_qr_reader - < example_export.txt" +cmd="docker run --rm -i -v \"$(pwd)\":/files:ro extract_otp_secrets_no_qr_reader - < example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker run --entrypoint /extract/run_pytest.sh --rm -v \"$(pwd)\":/files:ro extract_otp_secret_keys_no_qr_reader tests/test_extract_otp_secret_keys_pytest.py -k 'not qreader' -vvv --relaxed" +cmd="docker run --entrypoint /extract/run_pytest.sh --rm -v \"$(pwd)\":/files:ro extract_otp_secrets_no_qr_reader tests/extract_otp_secrets_test.py -k 'not qreader' -vvv --relaxed" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker build . -t extract_otp_secret_keys --pull" +cmd="docker build . -t extract_otp_secrets --pull" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker run --rm -v \"$(pwd)\":/files:ro extract_otp_secret_keys example_export.txt" +cmd="docker run --rm -v \"$(pwd)\":/files:ro extract_otp_secrets example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker run --rm -i -v \"$(pwd)\":/files:ro extract_otp_secret_keys - < example_export.txt" +cmd="docker run --rm -i -v \"$(pwd)\":/files:ro extract_otp_secrets - < example_export.txt" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="docker run --entrypoint /extract/run_pytest.sh --rm -v \"$(pwd)\":/files:ro extract_otp_secret_keys" +cmd="docker run --entrypoint /extract/run_pytest.sh --rm -v \"$(pwd)\":/files:ro extract_otp_secrets" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" @@ -328,7 +328,7 @@ cmd="docker image prune || echo 'No docker image pruning'" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd" -cmd="$PYTHON src/extract_otp_secret_keys.py &" +cmd="$PYTHON src/extract_otp_secrets.py &" if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi eval "$cmd"