|
40 | 40 | import datetime |
41 | 41 | import hashlib |
42 | 42 | import time |
| 43 | +import sys |
43 | 44 |
|
44 | 45 | from mig.shared.base import force_utf8, force_native_str, mask_creds, string_snippet |
45 | 46 | from mig.shared.defaults import keyword_auto, RESET_TOKEN_TTL |
@@ -1027,7 +1028,8 @@ def generate_random_password(configuration, tries=42): |
1027 | 1028 | raise ValueError("Failed to generate suitable password!") |
1028 | 1029 |
|
1029 | 1030 |
|
1030 | | -if __name__ == "__main__": |
| 1031 | +def main(_exit=sys.exit, _print=print): |
| 1032 | + """Run module self-tests""" |
1031 | 1033 | from mig.shared.conf import get_configuration_object |
1032 | 1034 | configuration = get_configuration_object() |
1033 | 1035 | dummy_user = {'distinguished_name': 'Test User', 'password_hash': ''} |
@@ -1057,6 +1059,8 @@ def generate_random_password(configuration, tries=42): |
1057 | 1059 | hashed = make_hash(pw) |
1058 | 1060 | snippet = string_snippet(hashed) |
1059 | 1061 | dummy_user['password_hash'] = hashed |
| 1062 | + if 'migoid' not in configuration.site_login_methods: |
| 1063 | + configuration.site_login_methods.append('migoid') |
1060 | 1064 | token = generate_reset_token(configuration, dummy_user, 'migoid') |
1061 | 1065 | print("Password %r gives hash %r, snippet %r and reset token %r" % |
1062 | 1066 | (pw, hashed, snippet, token)) |
@@ -1112,3 +1116,7 @@ def generate_random_password(configuration, tries=42): |
1112 | 1116 | except Exception as exc: |
1113 | 1117 | print( |
1114 | 1118 | "Failed to handle aesgcm static encrypt/decrypt %s : %s" % (pw, exc)) |
| 1119 | + |
| 1120 | + |
| 1121 | +if __name__ == "__main__": |
| 1122 | + main() |
0 commit comments