def test_form_post(self): html = '<form method="POST">%s<input name="age" value=""/></form>' injector = FormTokenInjector('123123', io.StringIO()) injector.feed(html % '') injector.close() html %= ('<input type="hidden" name="__FORM_TOKEN" value="%s"/>' % injector.token) self.assertEqual(html, injector.out.getvalue())
def test_form_get(self): html = '<form method="get"><input name="age" value=""/></form>' injector = FormTokenInjector('123123', io.StringIO()) injector.feed(html) injector.close() self.assertEqual(html, injector.out.getvalue())
def test_no_form(self): html = '<div><img src="trac.png"/></div>' injector = FormTokenInjector('123123', io.StringIO()) injector.feed(html) injector.close() self.assertEqual(html, injector.out.getvalue())