Beispiel #1
0
def test_generate_login_code():
    expect = b'84400-1-Tqf88675CWYb2sge67b9'
    result = generate_login_code('abc', 84400, 1)
    assert expect == result

    # Check that this will work with strings or bytes
    result = generate_login_code(b'abc', 84400, b'1')
    assert expect == result
Beispiel #2
0
def test_generate_login_code():
    expected = "84400-1-Tqf88675CWYb2sge67b9"
    result = generate_login_code("abc", 84400, 1)
    assert expected == result

    # Check that this will work with a key made of bytes
    result = generate_login_code(b"abc", 84400, 1)
    assert expected == result
Beispiel #3
0
def test_generate_login_code():
    expected = '84400-1-Tqf88675CWYb2sge67b9'
    result = generate_login_code('abc', 84400, 1)
    assert expected == result

    # Check that this will work with a key made of bytes
    result = generate_login_code(b'abc', 84400, 1)
    assert expected == result
Beispiel #4
0
    def test_generate_login_code(self):
        expect = b'84400-1-Tqf88675CWYb2sge67b9'
        result = generate_login_code('abc', 84400, 1)
        self.assertEqual(expect, result)

        # Check that this will work with strings or bytes
        result = generate_login_code(b'abc', 84400, b'1')
        self.assertEqual(expect, result)
Beispiel #5
0
def test_generate_login_code():
    expect = b'84400-1-Tqf88675CWYb2sge67b9'
    result = generate_login_code('abc', 84400, 1)
    assert expect == result

    # Check that this will work with strings or bytes
    result = generate_login_code(b'abc', 84400, b'1')
    assert expect == result
Beispiel #6
0
def test_verify_login_code():
    uid = 1
    key = "abc"
    gen_time = 84400
    good_time = 84401
    code = generate_login_code(key, gen_time, uid)

    good_result = verify_login_code("abc", good_time, code)
    assert good_result == uid

    malformed_code_result = verify_login_code("abc", good_time, "84400-1")
    assert malformed_code_result is None

    # Timeout is currently 6 hours
    expired_result = verify_login_code("abc", gen_time * 10, code)
    assert expired_result is None

    bad_code_result = verify_login_code("ab", good_time, code)
    assert bad_code_result is None
Beispiel #7
0
def test_verify_login_code():
    uid = 1
    key = 'abc'
    gen_time = 84400
    good_time = 84401
    code = generate_login_code(key, gen_time, uid)

    good_result = verify_login_code('abc', good_time, code)
    assert good_result == uid

    malformed_code_result = verify_login_code('abc', good_time, b'84400-1')
    assert malformed_code_result is None

    # Timeout is currently 6 hours
    expired_result = verify_login_code('abc', gen_time * 10, code)
    assert expired_result is None

    bad_code_result = verify_login_code('ab', good_time, code)
    assert bad_code_result is None
Beispiel #8
0
    def test_verify_login_code(self):
        uid = 1
        key = 'abc'
        gen_time = 84400
        good_time = 84401
        code = generate_login_code(key, gen_time, uid)

        good_result = verify_login_code('abc', good_time, code)
        self.assertEqual(good_result, uid)

        malformed_code_result = verify_login_code('abc', good_time, b'84400-1')
        self.assertIsNone(malformed_code_result)

        # Timeout is currently 6 hours
        expired_result = verify_login_code('abc', gen_time * 10, code)
        self.assertIsNone(expired_result)

        bad_code_result = verify_login_code('ab', good_time, code)
        self.assertIsNone(bad_code_result)