Permalink
Browse files

more refactoring

  • Loading branch information...
oberstet committed Oct 9, 2013
1 parent 5738e9b commit a024913c0a82697c114f2420e3a3bb188f351f18
Showing with 43 additions and 85 deletions.
  1. +1 −0 .gitignore
  2. +41 −2 autobahntestsuite/autobahntestsuite/fuzzing.py
  3. +1 −83 autobahntestsuite/autobahntestsuite/wstest.py
View
@@ -6,3 +6,4 @@
/autobahntestsuite/autobahntestsuite.egg-info*/
/reports
*~
+autobahntestsuite/reports
@@ -1263,10 +1263,49 @@ def clientConnectionFailed(self, connector, reason):
reactor.stop()
+def loadTestData():
+ test_data = {
+ 'gutenberg_faust':
+ {'desc': "Human readable text, Goethe's Faust I (German)",
+ 'url': 'http://www.gutenberg.org/cache/epub/2229/pg2229.txt',
+ 'file':
+ 'pg2229.txt'
+ },
+ 'lena512':
+ {'desc': 'Lena Picture, Bitmap 512x512 bw',
+ 'url': 'http://www.ece.rice.edu/~wakin/images/lena512.bmp',
+ 'file': 'lena512.bmp'
+ },
+ 'ooms':
+ {'desc': 'A larger PDF',
+ 'url':
+ 'http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.105.5439',
+ 'file': '10.1.1.105.5439.pdf'
+ },
+ 'json_data1':
+ {'desc': 'Large JSON data file',
+ 'url': None,
+ 'file': 'data1.json'
+ },
+ 'html_data1':
+ {'desc': 'Large HTML file',
+ 'url': None,
+ 'file': 'data1.html'
+ }
+ }
+
+ for t in test_data:
+ fn = pkg_resources.resource_filename("autobahntestsuite",
+ "testdata/%s" %
+ test_data[t]['file'])
+ test_data[t]['data'] = open(fn, 'rb').read()
+
+ return test_data
+
def startClient(spec, debug = False):
factory = FuzzingClientFactory(spec, debug)
- #factory.testData = self.testData
+ factory.testData = loadTestData()
# no connectWS done here, since this is done within
# FuzzingClientFactory automatically to orchestrate tests
return True
@@ -1282,7 +1321,7 @@ def startServer(spec, sslKey = None, sslCert = None, debug = False):
sslCert = spec.get('cert', None)
factory = FuzzingServerFactory(spec, debug)
- #factory.testData = self.testData
+ factory.testData = loadTestData()
if sslKey and sslCert:
sslContext = ssl.DefaultOpenSSLContextFactory(sslKey, sslCert)
@@ -250,7 +250,6 @@ def __init__(self):
log.startLogging(sys.stdout)
self.mode = str(self.options['mode'])
- self.testData = self._loadTestData()
def startService(self):
@@ -546,36 +545,7 @@ def process(result):
def startFuzzingService(self):
spec = self._loadSpec()
- if self.mode == 'fuzzingserver':
- ## use TLS server key/cert from spec, but allow overriding
- ## from cmd line
- if not self.options['key']:
- self.options['key'] = spec.get('key', None)
- if not self.options['cert']:
- self.options['cert'] = spec.get('cert', None)
-
- factory = FuzzingServerFactory(spec, self.debug)
- factory.testData = self.testData
- context = self._createWssContext(factory)
- listenWS(factory, context)
-
- webdir = File(pkg_resources.resource_filename("autobahntestsuite",
- "web/fuzzingserver"))
- curdir = File('.')
- webdir.putChild('cwd', curdir)
- web = Site(webdir)
- if factory.isSecure:
- reactor.listenSSL(spec.get("webport", 8080), web, context)
- else:
- reactor.listenTCP(spec.get("webport", 8080), web)
-
- elif self.mode == 'fuzzingclient':
- factory = FuzzingClientFactory(spec, self.debug)
- factory.testData = self.testData
- # no connectWS done here, since this is done within
- # FuzzingClientFactory automatically to orchestrate tests
-
- elif self.mode == 'fuzzingwampclient':
+ if self.mode == 'fuzzingwampclient':
testSet = WampCaseSet()
testDb = TestDb([testSet])
@@ -611,21 +581,6 @@ def startFuzzingService(self):
raise Exception("logic error")
- def startTesteeService(self):
- wsuri = str(self.options['wsuri'])
-
- if self.mode == 'testeeserver':
- factory = TesteeServerFactory(wsuri, self.debug)
- listenWS(factory, self._createWssContext(factory))
-
- elif self.mode == 'testeeclient':
- factory = TesteeClientFactory(wsuri, self.debug)
- connectWS(factory)
-
- else:
- raise Exception("logic error")
-
-
def startEchoService(self):
wsuri = str(self.options['wsuri'])
@@ -775,44 +730,7 @@ def _createWssContext(self, factory):
return ssl.DefaultOpenSSLContextFactory(key, cert)
- def _loadTestData(self):
- test_data = {
- 'gutenberg_faust':
- {'desc': "Human readable text, Goethe's Faust I (German)",
- 'url': 'http://www.gutenberg.org/cache/epub/2229/pg2229.txt',
- 'file':
- 'pg2229.txt'
- },
- 'lena512':
- {'desc': 'Lena Picture, Bitmap 512x512 bw',
- 'url': 'http://www.ece.rice.edu/~wakin/images/lena512.bmp',
- 'file': 'lena512.bmp'
- },
- 'ooms':
- {'desc': 'A larger PDF',
- 'url':
- 'http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.105.5439',
- 'file': '10.1.1.105.5439.pdf'
- },
- 'json_data1':
- {'desc': 'Large JSON data file',
- 'url': None,
- 'file': 'data1.json'
- },
- 'html_data1':
- {'desc': 'Large HTML file',
- 'url': None,
- 'file': 'data1.html'
- }
- }
-
- for t in test_data:
- fn = pkg_resources.resource_filename("autobahntestsuite",
- "testdata/%s" %
- test_data[t]['file'])
- test_data[t]['data'] = open(fn, 'rb').read()
- return test_data

0 comments on commit a024913

Please sign in to comment.