diff --git a/.github/workflows/test_and_publish.yaml b/.github/workflows/test_and_publish.yaml index daa2a73..453ace1 100644 --- a/.github/workflows/test_and_publish.yaml +++ b/.github/workflows/test_and_publish.yaml @@ -18,8 +18,6 @@ jobs: strategy: matrix: include: -# - python-version: 2.7 -# os: ubuntu-20.04 # - python-version: 3.6 # os: ubuntu-20.04 - python-version: 3.7 @@ -38,17 +36,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} != 2.7 - if: ${{ matrix.python-version != '2.7' }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Set up Python 2.7 - if: ${{ matrix.python-version == '2.7' }} - run: | - sudo ln -sf /usr/bin/python2.7 /usr/bin/python - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py - sudo python get-pip.py - name: Install dependencies run: | @@ -93,8 +84,6 @@ jobs: strategy: matrix: include: -# - python-version: 2.7 -# os: ubuntu-20.04 # - python-version: 3.6 # os: ubuntu-20.04 - python-version: 3.7 @@ -112,17 +101,10 @@ jobs: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') steps: - - name: Set up Python ${{ matrix.python-version }} != 2.7 - if: ${{ matrix.python-version != '2.7' }} + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Set up Python 2.7 - if: ${{ matrix.python-version == '2.7' }} - run: | - sudo ln -sf /usr/bin/python2.7 /usr/bin/python - curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py - sudo python get-pip.py - name: Upgrade pip run: python -m pip install --upgrade pip diff --git a/domainconnectzone/sigutil.py b/domainconnectzone/sigutil.py index 82de559..27461b6 100644 --- a/domainconnectzone/sigutil.py +++ b/domainconnectzone/sigutil.py @@ -50,7 +50,7 @@ def get_publickey(domain): pembits = '' try: - records = dns.resolver.query(domain, 'TXT') # Get all text records + records = dns.resolver.resolve(domain, 'TXT') # Get all text records record_strings = [] for record in records: text = record.strings[0].decode('utf-8') diff --git a/requirements-test.txt b/requirements-test.txt index 3e2e187..96a50de 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,20 +1,14 @@ -cryptography>=3.3.2; python_version == '2.7' -cryptography>=39.0.1; python_version > '2.7' and python_version < '3.6' +cryptography>=39.0.1; python_version >= '3.0' and python_version < '3.6' cryptography>=40.0.2; python_version >= '3.6' and python_version < '3.7' cryptography>=42.0.3; python_version >= '3.7' -dnspython>=1.16.0; python_version == '2.7' -dnspython3>=1.15.0; python_version > '2.7' +dnspython>=2.0.0; python_version >= '3.0' ipy>=1.1 -jsonschema>=3.2.0; python_version == '2.7' -jsonschema>=4.0.0; python_version > '2.7' +jsonschema>=4.0.0; python_version >= '3.0' requests>=2.27.1; python_version < '3.7' requests>=2.31.0; python_version >= '3.7' six>=1.16.0 -validators>=0.14.2; python_version == '2.7' -validators>=0.20.0; python_version > '2.7' +validators>=0.20.0; python_version >= '3.0' coverage>=5.5 -pytest>=4.6; python_version == '2.7' -pytest>=7.0; python_version > '2.7' +pytest>=7.0; python_version >= '3.0' mock>=3.0.5; python_version < '3.3' -PyYAML>=5.1,<6.0; python_version == '2.7' -PyYAML>=6.0; python_version > '2.7' +PyYAML>=6.0; python_version >= '3.0' diff --git a/requirements.txt b/requirements.txt index c43a702..23b6709 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,10 @@ -cryptography>=3.3.2; python_version == '2.7' -cryptography>=39.0.1; python_version > '2.7' and python_version < '3.6' +cryptography>=39.0.1; python_version >= '3.0' and python_version < '3.6' cryptography>=40.0.2; python_version >= '3.6' and python_version < '3.7' cryptography>=42.0.3; python_version >= '3.7' -dnspython>=1.16.0; python_version == '2.7' -dnspython3>=1.15.0; python_version > '2.7' +dnspython>=2.0.0; python_version >= '3.0' ipy>=1.1 -jsonschema>=3.2.0; python_version == '2.7' -jsonschema>=4.0.0; python_version > '2.7' +jsonschema>=4.0.0; python_version >= '3.0' requests>=2.27.1; python_version < '3.7' requests>=2.31.0; python_version >= '3.7' six>=1.16.0 -validators>=0.14.2; python_version == '2.7' -validators>=0.20.0; python_version > '2.7' \ No newline at end of file +validators>=0.20.0; python_version >= '3.0' \ No newline at end of file diff --git a/setup.py b/setup.py index d59391d..ebad1d7 100644 --- a/setup.py +++ b/setup.py @@ -64,22 +64,14 @@ def run(self): extras_require={ 'testing': [ 'coverage>=5.5', - 'pytest>=4.6; python_version == "2.7"', - 'pytest>=7.0; python_version > "2.7"', + 'pytest>=7.0; python_version >= "3.0"', 'mock>=3.0.5; python_version < "3.3"', ], 'docs': [ 'phinx>=7.4.7', 'sphinx-rtd-theme>=2.0.0' ], - ':python_version == "2.7"': [ - 'cryptography>=3.3.2', - 'dnspython>=1.16.0', - 'jsonschema>=3.2.0', - 'requests>=2.27.1', - 'validators>=0.14.2', - ], - ':python_version > "2.7" and python_version < "3.6"': [ + ':python_version >= "3.0" and python_version < "3.6"': [ 'cryptography>=39.0.1', 'dnspython3>=1.15.0', 'jsonschema>=4.0.0', @@ -102,7 +94,6 @@ def run(self): ], }, classifiers=[ - "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff --git a/test/test_sigutil.py b/test/test_sigutil.py index 20c500e..2ab0003 100644 --- a/test/test_sigutil.py +++ b/test/test_sigutil.py @@ -88,7 +88,7 @@ def test_exception_handling(self): class TestGetPublicKey(unittest.TestCase): - @patch('dns.resolver.query') + @patch('dns.resolver.resolve') def test_get_publickey(self, mock_query): # Mock DNS TXT records mock_records = MagicMock() @@ -104,7 +104,7 @@ def test_get_publickey(self, mock_query): expected_key = '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqG9w0BAQEFAAOCAQ8AMIIBCgKCAQE\n-----END PUBLIC KEY-----\n' self.assertEqual(get_publickey(domain), expected_key) - @patch('dns.resolver.query') + @patch('dns.resolver.resolve') def test_get_publickey_full_spec(self, mock_query): # Mock DNS TXT records with fully specified algorithm and type mock_records = MagicMock() @@ -122,7 +122,7 @@ def test_get_publickey_full_spec(self, mock_query): expected_key = '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqG9w0BAQEFAAOCAQ8AMIIBCgKCAQE\n-----END PUBLIC KEY-----\n' self.assertEqual(get_publickey(domain), expected_key) - @patch('dns.resolver.query') + @patch('dns.resolver.resolve') def test_get_publickey_with_invalid_data(self, mock_query): # Mock DNS TXT record with invalid data mock_records = MagicMock() @@ -135,7 +135,7 @@ def test_get_publickey_with_invalid_data(self, mock_query): domain = 'example.com' self.assertIsNone(get_publickey(domain)) - @patch('dns.resolver.query') + @patch('dns.resolver.resolve') def test_get_publickey_with_invalid_algorithm(self, mock_query): # Mock DNS TXT record with unsupported algorithm mock_records = MagicMock() @@ -148,7 +148,7 @@ def test_get_publickey_with_invalid_algorithm(self, mock_query): domain = 'example.com' self.assertIsNone(get_publickey(domain)) - @patch('dns.resolver.query') + @patch('dns.resolver.resolve') def test_get_publickey_with_invalid_type(self, mock_query): # Mock DNS TXT record with unsupported type mock_records = MagicMock()