Ejemplo n.º 1
0
def get_username(strategy, user=None, *args, **kwargs):
    """Sets the `username` argument.

    If the user exists already, use the existing username. Otherwise
    generate username from the `new_uuid` using the
    `helusers.utils.uuid_to_username` function.
    """
    storage = strategy.storage

    if not user:
        user_uuid = kwargs.get('new_uuid')
        if not user_uuid:
            return

        final_username = uuid_to_username(user_uuid)
    else:
        final_username = storage.user.get_username(user)

    return {'username': final_username}
Ejemplo n.º 2
0
def get_username(strategy, user=None, *args, **kwargs):
    """Sets the `username` argument.

    If the user exists already, use the existing username. Otherwise
    generate username from the `new_uuid` using the
    `helusers.utils.uuid_to_username` function.
    """
    storage = strategy.storage

    if not user:
        user_uuid = kwargs.get('new_uuid')
        if not user_uuid:
            return

        final_username = uuid_to_username(user_uuid)
    else:
        final_username = storage.user.get_username(user)

    return {
        'username': final_username
    }
Ejemplo n.º 3
0
def test_uuid_to_username():
    assert uuid_to_username('00fbac99-0bab-5e66-8e84-2e567ea4d1f6') == 'u-ad52zgilvnpgnduefzlh5jgr6y'
Ejemplo n.º 4
0
def test_reflective_username_uuid_relationship():
    rd = random.Random()
    rd.seed(0)

    for uuid in [UUID(int=rd.getrandbits(128)) for i in range(0,100)]:
        assert username_to_uuid(uuid_to_username(uuid)) == uuid
Ejemplo n.º 5
0
 def extract_common_fields(self, data):
     ret = data.copy()
     ret['username'] = uuid_to_username(data['uuid'])
     return ret
Ejemplo n.º 6
0
 def extract_common_fields(self, data):
     ret = oidc_to_user_data(data)
     ret['username'] = uuid_to_username(data['sub'])
     return ret