Skip to content

Commit

Permalink
Revert "twisted.spread.test_pb.NewCredTests becomes a SynchronousTest…
Browse files Browse the repository at this point in the history
…Case"

This reverts commit 5c19886.

This is reverted because SynchronousTestCase exposes bugs in PB's
error handling that will be handled under a different ticket.
  • Loading branch information
markrwilliams committed Sep 13, 2016
1 parent 2192b83 commit 1db8a2a
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions src/twisted/spread/test/test_pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ def connectionLost(_):



class NewCredTests(unittest.SynchronousTestCase):
class NewCredTests(unittest.TestCase):
"""
Tests related to the L{twisted.cred} support in PB.
"""
Expand Down Expand Up @@ -1386,7 +1386,7 @@ def disconnect(rootObj):
rootObjDeferred.addCallback(gotRootObject)
rootObjDeferred.addCallback(disconnect)

self.successResultOf(rootObjDeferred)
return rootObjDeferred


def test_deadReferenceError(self):
Expand All @@ -1413,8 +1413,7 @@ def lostConnection(ign):

return disconnectedDeferred

rootObjDeferred.addCallback(gotRootObject)
self.successResultOf(rootObjDeferred)
return rootObjDeferred.addCallback(gotRootObject)


def test_clientConnectionLost(self):
Expand Down Expand Up @@ -1462,8 +1461,7 @@ def gotAnotherRootObject(anotherRootObj):
return d.addCallback(gotAnotherRootObject)
return d.addCallback(disconnected)

rootObjDeferred.addCallback(gotRootObject)
self.successResultOf(rootObjDeferred)
return rootObjDeferred.addCallback(gotRootObject)


def test_immediateClose(self):
Expand All @@ -1490,9 +1488,7 @@ def test_loginConnectionRefused(self):
None,
failure.Failure(
ConnectionRefusedError("Test simulated refused connection")))

loginFailure = self.failureResultOf(loginDeferred)
loginFailure.trap(ConnectionRefusedError)
return self.assertFailure(loginDeferred, ConnectionRefusedError)


def test_loginLogout(self):
Expand Down Expand Up @@ -1539,8 +1535,7 @@ def cbLogout(ignored):
self.pump.flush()
# Now allow the client to disconnect.
loginCompleted.callback(None)

self.successResultOf(loginCompleted)
return d


def test_logoutAfterDecref(self):
Expand Down Expand Up @@ -1590,8 +1585,7 @@ def cbLoggedOut(ignored):
gc.collect()
# push their decref messages through
self.pump.flush()

self.successResultOf(d)
return d


def test_concurrentLogin(self):
Expand Down Expand Up @@ -1623,7 +1617,7 @@ def cbAvatarIds(x):
self.establishClientAndServer()
self.pump.flush()

self.successResultOf(d)
return d


def test_badUsernamePasswordLogin(self):
Expand All @@ -1639,17 +1633,19 @@ def test_badUsernamePasswordLogin(self):
secondLogin = self.clientFactory.login(
credentials.UsernamePassword(b'user', b'wrongpass'))

self.establishClientAndServer()
self.pump.flush()
self.assertFailure(firstLogin, UnauthorizedLogin)
self.assertFailure(secondLogin, UnauthorizedLogin)
d = gatherResults([firstLogin, secondLogin])

firstLoginFailure = self.failureResultOf(firstLogin)
secondLoginFailure = self.failureResultOf(secondLogin)
def cleanup(ignore):
errors = self.flushLoggedErrors(UnauthorizedLogin)
self.assertEqual(len(errors), 2)
d.addCallback(cleanup)

firstLoginFailure.trap(UnauthorizedLogin)
secondLoginFailure.trap(UnauthorizedLogin)
self.establishClientAndServer()
self.pump.flush()

errors = self.flushLoggedErrors(UnauthorizedLogin)
self.assertEqual(len(errors), 2)
return d


def test_anonymousLogin(self):
Expand All @@ -1669,8 +1665,7 @@ def cbLoggedIn(perspective):

self.establishClientAndServer()
self.pump.flush()

self.successResultOf(d)
return d


def test_anonymousLoginNotPermitted(self):
Expand All @@ -1681,15 +1676,17 @@ def test_anonymousLoginNotPermitted(self):
self.portal.registerChecker(
checkers.InMemoryUsernamePasswordDatabaseDontUse(user='pass'))
d = self.clientFactory.login(credentials.Anonymous(), "BRAINS!")
self.assertFailure(d, UnhandledCredentials)

def cleanup(ignore):
errors = self.flushLoggedErrors(UnhandledCredentials)
self.assertEqual(len(errors), 1)
d.addCallback(cleanup)

self.establishClientAndServer()
self.pump.flush()

loginFailure = self.failureResultOf(d)
loginFailure.trap(UnhandledCredentials)

errors = self.flushLoggedErrors(UnhandledCredentials)
self.assertEqual(len(errors), 1)
return d


def test_anonymousLoginWithMultipleCheckers(self):
Expand All @@ -1711,7 +1708,7 @@ def cbLogin(perspective):
self.establishClientAndServer()
self.pump.flush()

self.successResultOf(d)
return d


def test_authenticatedLoginWithMultipleCheckers(self):
Expand All @@ -1734,7 +1731,7 @@ def cbLogin(perspective):
self.establishClientAndServer()
self.pump.flush()

self.successResultOf(d)
return d


def test_view(self):
Expand All @@ -1760,7 +1757,7 @@ def cbView(viewpoint):
self.establishClientAndServer()
self.pump.flush()

self.successResultOf(d)
return d



Expand Down

0 comments on commit 1db8a2a

Please sign in to comment.