Skip to content

Commit

Permalink
Add publisher only role (#295)
Browse files Browse the repository at this point in the history
* add publisher-only role

* Bump version: 3.13.1 → 3.14.0
  • Loading branch information
maxkahan authored May 13, 2024
1 parent 9e926fb commit 0852476
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.13.1
current_version = 3.14.0
commit = True
tag = False

Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,9 @@ ENV*
.pytest_cache
html/
.mutmut-cache
_test_scripts/

# Pants workspace files
/.pants.*
/dist/
/.pids
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 3.14.0
- Add publisher-only as a valid Video API client token role

# 3.13.1
- Fix content-type incorrect serialization

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name="vonage",
version="3.13.1",
version="3.14.0",
description="Vonage Server SDK for Python",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion src/vonage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .client import *
from .ncco_builder.ncco import *

__version__ = "3.13.1"
__version__ = "3.14.0"
2 changes: 1 addition & 1 deletion src/vonage/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Video:
auth_type = 'jwt'
archive_mode_values = {'manual', 'always'}
media_mode_values = {'routed', 'relayed'}
token_roles = {'subscriber', 'publisher', 'moderator'}
token_roles = {'subscriber', 'publisher', 'publisheronly', 'moderator'}

def __init__(self, client: Client):
self._client = client
Expand Down
20 changes: 17 additions & 3 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def test_create_session_custom_archive_mode_and_location(client: Client):
fixture_path="video/create_session.json",
)

session_options = {'archive_mode': 'always', 'location': '192.0.1.1', 'media_mode': 'routed'}
session_options = {
'archive_mode': 'always',
'location': '192.0.1.1',
'media_mode': 'routed',
}
session_info = client.video.create_session(session_options)
assert isinstance(session_info, dict)
assert session_info['session_id'] == session_id
Expand Down Expand Up @@ -130,6 +134,12 @@ def test_generate_client_token_custom_options(client: Client):
assert decoded_token['acl'] == ['1', '2', '3']


def test_generate_client_token_publisher_only_role(client: Client):
token = client.video.generate_client_token(session_id, {'role': 'publisheronly'})
decoded_token = jwt.decode(token, algorithms='RS256', options={'verify_signature': False})
assert decoded_token['role'] == 'publisheronly'


def test_check_client_token_headers(client: Client):
token = client.video.generate_client_token(session_id)
headers = jwt.get_unverified_header(token)
Expand Down Expand Up @@ -197,7 +207,8 @@ def test_send_signal_to_all_participants(client: Client):
)

assert isinstance(
client.video.send_signal(session_id, type='chat', data='hello from a test case'), dict
client.video.send_signal(session_id, type='chat', data='hello from a test case'),
dict,
)
assert request_content_type() == "application/json"

Expand All @@ -211,7 +222,10 @@ def test_send_signal_to_single_participant(client: Client):

assert isinstance(
client.video.send_signal(
session_id, type='chat', data='hello from a test case', connection_id=connection_id
session_id,
type='chat',
data='hello from a test case',
connection_id=connection_id,
),
dict,
)
Expand Down

0 comments on commit 0852476

Please sign in to comment.