Skip to content

Commit 0852476

Browse files
authored
Add publisher only role (#295)
* add publisher-only role * Bump version: 3.13.1 → 3.14.0
1 parent 9e926fb commit 0852476

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 3.13.1
2+
current_version = 3.14.0
33
commit = True
44
tag = False
55

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,9 @@ ENV*
111111
.pytest_cache
112112
html/
113113
.mutmut-cache
114+
_test_scripts/
115+
116+
# Pants workspace files
117+
/.pants.*
118+
/dist/
119+
/.pids

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 3.14.0
2+
- Add publisher-only as a valid Video API client token role
3+
14
# 3.13.1
25
- Fix content-type incorrect serialization
36

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name="vonage",
12-
version="3.13.1",
12+
version="3.14.0",
1313
description="Vonage Server SDK for Python",
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",

src/vonage/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .client import *
22
from .ncco_builder.ncco import *
33

4-
__version__ = "3.13.1"
4+
__version__ = "3.14.0"

src/vonage/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Video:
2020
auth_type = 'jwt'
2121
archive_mode_values = {'manual', 'always'}
2222
media_mode_values = {'routed', 'relayed'}
23-
token_roles = {'subscriber', 'publisher', 'moderator'}
23+
token_roles = {'subscriber', 'publisher', 'publisheronly', 'moderator'}
2424

2525
def __init__(self, client: Client):
2626
self._client = client

tests/test_video.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ def test_create_session_custom_archive_mode_and_location(client: Client):
4444
fixture_path="video/create_session.json",
4545
)
4646

47-
session_options = {'archive_mode': 'always', 'location': '192.0.1.1', 'media_mode': 'routed'}
47+
session_options = {
48+
'archive_mode': 'always',
49+
'location': '192.0.1.1',
50+
'media_mode': 'routed',
51+
}
4852
session_info = client.video.create_session(session_options)
4953
assert isinstance(session_info, dict)
5054
assert session_info['session_id'] == session_id
@@ -130,6 +134,12 @@ def test_generate_client_token_custom_options(client: Client):
130134
assert decoded_token['acl'] == ['1', '2', '3']
131135

132136

137+
def test_generate_client_token_publisher_only_role(client: Client):
138+
token = client.video.generate_client_token(session_id, {'role': 'publisheronly'})
139+
decoded_token = jwt.decode(token, algorithms='RS256', options={'verify_signature': False})
140+
assert decoded_token['role'] == 'publisheronly'
141+
142+
133143
def test_check_client_token_headers(client: Client):
134144
token = client.video.generate_client_token(session_id)
135145
headers = jwt.get_unverified_header(token)
@@ -197,7 +207,8 @@ def test_send_signal_to_all_participants(client: Client):
197207
)
198208

199209
assert isinstance(
200-
client.video.send_signal(session_id, type='chat', data='hello from a test case'), dict
210+
client.video.send_signal(session_id, type='chat', data='hello from a test case'),
211+
dict,
201212
)
202213
assert request_content_type() == "application/json"
203214

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

212223
assert isinstance(
213224
client.video.send_signal(
214-
session_id, type='chat', data='hello from a test case', connection_id=connection_id
225+
session_id,
226+
type='chat',
227+
data='hello from a test case',
228+
connection_id=connection_id,
215229
),
216230
dict,
217231
)

0 commit comments

Comments
 (0)