Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add verification push methods to client #241

Merged
merged 3 commits into from
Dec 8, 2023
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
13 changes: 13 additions & 0 deletions duo_client/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3245,6 +3245,19 @@ def sync_user(self, username, directory_key):
directory_key=directory_key)
return self.json_api_call('POST', path, params)

def send_verification_push(self, user_id, phone_id):
return self.json_api_call(
'POST',
f'/admin/v1/users/{user_id}/send_verification_push',
{'phone_id': phone_id}
)

def get_verification_push_response(self, user_id, push_id):
return self.json_api_call(
'GET',
f'/admin/v1/users/{user_id}/verification_push_response',
{'push_id': push_id},
)
def get_trust_monitor_events_iterator(
self,
mintime,
Expand Down
30 changes: 30 additions & 0 deletions tests/admin/test_verification_push.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import json
from .. import util
from .base import TestAdmin


class TestVerificationPush(TestAdmin):
def test_send_verification_push(self):
"""
Test sending a verification push to a user.
"""
response = self.client.send_verification_push('test_user_id', 'test_phone_id')
self.assertEqual(response['method'], 'POST')
self.assertEqual(response['uri'],
'/admin/v1/users/test_user_id/send_verification_push')
self.assertEqual(
json.loads(response['body']),
{'phone_id': 'test_phone_id', 'account_id': self.client.account_id})

def test_get_verification_push_response(self):
"""
Test getting the verification push response.
"""
response = self.client.get_verification_push_response('test_user_id', 'test_push_id')
(uri, args) = response['uri'].split('?')
self.assertEqual(response['method'], 'GET')
self.assertEqual(uri, '/admin/v1/users/test_user_id/verification_push_response')

self.assertEqual(
util.params_to_dict(args),
{'push_id': ['test_push_id'], 'account_id': [self.client.account_id]})
Loading