Пример #1
0
def test_encoding(uint_val, separator):
    quint = uint2quint(uint_val, separator)
    assert_not_equals(quint, uint_val)
    assert_equals(11, len(quint))

    uint_val1 = quint2uint(quint)
    assert_equals(uint_val, uint_val1)
Пример #2
0
def test_encoding(uint_val, separator):
    quint = uint2quint(uint_val, separator)
    assert_not_equals(quint, uint_val)
    assert_equals(11, len(quint))

    uint_val1 = quint2uint(quint)
    assert_equals(uint_val, uint_val1)
Пример #3
0
def test_presets():
    presets = [
        ('127.0.0.1', 'lusab-babad'), ('63.84.220.193', 'gutih-tugad'),
        ('63.118.7.35', 'gutuk-bisog'), ('140.98.193.141', 'mudof-sakat'),
        ('64.255.6.200', 'haguz-biram'), ('128.30.52.45', 'mabiv-gibot'),
        ('147.67.119.2', 'natag-lisaf'), ('212.58.253.68', 'tibup-zujah'),
        ('216.35.68.215', 'tobog-higil'), ('216.68.232.21', 'todah-vobij'),
        ('198.81.129.136', 'sinid-makam'), ('12.110.110.204', 'budov-kuras')
    ]

    quints = [uint2quint(ip2uint_str(t[0])) for t in presets]
    assert_list_equal(quints, [t[1] for t in presets])

    uints = [quint2uint(t[1]) for t in presets]
    assert_list_equal(uints, [ip2uint_str(t[0]) for t in presets])
Пример #4
0
def generate_eppn():
    """
    Generate a unique eduPersonPrincipalName.

    Unique is defined as 'at least it doesn't exist right now'.

    :return: eppn
    :rtype: string or None
    """
    for _ in range(10):
        eppn_int = struct.unpack('I', os.urandom(4))[0]
        eppn = proquint.uint2quint(eppn_int)
        try:
            current_app.central_userdb.get_user_by_eppn(eppn)
        except current_app.central_userdb.exceptions.UserDoesNotExist:
            return eppn
    abort(500)
Пример #5
0
def generate_eppn():
    """
    Generate a unique eduPersonPrincipalName.

    Unique is defined as 'at least it doesn't exist right now'.

    :return: eppn
    :rtype: string or None
    """
    for _ in range(10):
        eppn_int = struct.unpack('I', os.urandom(4))[0]
        eppn = proquint.uint2quint(eppn_int)
        try:
            current_app.central_userdb.get_user_by_eppn(eppn)
        except current_app.central_userdb.exceptions.UserDoesNotExist:
            return eppn
    abort(500)
Пример #6
0
def test_presets():
    presets = [
        ('127.0.0.1',       'lusab-babad'),
        ('63.84.220.193',   'gutih-tugad'),
        ('63.118.7.35',     'gutuk-bisog'),
        ('140.98.193.141',  'mudof-sakat'),
        ('64.255.6.200',    'haguz-biram'),
        ('128.30.52.45',    'mabiv-gibot'),
        ('147.67.119.2',    'natag-lisaf'),
        ('212.58.253.68',   'tibup-zujah'),
        ('216.35.68.215',   'tobog-higil'),
        ('216.68.232.21',   'todah-vobij'),
        ('198.81.129.136',  'sinid-makam'),
        ('12.110.110.204',  'budov-kuras')]

    quints = [uint2quint(ip2uint_str(t[0])) for t in presets]
    assert_list_equal(quints, [t[1] for t in presets])

    uints = [quint2uint(t[1]) for t in presets]
    assert_list_equal(uints, [ip2uint_str(t[0]) for t in presets])
Пример #7
0
def hex2quint_str(hex_str, separator='-'):
    return uint2quint(int(hex_str, 16), separator)
Пример #8
0
def uint2quint_str(uint_str, separator='-'):
    return uint2quint(int(uint_str), separator)