-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* VT-4406 * VT-4406 * VT-4406 * Updated to current style * Update token.py Added checking to iss * VT-4406 * made changes in token.py * made changes in token.py * Added unit testing files * w * Added token creation * Updated version * Updated version * Update setup.py * Update version.py * Update version.py * Update setup.py * versioning change * Update CHANGELOG.md * version change * Update setup.py * Update CHANGELOG.md * Added unit tests * Added unit tests * Added unit tests * unit testing changes * Delete test.py Co-authored-by: kowshiksiva5 <[email protected]> Co-authored-by: abhishekgupta <[email protected]> Co-authored-by: Kowshik siva sai Motepalli <[email protected]> Co-authored-by: abhishekGupta-Plivo <[email protected]>
- Loading branch information
1 parent
ef76f68
commit cc6a319
Showing
8 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import string | ||
|
||
from plivo.base import (PlivoResourceInterface) | ||
from plivo.utils.validators import * | ||
|
||
|
||
class Token(PlivoResourceInterface): | ||
@validate_args( | ||
iss=[required(of_type(six.text_type))], | ||
sub=[optional(of_type(six.text_type))], | ||
nbf=[optional(of_type(six.text_type))], | ||
exp=[optional(of_type(six.text_type))], | ||
incoming_allow=[optional(of_type(bool, string))], | ||
outgoing_allow=[optional(of_type(bool, string))], | ||
app=[optional(of_type(six.text_type))] | ||
) | ||
def create(self, iss, sub=None, nbf=None, exp=None, incoming_allow=None, outgoing_allow=None, app=None): | ||
if incoming_allow is True and sub is None: | ||
raise ValueError('sub is required when incoming_allow is true') | ||
else: | ||
params = {'iss': iss} | ||
|
||
if sub: | ||
params['sub'] = sub | ||
if nbf: | ||
params['nbf'] = nbf | ||
if exp: | ||
params['exp'] = exp | ||
if incoming_allow or outgoing_allow: | ||
params['per'] = {} | ||
params['per']['voice'] = {} | ||
if incoming_allow: | ||
params['per']['voice']['incoming_allow'] = incoming_allow | ||
if outgoing_allow: | ||
params['per']['voice']['outgoing_allow'] = outgoing_allow | ||
if app: | ||
params['app'] = app | ||
|
||
return self.client.request('POST', ('JWT', 'Token',), params, is_voice_request=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
__version__ = '4.24.1' | ||
__version__ = '4.25.1' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{"api_id": "5cbad7b4-19f4-11ed-8b03-0242ac110005", | ||
"token": "eyJhbGciOiJIUzI1NiIsImN0eSI6InBsaXZvO3Y9MSIsInR5cCI6IkpXVCJ9.eyJhcHAiOiIiLCJleHAiOjE2NjAzNjM2ODMsImlzcyI6Ik1BTURWTFpKWTJaR1k1TVdVMVpKIiwibmJmIjoxNjYwMjc3MjgzLCJwZXIiOnsidm9pY2UiOnsiaW5jb21pbmdfYWxsb3ciOmZhbHNlLCJvdXRnb2luZ19hbGxvdyI6dHJ1ZX19LCJzdWIiOiIifQ.LAwFEuotTmbZeGWBhfNT4X2KbRapYF23BrkwVfmr5A4" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
from tests import PlivoResourceTestCase | ||
from tests.decorators import with_response | ||
|
||
|
||
class TokenTest(PlivoResourceTestCase): | ||
@with_response(200) | ||
def test_create(self): | ||
self.client.token.create("MAXXXXXXXXXXXXXXXXXX") | ||
self.assertEqual(self.client.current_request.method, 'POST') | ||
self.assertUrlEqual( | ||
self.get_voice_url('JWT/Token'), self.client.current_request.url) |