Commit 912a4f4a authored by Petr Kalashnikov's avatar Petr Kalashnikov
Browse files

CIM19: Create temporary usernames and passwords for new student IDs

parent fc5886f5
Pipeline #22895 passed with stage
in 34 seconds
......@@ -6,6 +6,8 @@ import urllib.parse
from typing import Tuple, Union, List
import requests
import random
import string
from cim_client.models import Person, PersonList
......@@ -42,6 +44,14 @@ def merge_dicts(*dicts):
return combined
def make_temporary_username(studentnummer):
return '' + str(studentnummer)
def generate_password():
return ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k=10))
class CimEndpoints:
def __init__(self,
......@@ -272,6 +282,14 @@ class CimClient(object):
return self.post_person(persons, delete=False, overwrite=overwrite)
def create_missing_usernames(self, list_of_student_ids=[]):
persons = [Person(
password=generate_password()) for x in list_of_student_ids]
return self.post_person(persons, delete=False, overwrite=False)
def get_client(config_dict):
......@@ -102,3 +102,12 @@ def test_update_failure_500(client, john_doe, requests_mock):
with pytest.raises(HTTPError):
response = client.update_person(Person.from_dict(john_doe))
def test_create_missing_usernames(client, requests_mock):
"""Ensure updating one works"""
response = client.create_missing_usernames(['0000', '9999'])
assert response == ('Import success', b'')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment