Skip to content

Commit

Permalink
Merge pull request #13 from skar404/test_ci/cd
Browse files Browse the repository at this point in the history
update to version 3.1.0
  • Loading branch information
skar404 authored Apr 6, 2024
2 parents 6e1a587 + d72f7dc commit ff76a4f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1,025 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

name: Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [ push, pull_request ]

jobs:
run-tests:
Expand Down
2 changes: 1 addition & 1 deletion aio_clients/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Dict, List, Optional

from aiohttp import ClientTimeout, TraceConfig, ClientResponse
from multidict import CIMultiDictProxy
from multidict import CIMultiDictProxy # type: ignore

from .__version__ import __version__
from .types import MiddlewareStart, MiddlewareEnd
Expand Down
1,015 changes: 0 additions & 1,015 deletions poetry.lock

This file was deleted.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ packages = [

[tool.poetry.dependencies]
python = ">=3.7,<4.0"
aiohttp = ">=3.8.0"
aiohttp = [
{ version = ">=3.8.6,<3.9", python = ">=3.7,<3.8" },
{ version = ">=3.9.3", python = ">=3.8" }
]

[tool.poetry.dev-dependencies]
pytest = "^7.1.3"
Expand Down
31 changes: 28 additions & 3 deletions tests/integrations/test_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from hashlib import sha256

import aiohttp
import pytest
Expand Down Expand Up @@ -269,17 +270,40 @@ async def test_request_query_params():
}


async def get_ssl_fingerprint(url):
"""
Get SSL fingerprint from url
:param url:
:return:
"""

async def fetch(session, url):
async with session.get(url) as response:
await response.text()

conn = aiohttp.TCPConnector(ssl=False)
async with aiohttp.ClientSession(connector=conn) as session:
await fetch(session, url)

ssl_object = next(iter(session._connector._conns.values()))[0][0].transport._ssl_protocol._extra['ssl_object']
cert = ssl_object.getpeercert(binary_form=True)
fingerprint = sha256(cert).hexdigest()
return fingerprint


@pytest.mark.integtest
async def test_request_with_correct_fingerprint():
fingerprint = await get_ssl_fingerprint('https://ulock.org/')
http = Http(
host='https://ulock.org/',
option=Options(
is_json=False,
is_ssl=None,
request_kwargs={
'fingerprint': bytes.fromhex('DAB4EC8A125FF4C539C2D1BFB34B2B68A59003705A1BEB51917D9AF614C6E519')}
request_kwargs={'fingerprint': bytes.fromhex(fingerprint)},
is_close_session=True,
))
await http.get()
assert True


@pytest.mark.integtest
Expand All @@ -289,7 +313,8 @@ async def test_request_with_broken_fingerprint():
option=Options(
is_json=False,
is_ssl=None,
request_kwargs={'fingerprint': bytes.fromhex('0' * 64)}
request_kwargs={'fingerprint': bytes.fromhex('0' * 64)},
is_close_session=True,
))
try:
await http.get()
Expand Down
13 changes: 13 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tox]
requires =
tox>=4
env_list = lint, type, py{37,38,39,310,311,312}

[testenv]
description = run unit tests
deps =
pytest
pytest-asyncio

commands =
pytest .

0 comments on commit ff76a4f

Please sign in to comment.