Esempio n. 1
0
def test_get_password_valid(fake_error):
    with mock.patch.object(vhost_mail, 'validate_password') as m, \
            mock.patch.object(vhost_mail, 'crypt_password') as c:
        assert _get_password(fake_request(password='******'), 'ckuehl') == c.return_value

    m.assert_called_once_with('ckuehl', 'password', strength_check=True)
    c.assert_called_once_with('password')
Esempio n. 2
0
def test_get_password_valid(fake_error):
    with mock.patch.object(vhost_mail, 'validate_password') as m, \
            mock.patch.object(vhost_mail, 'crypt_password') as c:
        assert _get_password(fake_request(password='******'), 'ckuehl') == c.return_value

    m.assert_called_once_with('ckuehl', 'password', strength_check=True)
    c.assert_called_once_with('password')
Esempio n. 3
0
def test_get_password_fails_strength_check(fake_error):
    def fake_validate(addr_name, password, strength_check=False):
        raise ValueError('bad password yo')

    with pytest.raises(fake_error) as ex, \
            mock.patch.object(vhost_mail, 'validate_password', side_effect=fake_validate) as m:
        assert _get_password(fake_request(password='******'), 'ckuehl') is None

    assert ex.value.args[0] == 'bad password yo'
    m.assert_called_once_with('ckuehl', 'password', strength_check=True)
Esempio n. 4
0
def test_get_password_fails_strength_check(fake_error):
    def fake_validate(addr_name, password, strength_check=False):
        raise ValueError('bad password yo')

    with pytest.raises(fake_error) as ex, \
            mock.patch.object(vhost_mail, 'validate_password', side_effect=fake_validate) as m:
        assert _get_password(fake_request(password='******'), 'ckuehl') is None

    assert ex.value.args[0] == 'bad password yo'
    m.assert_called_once_with('ckuehl', 'password', strength_check=True)
Esempio n. 5
0
def test_get_password_empty():
    """If password is present and an empty string, remove it."""
    assert _get_password(fake_request(password=''), 'ckuehl') is REMOVE_PASSWORD
Esempio n. 6
0
def test_get_password_not_present():
    """If "password" is not present, just do nothing."""
    assert _get_password(fake_request(), 'ckuehl') is None
Esempio n. 7
0
def test_get_password_no_name():
    assert _get_password(fake_request(password='******'), None) is REMOVE_PASSWORD
Esempio n. 8
0
def test_get_password_empty():
    """If password is present and an empty string, remove it."""
    assert _get_password(fake_request(password=''), 'ckuehl') is REMOVE_PASSWORD
Esempio n. 9
0
def test_get_password_not_present():
    """If "password" is not present, just do nothing."""
    assert _get_password(fake_request(), 'ckuehl') is None
Esempio n. 10
0
def test_get_password_no_name():
    assert _get_password(fake_request(password='******'), None) is REMOVE_PASSWORD