def fake_find_as2_message(condition, doc_type, match_tag=True): msg = AS2Message(key='123456789') result = CloudStoreQueryResult() result.page_size = 1 result.page_index = 1 result.total_count = 1 result.succeeded = True result.records = [msg] return result
def test_save_failed_message_folder_is_exists(self, mock_file_exists): mock_file_exists.return_value = True with mock.patch("__builtin__.open", mock.mock_open(read_data="data")) as fp: Monitor.save_failed_message( "NgAS2_Inbound_Message", "4ediuse0nly", {"Environment": "GDEV"}, AS2Message(key="1232456"), True )
def _create_received_message(self): mdn_message_id = generate_as2_message_id() message = AS2Message(key=str(uuid.uuid4()).upper(), business_id=None, message_id=None, direction=DirectionType.inbound, agreement_id=None, local_identity=None, trading_identity=None, version=ngas2.__version__, received_headers=[ NameValuePair(name=k, value=v) for k, v in self.headers.items() ], received_data_dfs_path=None, sent_headers=None, sent_data_dfs_path=None, message_status=None, message_mdn=AS2MessageMdn( mdn_message_id=mdn_message_id, direction=DirectionType.outbound, original_message_id=None, mdn_status=StatusType.waiting, mdn_mode=None, mdn_validate_status=None, mdn_disposition_mode=None, mdn_disposition_type=None, mdn_disposition_modifier_code=None, mdn_disposition_modifier_value=None, mdn_disposition_description=None, mdn_headers=None, mdn_data_dfs_path=None, mdn_mic_digest=None, mdn_mic_algorithm=None, in_date=datetime.utcnow(), edit_date=datetime.utcnow()), message_mdn_status=StatusType.waiting, message_is_mic=False, message_mic_digest=None, message_mic_algorithm=None, message_trace_list=None, memo=None, in_date=datetime.utcnow(), edit_date=datetime.utcnow(), in_user=ngas2.__title__) return message
def test_as2_message_send_ok(self, mock_msg_send): mock_msg_send.return_value = AS2Message(key='123') resp = as2_svc.post_message_send('ngas2') assert_not_equal(None, resp) assert_equal(200, resp.status_code) mock_msg_send.assert_called_with()
def get_as2_context(self): pb_cert = Certificate( id="1", subject="AS2.SelfTesting.Newegg.com", thumbprint="B7A5ED759898822397CCCE96BD493D3203CE83AC", type=CertificateType.public, description="Newegg Production Test Cert", dfs_file_path= "http://neg-app-img/EaaS/Certificate/B7A5ED759898822397CCCE96BD493D3203CE83AC.cer", local_file_path=self._get_public_cert_path( "B7A5ED759898822397CCCE96BD493D3203CE83AC.pem"), dfs_ca_file_path=None, local_ca_file_path=None, pass_phrase=None, is_need_verify=True) pr_cert = Certificate( id="2", subject="Tp1 private", thumbprint="CB17BDDF500C14A049C3A18D6A292174B27F198E", type=CertificateType.private, description="TP1 private Cert", dfs_file_path= "http://neg-app-img/EaaS/Certificate/CB17BDDF500C14A049C3A18D6A292174B27F198E.cer", local_file_path=self._get_private_cert_path( "CB17BDDF500C14A049C3A18D6A292174B27F198E.pem"), dfs_ca_file_path=None, local_ca_file_path=None, pass_phrase="123456", is_need_verify=True) out_agr = OutboundAgreement( is_signed=True, is_compressed=False, is_encrypted=True, target_url="http://10.16.86.29:9009/as2-test/receive", message_encryption_certificate=pb_cert, message_encryption_algorithm=EncryptionAlgorithm.des_3, message_signature_certificate=pr_cert, message_signature_algorithm=SignatureAlgorithm.sha_1, message_content_type=MessageContentType.edi_x12, is_request_mdn=True, mdn_mode=MdnMode.sync, is_mdn_signed=True, mdn_signature_algorithm=SignatureAlgorithm.sha_1, async_mdn_url=None, disposition_notification_to="*****@*****.**") in_agr = InboundAgreement( is_signed=True, is_compressed=False, is_encrypted=True, message_decrypt_certificate=pr_cert, message_verify_certificate=pb_cert, message_content_type=MessageContentType.edi_x12, mdn_confirmation_text='', is_request_mdn=True, mdn_mode=MdnMode.sync, is_mdn_signed=True, mdn_signature_algorithm=SignatureAlgorithm.sha_1, async_mdn_url=None) agr = Agreement(id="1", name="Tr_Newegg_Agreement_1", is_primary=True, local_identity="pyas2_01", trading_identity="Newegg", local_partner_id="1", trading_partner_id="1", inbound_agreement=in_agr, outbound_agreement=out_agr, status=AgreementStatus.active) as2_message = AS2Message( key="1", business_id="", message_id=email.utils.make_msgid().strip('<>'), direction="outbound") ctx = AS2Context(agr, as2_message) return ctx