Skip to content

Commit 3b0652e

Browse files
committed
Detect instance source and adapt security properties
1 parent e8011f1 commit 3b0652e

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/browsergym/workarena/install.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@
5353
from .utils import url_login
5454

5555

56+
def _is_dev_portal_instance() -> bool:
57+
"""
58+
Check if the instance is a ServiceNow Developer Portal instance.
59+
60+
Returns:
61+
--------
62+
bool: True if the instance is a developer portal instance, False otherwise.
63+
64+
"""
65+
instance = SNowInstance()
66+
# Check if the instance url has the for devXXXXXX.service-now.com format (where X is a digit)
67+
if re.match(r"^https?://dev\d{6}\.service-now\.com", instance.snow_url):
68+
logging.info("Detected a developer portal instance...")
69+
return True
70+
logging.info("Detected an internal instance...")
71+
return False
72+
73+
5674
def _set_sys_property(property_name: str, value: str):
5775
"""
5876
Set a sys_property in the instance.
@@ -812,9 +830,11 @@ def disable_password_policies():
812830
"""
813831
_set_sys_property(property_name="glide.security.password.policy.enabled", value="false")
814832
_set_sys_property(property_name="glide.apply.password_policy.on_login", value="false")
815-
_set_sys_property(
816-
property_name="glide.authenticate.api.user.reset_password.mandatory", value="false"
817-
)
833+
# The following is not supported on developer portal instances
834+
if not _is_dev_portal_instance():
835+
_set_sys_property(
836+
property_name="glide.authenticate.api.user.reset_password.mandatory", value="false"
837+
)
818838
logging.info("Password policies disabled.")
819839

820840

0 commit comments

Comments
 (0)