Skip to content

Commit

Permalink
Merge branch '55-allow-unsecured-connections-for-expir'
Browse files Browse the repository at this point in the history
  • Loading branch information
leonhard-s committed May 10, 2022
2 parents e402895 + 58e8109 commit 270d3be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions auraxium/_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ class RequestClient:
"""The REST request handler for Auraxium."""

def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None,
service_id: str = 's:example', profiling: bool = False
) -> None:
service_id: str = 's:example', profiling: bool = False,
no_ssl_certs: bool = False) -> None:
self.loop = loop or asyncio.get_event_loop()
self.profiling = profiling
self.service_id = service_id
self.session = aiohttp.ClientSession()
self._no_ssl_certs = no_ssl_certs
self._timing_cache: List[float] = []

async def __aenter__(self: _T) -> _T:
Expand Down
7 changes: 6 additions & 1 deletion auraxium/event/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import contextlib
import json
import logging
import ssl
from typing import (Any, Callable, Coroutine, Dict, Iterator, List, Optional, Type, TypeVar, Union,
cast, overload)

Expand Down Expand Up @@ -264,7 +265,11 @@ async def _connection_handler(self) -> None:
"""
_log.info('Connecting to WebSocket endpoint...')
url = f'{_ESS_ENDPOINT}?environment=ps2&service-id={self.service_id}'
async with ws_client.connect(url) as websocket:
if self._no_ssl_certs:
ssl_ctx = ssl.SSLContext()
else:
ssl_ctx = None
async with ws_client.connect(url, ssl=ssl_ctx) as websocket:
self.websocket = websocket
_log.info('Connected to %s?environment=ps2&service-id=XXX',
_ESS_ENDPOINT)
Expand Down
3 changes: 2 additions & 1 deletion tests/event_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ async def asyncSetUp(self) -> None:
"""Reset the event streaming client before every test."""
if self._client is not None:
await self._client.close()
self._client = auraxium.event.EventClient(service_id=SERVICE_ID)
self._client = auraxium.event.EventClient(
service_id=SERVICE_ID, no_ssl_certs=True)

async def asyncTearDown(self) -> None:
"""Close the event streaming client after every test."""
Expand Down

0 comments on commit 270d3be

Please sign in to comment.