Example #1
0
    async def test_verify_authenticated(self):
        http = HttpSession(self.session,
                           'http://127.0.0.1:{0}/'.format(self.server.port))
        handler = srp.SRPAuthHandler()
        handler.initialize(binascii.unhexlify(DEVICE_AUTH_KEY))

        verifier = AuthenticationVerifier(http, handler)
        self.assertTrue((await verifier.verify_authed()))
Example #2
0
    async def test_verify_invalid(self):
        http = HttpSession(self.session,
                           'http://127.0.0.1:{0}/'.format(self.server.port))
        handler = srp.SRPAuthHandler()
        handler.initialize(INVALID_AUTH_KEY)

        verifier = AuthenticationVerifier(http, handler)
        with self.assertRaises(AuthenticationError):
            await verifier.verify_authed()
Example #3
0
    async def test_auth_successful(self):
        http = HttpSession(self.session,
                           'http://127.0.0.1:{0}/'.format(self.server.port))
        handler = srp.SRPAuthHandler()
        handler.initialize(INVALID_AUTH_KEY)

        auther = DeviceAuthenticator(http, handler)
        await auther.start_authentication()
        with self.assertRaises(AuthenticationError):
            await auther.finish_authentication(DEVICE_IDENTIFIER, DEVICE_PIN)
Example #4
0
    async def test_auth_failed(self):
        http = HttpSession(
            self.session, 'http://127.0.0.1:{0}/'.format(self.server.port))
        handler = srp.SRPAuthHandler()
        handler.initialize(binascii.unhexlify(DEVICE_AUTH_KEY))

        auther = DeviceAuthenticator(http, handler)
        await auther.start_authentication()
        self.assertTrue((await auther.finish_authentication(
            DEVICE_IDENTIFIER, DEVICE_PIN)))