mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
python: Normalize quotes with Black.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
11741543da
commit
6e4c3e41dc
@@ -9,18 +9,18 @@ from zerver.lib.storage import static_path
|
||||
|
||||
# See https://jackstromberg.com/2013/01/useraccountcontrol-attributeflag-values/
|
||||
# for docs on what these values mean.
|
||||
LDAP_USER_ACCOUNT_CONTROL_NORMAL = '512'
|
||||
LDAP_USER_ACCOUNT_CONTROL_DISABLED = '514'
|
||||
LDAP_USER_ACCOUNT_CONTROL_NORMAL = "512"
|
||||
LDAP_USER_ACCOUNT_CONTROL_DISABLED = "514"
|
||||
|
||||
|
||||
def generate_dev_ldap_dir(mode: str, num_users: int = 8) -> Dict[str, Dict[str, Any]]:
|
||||
mode = mode.lower()
|
||||
ldap_data = []
|
||||
for i in range(1, num_users + 1):
|
||||
name = f'LDAP User {i}'
|
||||
email = f'ldapuser{i}@zulip.com'
|
||||
phone_number = f'999999999{i}'
|
||||
birthdate = f'19{i:02}-{i:02}-{i:02}'
|
||||
name = f"LDAP User {i}"
|
||||
email = f"ldapuser{i}@zulip.com"
|
||||
phone_number = f"999999999{i}"
|
||||
birthdate = f"19{i:02}-{i:02}-{i:02}"
|
||||
ldap_data.append((name, email, phone_number, birthdate))
|
||||
|
||||
profile_images = []
|
||||
@@ -30,28 +30,28 @@ def generate_dev_ldap_dir(mode: str, num_users: int = 8) -> Dict[str, Dict[str,
|
||||
ldap_dir = {}
|
||||
for i, user_data in enumerate(ldap_data):
|
||||
email = user_data[1].lower()
|
||||
email_username = email.split('@')[0]
|
||||
email_username = email.split("@")[0]
|
||||
common_data = {
|
||||
'cn': [user_data[0]],
|
||||
'userPassword': [email_username],
|
||||
'phoneNumber': [user_data[2]],
|
||||
'birthDate': [user_data[3]],
|
||||
"cn": [user_data[0]],
|
||||
"userPassword": [email_username],
|
||||
"phoneNumber": [user_data[2]],
|
||||
"birthDate": [user_data[3]],
|
||||
}
|
||||
if mode == 'a':
|
||||
ldap_dir['uid=' + email + ',ou=users,dc=zulip,dc=com'] = dict(
|
||||
if mode == "a":
|
||||
ldap_dir["uid=" + email + ",ou=users,dc=zulip,dc=com"] = dict(
|
||||
uid=[email],
|
||||
thumbnailPhoto=[profile_images[i % len(profile_images)]],
|
||||
userAccountControl=[LDAP_USER_ACCOUNT_CONTROL_NORMAL],
|
||||
**common_data,
|
||||
)
|
||||
elif mode == 'b':
|
||||
ldap_dir['uid=' + email_username + ',ou=users,dc=zulip,dc=com'] = dict(
|
||||
elif mode == "b":
|
||||
ldap_dir["uid=" + email_username + ",ou=users,dc=zulip,dc=com"] = dict(
|
||||
uid=[email_username],
|
||||
jpegPhoto=[profile_images[i % len(profile_images)]],
|
||||
**common_data,
|
||||
)
|
||||
elif mode == 'c':
|
||||
ldap_dir['uid=' + email_username + ',ou=users,dc=zulip,dc=com'] = dict(
|
||||
elif mode == "c":
|
||||
ldap_dir["uid=" + email_username + ",ou=users,dc=zulip,dc=com"] = dict(
|
||||
uid=[email_username], email=[email], **common_data
|
||||
)
|
||||
|
||||
@@ -72,13 +72,13 @@ def init_fakeldap(
|
||||
|
||||
# Silent `django_auth_ldap` logger in dev mode to avoid
|
||||
# spammy user not found log messages.
|
||||
ldap_auth_logger = logging.getLogger('django_auth_ldap')
|
||||
ldap_auth_logger = logging.getLogger("django_auth_ldap")
|
||||
ldap_auth_logger.setLevel(logging.CRITICAL)
|
||||
|
||||
fakeldap_logger = logging.getLogger('fakeldap')
|
||||
fakeldap_logger = logging.getLogger("fakeldap")
|
||||
fakeldap_logger.setLevel(logging.CRITICAL)
|
||||
|
||||
ldap_patcher = mock.patch('django_auth_ldap.config.ldap.initialize')
|
||||
ldap_patcher = mock.patch("django_auth_ldap.config.ldap.initialize")
|
||||
mock_initialize = ldap_patcher.start()
|
||||
mock_ldap = MockLDAP()
|
||||
mock_initialize.return_value = mock_ldap
|
||||
|
||||
Reference in New Issue
Block a user