Commit 4a2409ac authored by Nicolas Wavrant's avatar Nicolas Wavrant

resiliency-tests: _getRcode now use lxml, which is made for this purpose

parent a7930478
...@@ -31,6 +31,7 @@ from .resiliencytestsuite import ResiliencyTestSuite ...@@ -31,6 +31,7 @@ from .resiliencytestsuite import ResiliencyTestSuite
import base64 import base64
import cookielib import cookielib
import json import json
from lxml import etree
import random import random
import string import string
import time import time
...@@ -170,27 +171,6 @@ class SlaprunnerTestSuite(ResiliencyTestSuite): ...@@ -170,27 +171,6 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
) )
def _getRcode(self): def _getRcode(self):
from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.recovery_code = ""
self.attributes = None
def handle_starttag(self, tag, attrs):
print "Encountered a start tag:", tag, " with attrs:", attrs
for at, val in attrs:
if at == "name" and val == "recovery-code":
self.attributes = attrs
def getRcode(self):
if type(self.attributes) == list:
for attr, val in self.attributes:
if attr == "value":
return val
else:
return ""
#XXX-Nicolas: hardcoded url. Best way right now to automate the tests... #XXX-Nicolas: hardcoded url. Best way right now to automate the tests...
monitor_url = self.monitor_url + "?script=zero-knowledge%2Fsettings.cgi" monitor_url = self.monitor_url + "?script=zero-knowledge%2Fsettings.cgi"
result = self._opener_director.open(monitor_url, result = self._opener_director.open(monitor_url,
...@@ -200,10 +180,10 @@ class SlaprunnerTestSuite(ResiliencyTestSuite): ...@@ -200,10 +180,10 @@ class SlaprunnerTestSuite(ResiliencyTestSuite):
raise NotHttpOkException(result.getcode()) raise NotHttpOkException(result.getcode())
page = result.read().strip() page = result.read().strip()
html = etree.HTML(page)
parser = MyHTMLParser() input = html.xpath("//input[@name='recovery-code']")
parser.feed(page) return input[0].get('value')
return parser.getRcode
def generateData(self): def generateData(self):
self.slaprunner_password = ''.join( self.slaprunner_password = ''.join(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment