diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49781ed..cc6da71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,9 +119,6 @@ jobs: - "3.9" - "3.10" - "3.11" - include: - - os: ubuntu-20.04 - python-version: "3.6" steps: - uses: actions/checkout@v3 - id: setup-python @@ -215,9 +212,6 @@ jobs: - "3.9" - "3.10" - "3.11" - include: - - os: ubuntu-20.04 - python-version: "3.6" steps: - uses: actions/checkout@v3 - id: setup-python @@ -268,9 +262,6 @@ jobs: - "3.9" - "3.10" - "3.11" - include: - - os: ubuntu-20.04 - python-version: "3.6" steps: - uses: actions/checkout@v3 - id: setup-python diff --git a/requirements.txt b/requirements.txt index f073e44..8b75fe9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ # Note: Add any additional requirements to setup.py's install_requires field --editable . -docker-compose wheel diff --git a/setup.py b/setup.py index 0dcea36..c208059 100644 --- a/setup.py +++ b/setup.py @@ -75,7 +75,6 @@ def get_version(version_file): # that you indicate whether you support Python 2, Python 3 or both. "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -83,7 +82,7 @@ def get_version(version_file): "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", ], - python_requires=">=3.6", + python_requires=">=3.7", # What does your project relate to? keywords="celery certificate-transparency cisa-directives", packages=find_packages(where="src"), @@ -96,11 +95,9 @@ def get_version(version_file): "defusedxml", "dnspython", "docopt", - # MongoEngine 0.27.0 introduces a breaking change to the mongomock - # connection method. See #50 for more details. - "mongoengine >= 0.16.3,<0.27.0", + "mongoengine >= 0.27.0", "python-dateutil >= 2.7.5", - "PyYAML >=4.2b1", + "PyYAML >= 6.0.0", "redis >= 3.2.0", "requests <2.21,>=2.6.1", "schedule >= 0.4.2", diff --git a/src/admiral/_version.py b/src/admiral/_version.py index 4208ce3..39b2a5c 100644 --- a/src/admiral/_version.py +++ b/src/admiral/_version.py @@ -1,2 +1,2 @@ """This file defines the version of this module.""" -__version__ = "1.3.3" +__version__ = "1.4.0" diff --git a/src/admiral/util/config.py b/src/admiral/util/config.py index 65d412c..2ea3cc4 100644 --- a/src/admiral/util/config.py +++ b/src/admiral/util/config.py @@ -2,6 +2,7 @@ # Third-Party Libraries from mongoengine import connect +import pymongo import yaml @@ -13,10 +14,10 @@ def load_config(filename="/run/secrets/config.yml"): return config -def connect_from_config(config=None): +def connect_from_config(config=None, client=pymongo.MongoClient): """Create connections from a confguration.""" if not config: config = load_config() connections = config["connections"] for alias in connections.keys(): - connect(host=connections[alias]["uri"], alias=alias) + connect(host=connections[alias]["uri"], mongo_client_class=client, alias=alias) diff --git a/tests/cert_model_test.py b/tests/cert_model_test.py index 2af9ebd..8037d41 100644 --- a/tests/cert_model_test.py +++ b/tests/cert_model_test.py @@ -7,6 +7,8 @@ # Third-Party Libraries import dateutil.tz as tz import mongoengine +from mongoengine import connect +from mongomock import MongoClient import pytest # cisagov Libraries @@ -48,11 +50,7 @@ @pytest.fixture(scope="class", autouse=True) def connection(): """Create connections for tests to use.""" - # Third-Party Libraries - from mongoengine import connect - - # TODO: Update this connection method. See #50 for more details. - connect(host="mongomock://localhost", alias="default") + connect(host="mongodb://localhost", mongo_client_class=MongoClient, alias="default") class TestCerts: @@ -68,8 +66,8 @@ def test_empty_creation(self): def test_subjects(self): """Validate that subjects and trimmed_subjects are calulcated correctly.""" cert = Cert() - cert.subjects = ["cisa.gov", "cyber.dhs.gov"] - assert set(cert.trimmed_subjects) == {"cisa.gov", "dhs.gov"} + cert.subjects = ["cisa.gov", "cyber.dhs.gov", "cisa.dhs.fed.us"] + assert set(cert.trimmed_subjects) == {"cisa.gov", "dhs.gov", "dhs.fed.us"} def test_simple_creation(self): """Create a new user, and save it.""" diff --git a/tests/data/valid_config.yml b/tests/data/valid_config.yml index 45769dd..d747d8e 100644 --- a/tests/data/valid_config.yml +++ b/tests/data/valid_config.yml @@ -1,6 +1,6 @@ --- connections: local: - uri: mongomock://local-user:example@mongo:27017/local + uri: mongodb://local-user:example@mongo:27017/local production: - uri: mongomock://production-user:example@mongo:27017/production + uri: mongodb://production-user:example@mongo:27017/production diff --git a/tests/test_util.py b/tests/test_util.py index 1365729..458cb1b 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,6 +1,7 @@ """Test the functionality of the util sub-module.""" # Third-Party Libraries +import mongomock import pytest # cisagov Libraries @@ -32,5 +33,4 @@ def test_load_config_valid(): def test_connect_from_config_valid(valid_config): """Test that a valid configuration connects to appropriate connections.""" - # TODO: Update this connection method. See #50 for more details. - util.connect_from_config(valid_config) + util.connect_from_config(valid_config, mongomock.MongoClient)