コード例 #1
0
def test_simpleloginform_valid_data(settings):
    settings.DJCL_MONERO_NETWORK = "mainnet"
    request = MagicMock()
    form = SimpleLoginForm(
        request=request,
        data={
            "address": VALID_ADDRESS,
            "challenge": "12345678",
            "signature": "some valid signature",
        },
    )
    with patch("django_cryptolock.forms.authenticate") as auth_mock:
        auth_mock.return_value = mommy.make(User)
        request.session.get.return_value = "12345678"
        assert form.is_valid()
コード例 #2
0
def test_simpleloginform_expired_challenge(settings):
    settings.DJCL_MONERO_NETWORK = "mainnet"
    mommy.make(Challenge, challenge="12345678", expires=timezone.now())
    request = MagicMock()
    request.build_absolute_uri.return_value = "http://something/"
    form = SimpleLoginForm(
        request=request,
        data={
            "address": VALID_MONERO_ADDRESS,
            "challenge": gen_challenge(request, "12345678"),
            "signature": "some valid signature",
        },
    )
    with patch("django_cryptolock.forms.authenticate") as auth_mock:
        auth_mock.return_value = mommy.make(User)
        assert not form.is_valid()