예제 #1
0
파일: pairing.py 프로젝트: postlund/pyatv
    async def finish(self) -> None:
        """Stop pairing process."""
        if not self.pairing_procedure:
            raise exceptions.PairingError("pairing was not started")
        if not self.pin_code:
            raise exceptions.PairingError("no pin given")

        self.service.credentials = str(await error_handler(
            self.pairing_procedure.finish_pairing,
            exceptions.PairingError,
            "",
            self.pin_code,
        ))
        self._has_paired = True
예제 #2
0
    async def finish(self) -> None:
        """Stop pairing process."""
        if not self.pairing_procedure:
            raise exceptions.PairingError("pairing was not started")
        if not self.pin_code:
            raise exceptions.PairingError("no pin given")

        self.service.credentials = str(
            await error_handler(
                self.pairing_procedure.finish_pairing,
                exceptions.PairingError,
                binascii.hexlify(self.credentials.identifier).decode("ascii").upper(),
                self.pin_code,
            )
        )
        self._has_paired = True
예제 #3
0
async def test_user_start_pair_error_failed(flow, mrp_device, pairing_mock):
    """Test initiating pairing fails."""
    pairing_mock.begin.side_effect = exceptions.PairingError()

    (await flow().step_user(identifier="MRP Device")).gives_form_confirm(
        description_placeholders={"name": "MRP Device"})

    (await flow().step_confirm()).gives_abort("auth")
예제 #4
0
    async def finish(self):
        """Stop pairing process."""
        if not self.pin_code:
            raise exceptions.PairingError('no pin given')

        self.service.credentials = str(await error_handler(
            self.pairing_procedure.finish_pairing, exceptions.PairingError,
            self.pin_code))
예제 #5
0
    async def finish(self):
        """Stop pairing process."""
        if not self.pin_code:
            raise exceptions.PairingError('no pin given')

        await error_handler(self.auther.finish_authentication,
                            exceptions.PairingError, self.auth_data.identifier,
                            self.pin_code)

        self.service.credentials = self.auth_data.credentials
        self.pairing_complete = True
예제 #6
0
async def test_user_pair_invalid_pin(flow, mrp_device, pairing_mock):
    """Test pairing with invalid pin."""
    pairing_mock.begin.return_value = mock_coro()
    pairing_mock.finish.side_effect = exceptions.PairingError()

    (await flow().step_user(identifier="MRP Device")).gives_form_confirm(
        description_placeholders={"name": "MRP Device"})

    (await flow().step_confirm()).gives_form_pair_with_pin()

    (await flow().step_pair_with_pin(pin=1111)).gives_form_pair_with_pin(
        errors={"base": "auth"})
예제 #7
0
파일: pairing.py 프로젝트: NebzHB/pyatv
    async def finish(self) -> None:
        """Stop pairing process."""
        _LOGGER.debug("Finish pairing Companion")
        if not self.pin_code:
            raise exceptions.PairingError("no pin given")

        self.service.credentials = str(await error_handler(
            self.pairing_procedure.finish_pairing,
            exceptions.PairingError,
            self.pin_code,
        ))
        self._has_paired = True
예제 #8
0
    async def finish(self):
        """Stop pairing process."""
        if not self.pin_code:
            raise exceptions.PairingError("no pin given")

        credentials = str(await error_handler(
            self.pairing_procedure.finish_pairing,
            exceptions.PairingError,
            self.pin_code,
        ))

        _LOGGER.debug("Verifying credentials %s", credentials)

        verifier = MrpPairingVerifier(self.protocol, self.srp,
                                      Credentials.parse(credentials))
        await error_handler(verifier.verify_credentials,
                            exceptions.PairingError)

        self.service.credentials = credentials
        self._has_paired = True