commit
fea78e9c83
|
@ -12,7 +12,7 @@ jobs:
|
||||||
- name: Set up Python 3.7
|
- name: Set up Python 3.7
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v1
|
||||||
with:
|
with:
|
||||||
python-version: 3.7
|
python-version: 2.7
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
dist/*
|
dist/*
|
||||||
|
__*
|
||||||
CSR_Generator.egg-info/*
|
CSR_Generator.egg-info/*
|
||||||
*.log
|
*.log
|
||||||
|
*.csr
|
||||||
|
*.key
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
Generate a key, self-signed certificate, and certificate request.
|
Generate a key, self-signed certificate, and certificate request.
|
||||||
|
|
||||||
## Information
|
## 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
|
## Installation / Dependencies
|
||||||
The following modules are required:
|
The following modules are required:
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
# Usage: csrgen -n <hostname> -s <san0> <san1>
|
# Usage: csrgen -n <hostname> -s <san0> <san1>
|
||||||
#
|
#
|
||||||
# If you want to generate multiple CSRs, you can use the -f command to
|
# 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.
|
# repository for examples.
|
||||||
#
|
#
|
||||||
# If you want to predefine some of your CSR attributes, you can use the -u command
|
# 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.
|
# for examples.
|
||||||
#
|
#
|
||||||
# Author: Courtney Cotton <cotton@cottoncourtney.com> 06-25-2014, Updated 8-9-2017
|
# Author: Cotton Beckfield <cotton@cottonbeckfield.com> 06-25-2014, Updated 01-20-2020
|
||||||
# Author: Ben Mz <bmz@prohacktive.io> Updated 06-15-2018
|
# Author: Ben Mz <bmz@prohacktive.io> Updated 06-15-2018
|
||||||
|
|
||||||
# Libraries/Modules
|
# Libraries/Modules
|
||||||
|
@ -295,6 +295,7 @@ class Authority(Certificate):
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
print(argv)
|
||||||
# Define default values
|
# Define default values
|
||||||
VERBOSE = False
|
VERBOSE = False
|
||||||
LOG_FILE = "./certGen.log"
|
LOG_FILE = "./certGen.log"
|
Binary file not shown.
|
@ -0,0 +1,39 @@
|
||||||
|
import pytest
|
||||||
|
import csrgen
|
||||||
|
import logging
|
||||||
|
|
||||||
|
def import_logging():
|
||||||
|
logger = logging.getLogger('certgen')
|
||||||
|
hdlr = logging.handlers.TimedRotatingFileHandler("csrgen_test.log", when="midnight", backupCount=3)
|
||||||
|
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
|
||||||
|
hdlr.setFormatter(formatter)
|
||||||
|
logger.addHandler(hdlr)
|
||||||
|
logger.setLevel("WARN")
|
||||||
|
|
||||||
|
return logger
|
||||||
|
|
||||||
|
# Test that if a file is supplied (../samples/sample-file.yaml) the code does #
|
||||||
|
# exit with an error.
|
||||||
|
|
||||||
|
def test_load_nodes():
|
||||||
|
logger = import_logging()
|
||||||
|
cert = csrgen.Certificate(logger, {'verbose': False, 'size': '2048', 'C': 'Te', 'ST': 'PACA', 'L': 'Gap', 'O': 'ProHacktive SAS', 'OU': 'prohacktive.io'})
|
||||||
|
result = cert.loadNodes("samples/sample-file.yaml")
|
||||||
|
|
||||||
|
def test_load_defaults():
|
||||||
|
logger = import_logging()
|
||||||
|
cert = csrgen.Certificate(logger, {'verbose': False, 'size': '2048'})
|
||||||
|
result = cert.loadDefaults("samples/csr-sample-unattended.yaml")
|
||||||
|
|
||||||
|
def test_generate_csr():
|
||||||
|
logger = import_logging()
|
||||||
|
cert = csrgen.Certificate(logger, {'verbose': False, 'size': '2048', 'hostname': 'test-csr.edu', 'sans': 'test-csr-sans.edu',
|
||||||
|
'C': 'Te', 'ST': 'PACA', 'L': 'Gap', 'O': 'ProHacktive SAS', 'OU': 'prohacktive.io'})
|
||||||
|
result = cert.generateCSR()
|
||||||
|
|
||||||
|
# Test that if a file is supplied and a ../samples/csr-sample-unattended.yaml is supplied
|
||||||
|
# that the code does not exit.
|
||||||
|
|
||||||
|
# Test that if someone supplies -n the code does not exit.
|
||||||
|
|
||||||
|
# Test that if someone supplies a -n and a -s that the code does not exit.
|
Loading…
Reference in New Issue