'When L{HTTPAuthSessionWrapper} finds an L{ICredentialFactory} to issue
a challenge, it calls the C{getChallenge} method with the request as an
argument.'

def test_getChallengeCalledWithRequest(self):

    @implementer(ICredentialFactory)
    class DumbCredentialFactory(object, ):
        scheme = 'dumb'
        def __init__(self):
            self.requests = []
        def getChallenge(self, request):
            self.requests.append(request)
            return {}
    factory = DumbCredentialFactory()
    self.credentialFactories.append(factory)
    request = self.makeRequest([self.childName])
    child = getChildForRequest(self.wrapper, request)
    d = request.notifyFinish()
    def cbFinished(ignored):
        self.assertEqual(factory.requests, [request])
    d.addCallback(cbFinished)
    request.render(child)
    return d
