예제 #1
0
    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
예제 #2
0
    def testUACPCCWrongPassword(self):
        # create
        keycard = keycards.KeycardUACPCC('user', '127.0.0.1')

        # send
        d = self.wrapper.remote_login(keycard, "avatarId",
                                      'twisted.spread.pb.IPerspective')

        def uacpccWrongPasswordCallback(keycard):
            self.assertEquals(keycard.state, keycards.REQUESTING)
            # respond to challenge
            keycard.setPassword('wrong')
            d = self.wrapper.remote_login(keycard, "avatarId",
                                          'twisted.spread.pb.IPerspective')

            def uacpccWrongPasswordErrback(failure):
                self.assert_(
                    isinstance(failure.type(), errors.NotAuthenticatedError))
                return True

            d.addErrback(uacpccWrongPasswordErrback)
            return d

        d.addCallback(uacpccWrongPasswordCallback)
        return d
예제 #3
0
    def testUACPCCTamperWithChallenge(self):
        # create challenger
        keycard = keycards.KeycardUACPCC('user', '127.0.0.1')
        self.assert_(keycard)
        self.assertEquals(keycard.state, keycards.REQUESTING)

        # submit for auth
        d = self.wrapper.remote_login(keycard, "avatarId",
                                      'twisted.spread.pb.IPerspective')

        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 = self.wrapper.remote_login(keycard, "avatarId",
                                          'twisted.spread.pb.IPerspective')

            def uacpccTamperErrback(failure):
                self.assert_(
                    isinstance(failure.type(), errors.NotAuthenticatedError))

            d.addErrback(uacpccTamperErrback)
            return d

        d.addCallback(uacpccTamperCallback)
        return d
예제 #4
0
    def testUACPPWrongPassword(self):
        keycard = keycards.KeycardUACPCC('user', '127.0.0.1')
        d = self.wrapper.remote_login(keycard, "avatarId",
                                      'twisted.spread.pb.IPerspective')

        def uacppWrongPasswordErrback(wrongpasserror):
            self.assert_(
                isinstance(wrongpasserror.type(),
                           errors.NotAuthenticatedError))

        d.addErrback(uacppWrongPasswordErrback)
        return d
예제 #5
0
    def testTamperWithChallenge(self):
        # create challenger
        keycard = keycards.KeycardUACPCC('user', '127.0.0.1')
        self.assert_(keycard)
        self.assertEquals(keycard.state, keycards.REQUESTING)

        # submit for auth
        d = defer.maybeDeferred(self.bouncer.authenticate, keycard)

        def tamperCallback(result):
            self.assertEquals(result.state, keycards.REQUESTING)
            # mess with challenge, respond to challenge and resubmit
            result.challenge = "I am a h4x0r"
            result.setPassword('test')
            dd = defer.maybeDeferred(self.bouncer.authenticate, keycard)

            def tamperAuthenticateCallback(result):
                self.failIf(result)
            dd.addCallback(tamperAuthenticateCallback)
            return dd
        d.addCallback(tamperCallback)
        return d
예제 #6
0
    def testOk(self):
        # create challenger
        keycard = keycards.KeycardUACPCC('user', '127.0.0.1')
        self.assert_(keycard)
        self.assertEquals(keycard.state, keycards.REQUESTING)

        # submit for auth
        d = defer.maybeDeferred(self.bouncer.authenticate, keycard)

        def okCallback(result):
            self.assertEquals(result.state, keycards.REQUESTING)
            # respond to challenge and resubmit
            result.setPassword('test')
            dd = defer.maybeDeferred(self.bouncer.authenticate, keycard)

            def authenticatedCallback(result):
                self.assertEquals(result.state, keycards.AUTHENTICATED)
            dd.addCallback(authenticatedCallback)
            return dd

        d.addCallback(okCallback)
        return d
예제 #7
0
    def testUACPCCOk(self):
        # create
        keycard = keycards.KeycardUACPCC('user', '127.0.0.1')

        # send
        d = self.wrapper.remote_login(keycard, None,
                                      'twisted.spread.pb.IPerspective')

        def uacpccOkCallback(keycard):
            self.assertEquals(keycard.state, keycards.REQUESTING)
            # respond to challenge
            keycard.setPassword('test')
            d = self.wrapper.remote_login(keycard, None,
                                          'twisted.spread.pb.IPerspective')

            def uacpccOkCallback2(result):
                self.assert_(isinstance(result, tpb.AsReferenceable))
                return result

            d.addCallback(uacpccOkCallback2)
            return d

        d.addCallback(uacpccOkCallback)
        return d
예제 #8
0
파일: pb.py 프로젝트: sharky93/flumotion
 def issue_KeycardUACPCC(self):
     return keycards.KeycardUACPCC(self.username, self.address)