'L{DigestCredentialFactory.decode} raises L{LoginFailed} when the opaque
value does not contain all the required parts.'

def test_invalidOpaque(self):

    credentialFactory = FakeDigestCredentialFactory(self.algorithm, self.realm)
    challenge = credentialFactory.getChallenge(self.clientAddress.host)
    exc = self.assertRaises(LoginFailed, credentialFactory._verifyOpaque, 'badOpaque', challenge['nonce'], self.clientAddress.host)
    self.assertEqual(str(exc), 'Invalid    response,    invalid    opaque    value')
    badOpaque = ('foo-' + b64encode('nonce,clientip'))
    exc = self.assertRaises(LoginFailed, credentialFactory._verifyOpaque, badOpaque, challenge['nonce'], self.clientAddress.host)
    self.assertEqual(str(exc), 'Invalid    response,    invalid    opaque    value')
    exc = self.assertRaises(LoginFailed, credentialFactory._verifyOpaque, '', challenge['nonce'], self.clientAddress.host)
    self.assertEqual(str(exc), 'Invalid    response,    invalid    opaque    value')
    badOpaque = ('foo-' + b64encode(','.join((challenge['nonce'], networkString(self.clientAddress.host), 'foobar'))))
    exc = self.assertRaises(LoginFailed, credentialFactory._verifyOpaque, badOpaque, challenge['nonce'], self.clientAddress.host)
    self.assertEqual(str(exc), 'Invalid    response,    invalid    opaque/time    values')
