Skip to content

Commit

Permalink
[playframework#1355] fix ssl config test
Browse files Browse the repository at this point in the history
  • Loading branch information
xael-fry committed Apr 3, 2022
1 parent d1da5ee commit d99cf34
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions samples-and-tests/i-am-a-developer/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

# --- TESTS
DEFAULTS = {
'host': '127.0.0.1',
'host': 'localhost',
'http.port': '9001',
}


class IamADeveloper(unittest.TestCase):
play = None

@unittest.skip
def testSSLConfig(self):

# Testing ssl config
Expand Down Expand Up @@ -146,9 +145,7 @@ def testSSLConfig(self):
self.assertTrue(waitFor(self.play, 'Listening for HTTPS on port ' + DEFAULTS['http.port']))

step("Send request to https")

browser = mechanize.Browser()
response = browser.open('https://' + DEFAULTS['host'] + ':' + DEFAULTS['http.port'])
response = browserOpen('https://' + DEFAULTS['host'] + ':' + DEFAULTS['http.port'])

step("check that ssl message is logged")
self.assertTrue(waitFor(self.play, 'I am ssl secured!'))
Expand All @@ -167,11 +164,11 @@ def testSSLConfig(self):

with callPlay(self, ['run', app]) as self.play:
# wait for play to be ready
self.assertTrue(waitFor(self.play, 'Listening for HTTPS on port 9000'))
self.assertTrue(waitFor(self.play, 'Listening for HTTPS on port ' + DEFAULTS['http.port']))

step("Send request to https")

browserOpen('https://' + DEFAULTS['host'] + ':' + DEFAULTS['http.port'])
response = browserOpen('https://' + DEFAULTS['host'] + ':' + DEFAULTS['http.port'])

step("check that ssl message is logged")
self.assertTrue(waitFor(self.play, 'I am ssl secured!'))
Expand Down Expand Up @@ -865,10 +862,11 @@ def timeout(process):
timeoutOccurred = True


def killPlay(process, http='http', host=DEFAULTS['host'], port=DEFAULTS['http.port'], ):
print("kill %s" % process.pid)
def killPlay(process, http='http', host=DEFAULTS['host'], port=DEFAULTS['http.port']):
print("kill play PID=%s" % process.pid)
try:
urllib.request.urlopen("{}://{}:{}/@kill".format(http, host, port))
print("Call %s" % "{}://{}:{}/@kill".format(http, host, port))
urllib.request.urlopen("{}://{}:{}/@kill".format(http, host, port), timeout=5)

print("terminate")
process.terminate()
Expand Down Expand Up @@ -899,6 +897,7 @@ def killPlay(process, http='http', host=DEFAULTS['host'], port=DEFAULTS['http.po
print("play is KILLED")
return
except:
print("play is KILLED with exception")
pass


Expand Down

0 comments on commit d99cf34

Please sign in to comment.