From 8193e2cbfc470f5157d3dc7f8a202bfed0ddf808 Mon Sep 17 00:00:00 2001 From: Alex Garrison Date: Wed, 20 Nov 2024 15:47:22 +0000 Subject: [PATCH 1/7] Added option to include endpoint details --- ssllabs/ssllabs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ssllabs/ssllabs.py b/ssllabs/ssllabs.py index 352cdbb..04d0539 100644 --- a/ssllabs/ssllabs.py +++ b/ssllabs/ssllabs.py @@ -39,6 +39,7 @@ async def analyze( publish: bool = False, ignore_mismatch: bool = False, from_cache: bool = False, + include_details: bool = True, max_age: Optional[int] = None, ) -> HostData: """ @@ -48,6 +49,7 @@ async def analyze( :param publish: True if assessment results should be published on the public results boards :param ignore_mismatch: True if assessment shall proceed even when the server certificate doesn't match the hostname :param from_cache: True if cached results should be used instead of new assessments + :param include_details: True if endpoint details should be returned :param max_age: Maximum age cached data might have in hours See also: https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs-v3.md#protocol-usage @@ -74,13 +76,14 @@ async def analyze( fromCache="on" if from_cache else "off", publish="on" if publish else "off", ignoreMismatch="on" if ignore_mismatch else "off", + all="done" if include_details else "off", maxAge=max_age, ) self._semaphore.release() while host_object.status not in ["READY", "ERROR"]: self._logger.debug("Assessment of %s not ready yet.", host) await asyncio.sleep(10) - host_object = await a.get(host=host, all="done") + host_object = await a.get(host=host, all="done" if include_details else "off") return host_object async def info(self) -> InfoData: From 8b605987c72558f37f5044a6788f92a1cabbca80 Mon Sep 17 00:00:00 2001 From: Alex Garrison Date: Mon, 25 Nov 2024 13:47:58 +0000 Subject: [PATCH 2/7] Removed include_details parameter. --- ssllabs/ssllabs.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ssllabs/ssllabs.py b/ssllabs/ssllabs.py index 04d0539..63aedf9 100644 --- a/ssllabs/ssllabs.py +++ b/ssllabs/ssllabs.py @@ -39,7 +39,6 @@ async def analyze( publish: bool = False, ignore_mismatch: bool = False, from_cache: bool = False, - include_details: bool = True, max_age: Optional[int] = None, ) -> HostData: """ @@ -49,7 +48,6 @@ async def analyze( :param publish: True if assessment results should be published on the public results boards :param ignore_mismatch: True if assessment shall proceed even when the server certificate doesn't match the hostname :param from_cache: True if cached results should be used instead of new assessments - :param include_details: True if endpoint details should be returned :param max_age: Maximum age cached data might have in hours See also: https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs-v3.md#protocol-usage @@ -76,14 +74,14 @@ async def analyze( fromCache="on" if from_cache else "off", publish="on" if publish else "off", ignoreMismatch="on" if ignore_mismatch else "off", - all="done" if include_details else "off", + all="done", maxAge=max_age, ) self._semaphore.release() while host_object.status not in ["READY", "ERROR"]: self._logger.debug("Assessment of %s not ready yet.", host) await asyncio.sleep(10) - host_object = await a.get(host=host, all="done" if include_details else "off") + host_object = await a.get(host=host, all="done") return host_object async def info(self) -> InfoData: From b2b8b84322ebd37823723acd2a67ed8fe4c8ad2e Mon Sep 17 00:00:00 2001 From: Alex Garrison Date: Fri, 29 Nov 2024 14:32:44 +0000 Subject: [PATCH 3/7] Updated tests --- tests/test_ssllabs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_ssllabs.py b/tests/test_ssllabs.py index 72fceaf..be46b0d 100644 --- a/tests/test_ssllabs.py +++ b/tests/test_ssllabs.py @@ -44,12 +44,12 @@ async def test_analyze(self, request: pytest.FixtureRequest) -> None: api_data = await ssllabs.analyze(host="devolo.de") assert dataclasses.asdict(api_data) == request.cls.analyze get.assert_called_with( - host="devolo.de", ignoreMismatch="off", publish="off", startNew="on", fromCache="off", maxAge=None + host="devolo.de", ignoreMismatch="off", publish="off", startNew="on", fromCache="off", maxAge=None, all="done" ) api_data = await ssllabs.analyze(host="devolo.de", from_cache=True, max_age=1) assert dataclasses.asdict(api_data) == request.cls.analyze get.assert_called_with( - host="devolo.de", ignoreMismatch="off", publish="off", startNew="off", fromCache="on", maxAge=1 + host="devolo.de", ignoreMismatch="off", publish="off", startNew="off", fromCache="on", maxAge=1, all="done" ) @pytest.mark.asyncio From 02851daf267fcfeb6e2d578245f3c4345d97d0bb Mon Sep 17 00:00:00 2001 From: Guido Schmitz Date: Fri, 29 Nov 2024 08:17:47 +0100 Subject: [PATCH 4/7] Fix tests --- tests/conftest.py | 11 ----------- tests/test_api.py | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 819d8d9..142269b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,14 +16,3 @@ def test_data_fixture(request): with file.open("r") as fh: test_data = json.load(fh) setattr(request.cls, filename, test_data) - - -@pytest.fixture() -def event_loop(): - loop = asyncio.get_event_loop() - yield loop - to_cancel = asyncio.tasks.all_tasks(loop) - for task in to_cancel: - task.cancel() - loop.run_until_complete(asyncio.tasks.gather(*to_cancel, return_exceptions=True)) - loop.close() diff --git a/tests/test_api.py b/tests/test_api.py index dee09d3..8235868 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -30,6 +30,8 @@ async def test_api(self, request, httpx_mock): httpx_mock.add_response(json=request.cls.info) r = await _Api()._call("") # pylint: disable=protected-access assert r.json() == request.cls.info + + httpx_mock.add_response(json=request.cls.info) client = AsyncClient() r = await _Api(client)._call("") # pylint: disable=protected-access await client.aclose() From 64b4f1af1998566ab84b2464517f350a70972f98 Mon Sep 17 00:00:00 2001 From: Guido Schmitz Date: Fri, 29 Nov 2024 08:18:56 +0100 Subject: [PATCH 5/7] Add Python 3.13 to tests --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 0702a47..e2c07ba 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout sources uses: actions/checkout@v4.1.7 From 932c7638afff410c86f94e02bdd2d51d7f181134 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:54:35 +0100 Subject: [PATCH 6/7] Bump actions/checkout from 4.1.7 to 4.2.2 (#64) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4.1.7...v4.2.2) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pythonpackage.yml | 6 +++--- .github/workflows/pythonpublish.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index e2c07ba..b620919 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.2 - name: Set up Python uses: actions/setup-python@v5.1.0 with: @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.2 - name: Set up Python uses: actions/setup-python@v5.1.0 with: @@ -52,7 +52,7 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Checkout sources - uses: actions/checkout@v4.1.7 + uses: actions/checkout@v4.2.2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5.1.0 with: diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index dbe238f..3b811d4 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -8,7 +8,7 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.7 + - uses: actions/checkout@v4.2.2 - name: Set up Python uses: actions/setup-python@v5.1.0 with: From 3dcb846949d2073151140ece3a3e828a8e5f8884 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 09:56:29 +0100 Subject: [PATCH 7/7] Bump actions/setup-python from 5.1.0 to 5.3.0 (#65) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.0 to 5.3.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v5.1.0...v5.3.0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pythonpackage.yml | 6 +++--- .github/workflows/pythonpublish.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index b620919..faf348e 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -11,7 +11,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.3.0 with: python-version: "3.8" - name: Check formatting @@ -24,7 +24,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.3.0 with: python-version: "3.8" - name: Lint with flake8 @@ -54,7 +54,7 @@ jobs: - name: Checkout sources uses: actions/checkout@v4.2.2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.3.0 with: python-version: ${{ matrix.python-version }} allow-prereleases: true diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 3b811d4..30274d9 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v4.2.2 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.3.0 with: python-version: "3.8" - name: Install dependencies