Skip to content

Commit

Permalink
Test making mocked HTTPS request after a real request
Browse files Browse the repository at this point in the history
This fails like so:

>     async def read(self) -> _T:
>         if not self._buffer and not self._eof:
>             assert not self._waiter
>             self._waiter = self._loop.create_future()
>             try:
> >               await self._waiter
> E               aiohttp.client_exceptions.ClientOSError: [Errno 1] [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2580)
>
> .devenv/state/venv/lib/python3.11/site-packages/aiohttp/streams.py:622: ClientOSError
  • Loading branch information
ento authored and mindflayer committed Jan 16, 2024
1 parent 0307301 commit 01b717d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/tests38/test_http_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import json
from unittest import IsolatedAsyncioTestCase

import pytest

from mocket.async_mocket import async_mocketize
from mocket.mocket import Mocket
from mocket.mocket import Mocket, Mocketizer
from mocket.mockhttp import Entry
from mocket.plugins.httpretty import HTTPretty, async_httprettified

Expand Down Expand Up @@ -101,3 +103,16 @@ async def test_httprettish_session(self):
async with session.get(self.target_url) as get_response:
assert get_response.status == 200
assert await get_response.text() == '{"origin": "127.0.0.1"}'

@pytest.mark.skipif('os.getenv("SKIP_TRUE_HTTP", False)')
async def test_mocked_https_request_after_unmocked_https_request(self):
async with aiohttp.ClientSession(timeout=self.timeout) as session:
response = await session.get(self.target_url + "real", ssl=False)
assert response.status == 200

async with Mocketizer(None):
Entry.single_register(Entry.GET, self.target_url + "mocked", status=404)
async with aiohttp.ClientSession(timeout=self.timeout) as session:
response = await session.get(self.target_url + "mocked", ssl=False)
assert response.status == 404
self.assertEqual(len(Mocket.request_list()), 1)

0 comments on commit 01b717d

Please sign in to comment.