Exemplo n.º 1
0
 def test_verified_data(self):
     form = SignedDataForm(data={"signed": SignedDataForm.sign(DATA)})
     self.assertEqual(
         form.verified_data(),
         {
             "value": "foo",
             "date": "2020-01-01 00:00:00+00:00",
         },
     )
     # Take it back to the foo form to validate the datetime is serialized
     foo_form = FooForm(data=form.verified_data())
     self.assertTrue(foo_form.is_valid())
     self.assertDictEqual(foo_form.cleaned_data, DATA)
Exemplo n.º 2
0
    def inner(request, *args, **kwargs):
        from debug_toolbar.forms import SignedDataForm

        data = request.GET if request.method == "GET" else request.POST
        signed_form = SignedDataForm(data)
        if signed_form.is_valid():
            return view(request,
                        *args,
                        verified_data=signed_form.verified_data(),
                        **kwargs)
        return HttpResponseBadRequest("Invalid signature")