From 98f7bb3b6ef5bf56a2fd58656f0bf20a38f609e0 Mon Sep 17 00:00:00 2001 From: Cotton Date: Mon, 20 Jan 2020 02:25:56 -0800 Subject: [PATCH] Adding pytests --- .github/workflows/pythonapp.yml | 11 +---- .gitignore | 3 ++ README.md | 3 +- csr_tools/csrgen.py => csrgen.py | 7 ++-- csrgen.pyc | Bin 0 -> 12678 bytes csrgen_test.py | 39 ++++++++++++++++++ .../csr-sample-unattended.yaml | 0 sample.yaml => samples/sample-file.yaml | 0 8 files changed, 50 insertions(+), 13 deletions(-) rename csr_tools/csrgen.py => csrgen.py (97%) create mode 100644 csrgen.pyc create mode 100644 csrgen_test.py rename csr-sample.yaml => samples/csr-sample-unattended.yaml (100%) rename sample.yaml => samples/sample-file.yaml (100%) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 5639973..bc97854 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -12,19 +12,12 @@ jobs: - name: Set up Python 3.7 uses: actions/setup-python@v1 with: - python-version: 3.7 + python-version: 2.7 - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - - name: Lint with flake8 - run: | - pip install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | pip install pytest - pytest + pytest csrgen_test.py diff --git a/.gitignore b/.gitignore index fde6770..e05d2f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ dist/* +__* CSR_Generator.egg-info/* *.log +*.csr +*.key diff --git a/README.md b/README.md index 2a5a91b..812b265 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Generate a key, self-signed certificate, and certificate request. ## Information -You'll notice there is only one version of python scripts. This can be used with both python(2.7) and python(3.5). +This script is for Python 2.7. Due to how the input() function has changed between python2 and python3, this +script is not backwards compatible at this time. ## Installation / Dependencies The following modules are required: diff --git a/csr_tools/csrgen.py b/csrgen.py similarity index 97% rename from csr_tools/csrgen.py rename to csrgen.py index c156093..989683a 100755 --- a/csr_tools/csrgen.py +++ b/csrgen.py @@ -8,14 +8,14 @@ # Usage: csrgen -n -s # # If you want to generate multiple CSRs, you can use the -f command to -# feed in a .yaml file via the CLI. See the example sample.yaml in this +# feed in a .yaml file via the CLI. See the example samples/sample-file.yaml in this # repository for examples. # # If you want to predefine some of your CSR attributes, you can use the -u command -# to feed in a .yaml file via the CLI. See the example csr.yaml in this repository +# to feed in a .yaml file via the CLI. See the example samples/csr-sample-unattended.yaml in this repository # for examples. # -# Author: Courtney Cotton 06-25-2014, Updated 8-9-2017 +# Author: Cotton Beckfield 06-25-2014, Updated 01-20-2020 # Author: Ben Mz Updated 06-15-2018 # Libraries/Modules @@ -295,6 +295,7 @@ def initialize(self): def main(argv): + print(argv) # Define default values VERBOSE = False LOG_FILE = "./certGen.log" diff --git a/csrgen.pyc b/csrgen.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1bb239ccceef8834bcda154af5d9cbf7e053285a GIT binary patch literal 12678 zcmcIq&2Jn>cCVfpQk)SfQQx9ITaslDZE+-j+qA5hq9~bJdMNiurbI;aCqlQTV| zt{zEai2-6cUME?=huzBpxdg~*u?UhJf?$E%HkbSXK~C9oZVM!r1X*l;zgOKoL)lIc z$&o$9>Z(_-s$RW%pOyc&vC`g$XMew;l7D&p{Qy7xwgqI%URu0%U0T+Q_H!u zo>$BHv|dolg|t4D)^n;ktXezN@($G+QOhIB@-U{Tynu<}c4 z74z)KT6ZdMgdfYJ${$l+QElc_^f$`Kr&1fc)Duftp)9vnE@A1xZ}G2M&Y>C)qi96E zPTY>Uy;^NS58>~tl~*el;+?3?`cWLL1`Rj%w-Mqp`ZN~BIk4?OsPF|yfNfi{8tgeI zm4fnzlsBrdsV_j69o!d}JCbaTI~|r5>`%6}Jg_C~hrrlaNh-UPzgumLD{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