def notestUACPCCTamperWithChallenge(self): factory = pb.FPBClientFactory() # create keycard = keycards.KeycardUACPCC('user', '127.0.0.1') self.assert_(keycard) self.assertEquals(keycard.state, keycards.REQUESTING) # send d = factory.login(keycard, 'MIND') c = reactor.connectTCP("127.0.0.1", self.portno, factory) def uacpccTamperCallback(keycard): self.assertEquals(keycard.state, keycards.REQUESTING) # mess with challenge, respond to challenge and resubmit keycard.challenge = "I am a h4x0r" keycard.setPassword('test') d = factory.login(keycard, 'MIND') def uacpccTamperErrback(failure): # find copied failure self.failUnless( failure.check( "flumotion.common.errors.NotAuthenticatedError")) return self.clientDisconnect(factory, None) d.addErrback(uacpccTamperErrback) return d d.addCallback(uacpccTamperCallback) return d
def testWrongUser(self): factory = pb.FPBClientFactory() # create a = pb.Authenticator(username="******", password="******", address="127.0.0.1") # send d = factory.login(a) c = reactor.connectTCP("127.0.0.1", self.portno, factory) def WrongUserCb(keycard): self.fail("Should have returned NotAuthenticatedError") def WrongUserEb(failure): # find copied failure self.failUnless( failure.check("flumotion.common.errors.NotAuthenticatedError")) return self.clientDisconnect(factory, None) d.addCallback(WrongUserCb) d.addErrback(WrongUserEb) return d
def notestUACPCCWrongPassword(self): factory = pb.FPBClientFactory() # create keycard = keycards.KeycardGeneric() keycard.username = '******' keycard.address = '127.0.0.1' # send d = factory.login(keycard, 'MIND') c = reactor.connectTCP("127.0.0.1", self.portno, factory) def uacpccWrongPasswordCallback(keycard): self.assertEquals(keycard.state, keycards.REQUESTING) # respond to challenge keycard.setPassword('wrongpass') d = factory.login(keycard, 'MIND') def uacpccWrongPasswordErrback(failure): # find copied failure self.failUnless( failure.check( "flumotion.common.errors.NotAuthenticatedError")) return self.clientDisconnect(factory, None) d.addErrback(uacpccWrongPasswordErrback) return d d.addCallback(uacpccWrongPasswordCallback) return d
def notestUACPCCOk(self): factory = pb.FPBClientFactory() # send d = factory.login(self.authenticator, 'MIND') c = reactor.connectTCP("127.0.0.1", self.portno, factory) def uacpccOkCallback(keycard): # get result self.assertEquals(keycard.state, keycards.REQUESTING) # respond to challenge keycard.setPassword('test') d = factory.login(keycard, 'MIND') # check if we have a remote reference def uacpccOkCallback2(result): self.assert_(isinstance(result, tpb.RemoteReference)) return self.clientDisconnect(factory, result) d.addCallback(uacpccOkCallback2) return d d.addCallback(uacpccOkCallback) return d
def testOk(self): factory = pb.FPBClientFactory() a = pb.Authenticator(username="******", password="******", address="127.0.0.1") # send d = factory.login(a) c = reactor.connectTCP("127.0.0.1", self.portno, factory) def OkCallback(result): # make sure we really used an SHA256 challenge/response keycard self.failUnless(isinstance(factory.keycard, keycards.KeycardUASPCC)) self.assert_(isinstance(result, tpb.RemoteReference)) return self.clientDisconnect(factory, result) d.addCallback(OkCallback) return d
def testWrongPassword(self): factory = pb.FPBClientFactory() a = pb.Authenticator(username="******", password="******", address="127.0.0.1") d = factory.login(a) c = reactor.connectTCP("127.0.0.1", self.portno, factory) log.debug("trial", "wait for result") def WrongPasswordErrback(failure): # make sure we really used an SHA256 challenge/response keycard self.failUnless(isinstance(factory.keycard, keycards.KeycardUASPCC)) # This is a CopiedFailure self.assert_( failure.check("flumotion.common.errors.NotAuthenticatedError")) log.debug("trial", "got failure %r" % failure) c.disconnect() return True d.addErrback(WrongPasswordErrback) return d