diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 32087d2..aac6e63 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,29 +1,31 @@ # This workflows will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -name: Upload Python Package +name: Build and Run Unit Test on: - release: - types: [created] + push: jobs: deploy: - - runs-on: capless/capless-docker:2 + runs-on: ubuntu-20.04 + container: + image: capless/capless-docker:2 steps: - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' + - name: Poetry Install + run: | + poetry update + poetry install --no-dev - name: Run tests env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} COGNITO_CLIENT_SECRET: ${{ secrets.COGNITO_CLIENT_SECRET }} - COGNITO_APP_WITH_SECRET_ID: ${{ secrets.COGNITO_APP_WITH_SECRET_ID }} + COGNITO_APP_ID: ${{ secrets.COGNITO_APP_ID }} COGNITO_USER_POOL_ID: ${{ secrets.COGNITO_USER_POOL_ID }} COGNITO_TEST_USERNAME: ${{ secrets.COGNITO_TEST_USERNAME }} COGNITO_TEST_PASSWORD: ${{ secrets.COGNITO_TEST_PASSWORD }} - run: | - poetry python -m unittests + run: poetry run python -m unittest diff --git a/.gitignore b/.gitignore index fd2f365..acc5fb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +poetry.lock # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..81fbe70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM capless/capless-docker:2 +COPY . /code +RUN poetry install diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..5611c8c --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,18 @@ +version: '3.7' + +services: + web: + restart: always + build: + dockerfile: Dockerfile + context: . + expose: + - "8019" + ports: + - 8019:8888 + volumes: + - ./warrant-lite/:/code/warrant-lite + - ~/.aws/:/root/.aws + env_file: .env + working_dir: /code/ + command: poetry run jupyter notebook --port=8888 --ip=0.0.0.0 --allow-root diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..4dc4319 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,206 @@ +[[package]] +category = "main" +description = "The AWS SDK for Python" +name = "boto3" +optional = false +python-versions = "*" +version = "1.9.152" + +[package.dependencies] +botocore = ">=1.12.152,<1.13.0" +jmespath = ">=0.7.1,<1.0.0" +s3transfer = ">=0.2.0,<0.3.0" + +[[package]] +category = "main" +description = "Low-level, data-driven core of boto 3." +name = "botocore" +optional = false +python-versions = "*" +version = "1.12.152" + +[package.dependencies] +docutils = ">=0.10" +jmespath = ">=0.7.1,<1.0.0" + +[package.dependencies.python-dateutil] +python = ">=2.7" +version = ">=2.1,<3.0.0" + +[package.dependencies.urllib3] +python = ">=3.4" +version = ">=1.20,<1.25" + +[[package]] +category = "main" +description = "Python package for providing Mozilla's CA Bundle." +name = "certifi" +optional = false +python-versions = "*" +version = "2019.3.9" + +[[package]] +category = "main" +description = "Universal encoding detector for Python 2 and 3" +name = "chardet" +optional = false +python-versions = "*" +version = "3.0.4" + +[[package]] +category = "main" +description = "Docutils -- Python Documentation Utilities" +name = "docutils" +optional = false +python-versions = "*" +version = "0.14" + +[[package]] +category = "main" +description = "ECDSA cryptographic signature library (pure python)" +name = "ecdsa" +optional = false +python-versions = "*" +version = "0.13.2" + +[[package]] +category = "main" +description = "Easy access of environment variables from Python with support for strings, booleans, list, tuples, and dicts." +name = "envs" +optional = false +python-versions = "*" +version = "1.3" + +[[package]] +category = "main" +description = "Clean single-source support for Python 3 and 2" +name = "future" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +version = "0.17.1" + +[[package]] +category = "main" +description = "Internationalized Domain Names in Applications (IDNA)" +name = "idna" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "2.8" + +[[package]] +category = "main" +description = "JSON Matching Expressions" +name = "jmespath" +optional = false +python-versions = "*" +version = "0.9.4" + +[[package]] +category = "main" +description = "ASN.1 types and codecs" +name = "pyasn1" +optional = false +python-versions = "*" +version = "0.4.5" + +[[package]] +category = "main" +description = "Extensions to the standard Python datetime module" +marker = "python_version >= \"2.7\"" +name = "python-dateutil" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +version = "2.8.0" + +[package.dependencies] +six = ">=1.5" + +[[package]] +category = "main" +description = "JOSE implementation in Python" +name = "python-jose" +optional = false +python-versions = "*" +version = "3.0.1" + +[package.dependencies] +ecdsa = "<1.0" +future = "<1.0" +rsa = "*" +six = "<2.0" + +[[package]] +category = "main" +description = "Python HTTP for Humans." +name = "requests" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +version = "2.22.0" + +[package.dependencies] +certifi = ">=2017.4.17" +chardet = ">=3.0.2,<3.1.0" +idna = ">=2.5,<2.9" +urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26" + +[[package]] +category = "main" +description = "Pure-Python RSA implementation" +name = "rsa" +optional = false +python-versions = "*" +version = "4.0" + +[package.dependencies] +pyasn1 = ">=0.1.3" + +[[package]] +category = "main" +description = "An Amazon S3 Transfer Manager" +name = "s3transfer" +optional = false +python-versions = "*" +version = "0.2.0" + +[package.dependencies] +botocore = ">=1.12.36,<2.0.0" + +[[package]] +category = "main" +description = "Python 2 and 3 compatibility utilities" +name = "six" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*" +version = "1.12.0" + +[[package]] +category = "main" +description = "HTTP library with thread-safe connection pooling, file post, and more." +name = "urllib3" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4" +version = "1.24.3" + +[metadata] +content-hash = "6509d733804aaa05ea7696a391af081fb8d46214bb501f66416c993eef7404c2" +python-versions = "^3.6" + +[metadata.hashes] +boto3 = ["ad311139cc3ee4464e5f3b558805e684988e71f591dbed6dd19a28dd6854455f", "bae8f2ab3732a7a51da34816f014c0dc98fc75de0bdb5ab19350b7964fba5763"] +botocore = ["19e54674913a7f697f11d7deb634353ceaf593e5486cab15664ea62a4a341dc9", "79a463b96ed16f6c4b7f387cc086ef3323e88c2d153cea407e2c3981fa9849de"] +certifi = ["59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", "b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae"] +chardet = ["84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", "fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"] +docutils = ["02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6", "51e64ef2ebfb29cae1faa133b3710143496eca21c530f3f71424d77687764274", "7a4bd47eaf6596e1295ecb11361139febe29b084a87bf005bf899f9a42edc3c6"] +ecdsa = ["20c17e527e75acad8f402290e158a6ac178b91b881f941fc6ea305bfdfb9657c", "5c034ffa23413ac923541ceb3ac14ec15a0d2530690413bff58c12b80e56d884"] +envs = ["cb771a231baafe920f2413c4e665c7394f475b5c4f1ef2388fba00e4c67817cc", "ccf5cd85ddb8ed335e39ed8a22e0d23658f5a6d7da430f225e6f750c6f50ae42"] +future = ["67045236dcfd6816dc439556d009594abf643e5eb48992e36beac09c2ca659b8"] +idna = ["c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", "ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"] +jmespath = ["3720a4b1bd659dd2eecad0666459b9788813e032b83e7ba58578e48254e0a0e6", "bde2aef6f44302dfb30320115b17d030798de8c4110e28d5cf6cf91a7a31074c"] +pyasn1 = ["061442c60842f6d11051d4fdae9bc197b64bd41573a12234a753a0cb80b4f30b", "0ee2449bf4c4e535823acc25624c45a8b454f328d59d3f3eeb82d3567100b9bd", "5f9fb05c33e53b9a6ee3b1ed1d292043f83df465852bec876e93b47fd2df7eed", "65201d28e081f690a32401e6253cca4449ccacc8f3988e811fae66bd822910ee", "79b336b073a52fa3c3d8728e78fa56b7d03138ef59f44084de5f39650265b5ff", "8ec20f61483764de281e0b4aba7d12716189700debcfa9e7935780850bf527f3", "9458d0273f95d035de4c0d5e0643f25daba330582cc71bb554fe6969c015042a", "98d97a1833a29ca61cd04a60414def8f02f406d732f9f0bcb49f769faff1b699", "b00d7bfb6603517e189d1ad76967c7e805139f63e43096e5f871d1277f50aea5", "b06c0cfd708b806ea025426aace45551f91ea7f557e0c2d4fbd9a4b346873ce0", "d14d05984581770333731690f5453efd4b82e1e5d824a1d7976b868a2e5c38e8", "da2420fe13a9452d8ae97a0e478adde1dee153b11ba832a95b223a2ba01c10f7", "da6b43a8c9ae93bc80e2739efb38cc776ba74a886e3e9318d65fe81a8b8a2c6e"] +python-dateutil = ["7e6584c74aeed623791615e26efd690f29817a27c73085b78e4bad02493df2fb", "c89805f6f4d64db21ed966fda138f8a5ed7a4fdbc1a8ee329ce1b74e3c74da9e"] +python-jose = ["29701d998fe560e52f17246c3213a882a4a39da7e42c7015bcc1f7823ceaff1c", "ed7387f0f9af2ea0ddc441d83a6eb47a5909bd0c8a72ac3250e75afec2cc1371"] +requests = ["11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", "9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"] +rsa = ["14ba45700ff1ec9eeb206a2ce76b32814958a98e372006c8fb76ba820211be66", "1a836406405730121ae9823e19c6e806c62bbad73f890574fff50efa4122c487"] +s3transfer = ["7b9ad3213bff7d357f888e0fab5101b56fa1a0548ee77d121c3a3dbfbef4cb2e", "f23d5cb7d862b104401d9021fc82e5fa0e0cf57b7660a1331425aab0c691d021"] +six = ["3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"] +urllib3 = ["2393a695cd12afedd0dcb26fe5d50d0cf248e5a66f75dbd89a3d4eb333a61af4", "a637e5fae88995b256e3409dc4d52c2e2e0ba32c42a6365fee8bbd2238de3cfb"] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f34b752 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "warrant-lite" +version = "1.0.4" +description = "Small Python library for process SRP requests for AWS Cognito. This library was initially included in the [Warrant](https://www.github.com/capless/warrant) library. We decided to separate it because not all projects and workfows need all of the helper classes and functions in Warrant." +authors = ["Brian Jinwright"] +license = "Apache License 2.0" + +[tool.poetry.dependencies] +python = "^3.6" +boto3 = "^1.14.56" +envs = "^1.3" +python-jose = "^3.2.0" +requests = "^2.24.0" + +[tool.poetry.dev-dependencies] +jupyter = "^1.0.0" + +[build-system] +requires = ["poetry>=0.12"] +build-backend = "poetry.masonry.api" diff --git a/setup.py b/setup.py deleted file mode 100644 index 79815a8..0000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -from setuptools import setup, find_packages - - -def parse_requirements(filename): - """ load requirements from a pip requirements file """ - lineiter = (line.strip() for line in open(filename)) - return [line for line in lineiter if line and not line.startswith("#")] - - -version = '1.0.3' - -README="""Small Python library for process SRP requests for AWS Cognito. This library was initially included in the [Warrant](https://www.github.com/capless/warrant) library. We decided to separate it because not all projects and workfows need all of the helper classes and functions in Warrant.""" - -setup( - name='warrant-lite', - version=version, - description=README, - long_description=README, - classifiers=[ - "Programming Language :: Python :: 3.6", - "Topic :: Software Development :: Libraries :: Python Modules", - "Environment :: Web Environment", - ], - keywords='aws,cognito,srp,capless', - author='Capless.io', - author_email='opensource@capless.io', - maintainer='Brian Jinwright', - packages=find_packages(), - url='https://github.com/capless/warrant-lite', - license='Apache License 2.0', - install_requires=parse_requirements('requirements.txt'), - include_package_data=True, - zip_safe=True, - -) diff --git a/warrant_lite/tests.py b/warrant_lite/tests.py index 7a5b9b9..1ff4461 100644 --- a/warrant_lite/tests.py +++ b/warrant_lite/tests.py @@ -10,7 +10,7 @@ class WarrantLiteTestCase(unittest.TestCase): def setUp(self): if env('USE_CLIENT_SECRET') == 'True': self.client_secret = env('COGNITO_CLIENT_SECRET') - self.app_id = env('COGNITO_APP_WITH_SECRET_ID') + self.app_id = env('COGNITO_APP_ID') else: self.app_id = env('COGNITO_APP_ID') self.client_secret = None