Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion duo_client/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
import time
import urllib.parse
import warnings
from typing import List, Optional
from datetime import datetime, timedelta, timezone

from . import Accounts, client
Expand Down Expand Up @@ -3677,7 +3678,7 @@ def get_passport_config(self):
response = self.json_api_call("GET", path, {})
return response

def update_passport_config(self, enabled_status, enabled_groups=[], disabled_groups=[]):
def update_passport_config(self, enabled_status, enabled_groups: Optional[List[str]]=None, disabled_groups: Optional[List[str]]=None, custom_supported_browsers=None):
"""
Update the current Passport configuration.

Expand All @@ -3688,7 +3689,11 @@ def update_passport_config(self, enabled_status, enabled_groups=[], disabled_gro
list of user group IDs for whom Passport should be enabled
disabled_groups (list[str]) - if enabled_status is "enabled-with-exceptions",
a list of user group IDs for whom Passport should be disabled
custom_supported_browsers (dict) - a dict of criteria that determines whether
a Windows or macOS browsers should be supported by Passport
"""
if custom_supported_browsers == None:
Comment thread
AaronAtDuo marked this conversation as resolved.
Outdated
custom_supported_browsers = {"macos": [], "windows": [],}

path = "/admin/v2/passport/config"
response = self.json_api_call(
Expand All @@ -3698,6 +3703,7 @@ def update_passport_config(self, enabled_status, enabled_groups=[], disabled_gro
"enabled_status": enabled_status,
"enabled_groups": enabled_groups,
"disabled_groups": disabled_groups,
"custom_supported_browsers": custom_supported_browsers,
},
)
return response
Expand Down
5 changes: 3 additions & 2 deletions tests/admin/test_passport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def test_get_passport(self):
def test_update_passport(self):
""" Test update passport configuration
"""
response = self.client.update_passport_config(enabled_status="enabled-for-groups", enabled_groups=["passport-test-group"])
response = self.client.update_passport_config(enabled_status="enabled-for-groups", enabled_groups=["passport-test-group"], custom_supported_browsers={"macos": [{"team_id": "UBF8T346G9"},], "windows": [{"common_name": "Duo Security LLC"},],})
self.assertEqual(response["uri"], "/admin/v2/passport/config")
body = json.loads(response["body"])
self.assertEqual(body["enabled_status"], "enabled-for-groups")
self.assertEqual(body["enabled_groups"], ["passport-test-group"])
self.assertEqual(body["disabled_groups"], [])
self.assertEqual(body["disabled_groups"], None)
self.assertEqual(body["custom_supported_browsers"], {"macos":[{"team_id":"UBF8T346G9"}],"windows":[{"common_name":"Duo Security LLC"}]})