def receive_async_mdn(self, agreement_id=None): if is_none_or_whitespace(agreement_id): headers = { k.lower().replace('_', '-'): v for k, v in self.headers.items() } trading_identity = decode_as2_identity(headers.get('as2-from', '')) local_identity = decode_as2_identity(headers.get('as2-to', '')) agreement = self._get_primary_agreement(local_identity, trading_identity) else: agreement = self._get_agreement(agreement_id) context = AS2Context(agreement, None) self._receive_async_mdn(self.headers, self.body, context)
def _build_received_as2_context(self, id, message): if is_none_or_whitespace(id): headers = { k.lower().replace('_', '-'): v for k, v in self.headers.items() } trading_identity = decode_as2_identity(headers.get('as2-from', '')) local_identity = decode_as2_identity(headers.get('as2-to', '')) agreement = self._get_primary_agreement(local_identity, trading_identity) else: agreement = self._get_agreement(id) message.local_identity = agreement.local_identity message.trading_identity = agreement.trading_identity message.agreement_id = agreement.id return AS2Context(agreement, message)
def test_decode_as2_identity_is_required(self): decode_as2_identity(None)
def test_decode_as2_identity(self, input, expected): actual = decode_as2_identity(input) assert_equal(actual, expected)
def _init_to_identity(self): identity = self.headers.get("as2-to") if is_none_or_whitespace(identity): raise AS2Exception('as2-to is required') self.to_identity = decode_as2_identity(identity.strip())