Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.venv
41 changes: 16 additions & 25 deletions docker-compose-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ services:
restart: on-failure
healthcheck:
test: >
curl --fail -H "authorization: Bearer development" http://fishjam:5002/room || exit 1
curl --fail-with-body -H "Authorization: Bearer 12345" http://fishjam:5002/admin/health
interval: 3s
retries: 2
timeout: 2s
start_period: 30s
environment:
FJ_HOST: "fishjam:5002"
FJ_INTEGRATED_TURN_IP: "${INTEGRATED_TURN_IP:-127.0.0.1}"
FJ_INTEGRATED_TURN_LISTEN_IP: "0.0.0.0"
FJ_INTEGRATED_TURN_PORT_RANGE: "50000-50050"
FJ_INTEGRATED_TCP_TURN_PORT: "49999"
FJ_SERVER_API_TOKEN: "development"
FJ_ADMIN_TOKEN: "12345"
FJ_PORT: 5002
FJ_SECRET_KEY_BASE: "super-secret-key"
FJ_SIP_IP: "127.0.0.1"
Expand All @@ -28,29 +24,24 @@ services:
volumes:
- ./tests/fixtures:/app/fishjam_resources/file_component_sources

test:
container_name: test
image: "cimg/python:${PYTHON_VERSION:-3.10}"
command: sh -c "cd /app && \ poetry config virtualenvs.in-project false && \ poetry install --no-ansi && \ poetry run pytest -s"
environment:
DOCKER_TEST: "TRUE"
ports:
- "5000:5000"
volumes:
- .:/app
fishjam-prep:
image: curlimages/curl:8.12.1
command: >
curl --fail-with-body -H "Authorization: Bearer 12345" -XPOST http://fishjam:5002/admin/user --json '{"id": "testuser", "token": "development"}'
depends_on:
fishjam:
condition: service_healthy

examples:
container_name: examples
image: "cimg/python:${PYTHON_VERSION:-3.10}"
command: sh -c "cd /app && \ poetry config virtualenvs.in-project false && \ poetry cache clear pypi --all && \ poetry install --no-ansi && \ poetry run examples"
test:
container_name: test
build:
context: .
dockerfile: tests/Dockerfile
args:
PYTHON_VERSION: ${PYTHON_VERSION:-3.10}
command: poetry run pytest
environment:
DOCKER_TEST: "TRUE"
CI_LIMIT: "10"
volumes:
- .:/app
depends_on:
fishjam:
condition: service_healthy
fishjam-prep:
condition: service_completed_successfully
Empty file.
155 changes: 155 additions & 0 deletions fishjam/_openapi_client/api/broadcaster/verify_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.broadcaster_verify_token_response import BroadcasterVerifyTokenResponse
from ...models.error import Error
from ...types import Response


def _get_kwargs(
token: str,
) -> Dict[str, Any]:
return {
"method": "get",
"url": "/broadcaster/verify/{token}".format(
token=token,
),
}


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[BroadcasterVerifyTokenResponse, Error]]:
if response.status_code == HTTPStatus.CREATED:
response_201 = BroadcasterVerifyTokenResponse.from_dict(response.json())

return response_201
if response.status_code == HTTPStatus.UNAUTHORIZED:
response_401 = Error.from_dict(response.json())

return response_401
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[BroadcasterVerifyTokenResponse, Error]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
token: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[BroadcasterVerifyTokenResponse, Error]]:
"""Verify token provided by broadcaster

Args:
token (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[BroadcasterVerifyTokenResponse, Error]]
"""

kwargs = _get_kwargs(
token=token,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
token: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[BroadcasterVerifyTokenResponse, Error]]:
"""Verify token provided by broadcaster

Args:
token (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[BroadcasterVerifyTokenResponse, Error]
"""

return sync_detailed(
token=token,
client=client,
).parsed


async def asyncio_detailed(
token: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[BroadcasterVerifyTokenResponse, Error]]:
"""Verify token provided by broadcaster

Args:
token (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[BroadcasterVerifyTokenResponse, Error]]
"""

kwargs = _get_kwargs(
token=token,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
token: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[BroadcasterVerifyTokenResponse, Error]]:
"""Verify token provided by broadcaster

Args:
token (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[BroadcasterVerifyTokenResponse, Error]
"""

return (
await asyncio_detailed(
token=token,
client=client,
)
).parsed
Empty file.
165 changes: 165 additions & 0 deletions fishjam/_openapi_client/api/viewer/generate_token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
from http import HTTPStatus
from typing import Any, Dict, Optional, Union, cast

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...types import Response


def _get_kwargs(
room_id: str,
) -> Dict[str, Any]:
return {
"method": "post",
"url": "/room/{room_id}/viewer".format(
room_id=room_id,
),
}


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, str]]:
if response.status_code == HTTPStatus.CREATED:
response_201 = cast(str, response.json())
return response_201
if response.status_code == HTTPStatus.BAD_REQUEST:
response_400 = Error.from_dict(response.json())

return response_400
if response.status_code == HTTPStatus.UNAUTHORIZED:
response_401 = Error.from_dict(response.json())

return response_401
if response.status_code == HTTPStatus.NOT_FOUND:
response_404 = Error.from_dict(response.json())

return response_404
if response.status_code == HTTPStatus.SERVICE_UNAVAILABLE:
response_503 = Error.from_dict(response.json())

return response_503
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Error, str]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Error, str]]:
"""Generate token for single viewer

Args:
room_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Error, str]]
"""

kwargs = _get_kwargs(
room_id=room_id,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Error, str]]:
"""Generate token for single viewer

Args:
room_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Error, str]
"""

return sync_detailed(
room_id=room_id,
client=client,
).parsed


async def asyncio_detailed(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Response[Union[Error, str]]:
"""Generate token for single viewer

Args:
room_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Error, str]]
"""

kwargs = _get_kwargs(
room_id=room_id,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
room_id: str,
*,
client: Union[AuthenticatedClient, Client],
) -> Optional[Union[Error, str]]:
"""Generate token for single viewer

Args:
room_id (str):

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Error, str]
"""

return (
await asyncio_detailed(
room_id=room_id,
client=client,
)
).parsed
Loading