def test_parsing_rp_ack_with_short_rp_user_data_deliver():
    assert parse(b"\x29\x01\x06\x02\x04\x41\x02\x00\x00") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_DATA,
            "cp_layer_protocol": {
                "length_indicator": 6,
                "spare": None,
                "mti": rp_mti.RP_ACK_MS_TO_N,
                "rp": {
                    "message_reference": 4,
                    "rp_user_data": {
                        "rp_user_data_iei": 0x41,
                        "tpdu": {
                            "tp_udhi": False,
                            "tp_mti": tp_mti.SMS_DELIVER_OR_REPORT,
                            "tp_pi": {
                                "tp_udl": False,
                                "tp_dcs": False,
                                "tp_pid": False
                            },
                            "tp_scts": None,
                            "tp_dcs": None,
                            "tp_pid": None,
                            "tp_ud": None,
                        }
                    }
                }
            }
        }
    }
Esempio n. 2
0
def test_parsing_cp_ack():
    assert parse(b"\x29\x04") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_ACK
        }
    }
Esempio n. 3
0
def test_parsing_sms_submit_without_data_header():
    assert parse(b"\x39\x01\x24\x00\x01\x00\x04\x90\x21\x43\x65\x1b\x09\xcc"
                 b"\x06\x90\x21\x43\x65\x00\x00\x03\x30\x40\x50\x00\x00\x00"
                 b"\x0b\xc4\x32\x3b\x6d\x2f\xcb\x41\xf5\x79\x08") == {
               "transaction_identifier": 3,
               "protocol_discriminator": protocol_discriminator.SMS,
               "l3_protocol": {
                   "message_type": message_type.CP_DATA,
                   "cp_layer_protocol": {
                       "spare": None,
                       "mti": rp_mti.RP_DATA_MS_TO_N,
                       "rp": {
                           "message_reference": 1,
                           "rp_destination_address": {
                               "ext": None,
                               "number": "123456",
                               "number_plan": plan.UNKNOWN,
                               "type_of_number": number_type.INTERNATIONAL_NUMBER
                           },
                           "rp_originator_address": 0,
                           "rp_user_data": {"tpdu": {
                               "tp_rp": False,
                               "tp_udhi": False,
                               "tp_srr": tp_srr.STATUS_REPORT_NOT_REQUESTED,
                               "tp_vpf": tp_vpf.ENHANCED_FORMAT,
                               "tp_rd": tp_rd.ACCEPT,
                               "tp_mti": tp_mti.SMS_SUBMIT_OR_REPORT,
                               "tp_mr": 0xcc,
                               "tp_da": {
                                   "ext": None,
                                   "number": "123456",
                                   "number_plan": plan.UNKNOWN,
                                   "type_of_number": number_type.INTERNATIONAL_NUMBER
                               },
                               "tp_pid": tp_pid.DEFAULT,
                               "tp_dcs": {
                                   "coding_group": dcs_coding_groups.GENERAL_DATA_CODING_INDICATION,
                                   "character_set": dcs_character_set.GSM_7,
                               },
                               "tp_vp": {
                                   "extension_bit": False,
                                   "single_shot_sm": False,
                                   "validity_period_format": tp_vp_enhanced_format.SEMI_OCTET,
                                   "validity_period": {
                                       "hour": 3,
                                       "minute": 4,
                                       "second": 5
                                   }
                               },
                               "tp_ud": {
                                   "user_data_header": None,
                                   "user_data": "Deliver us!"
                               }
                           }}
                       }
                   }
               }
           }
def test_parsing_sms_command_without_data_header():
    assert parse(b"\x39\x01\x1f\x00\x01\x00\x04\x90\x21\x43\x65\x16\x22\xcd"
                 b"\x00\x02\xcc\x06\x90\x21\x43\x65\x0b\x44\x65\x6c\x69\x76"
                 b"\x65\x72\x20\x75\x73\x21") == {
                     "transaction_identifier": 3,
                     "protocol_discriminator": protocol_discriminator.SMS,
                     "l3_protocol": {
                         "message_type": message_type.CP_DATA,
                         "cp_layer_protocol": {
                             "spare": None,
                             "mti": rp_mti.RP_DATA_MS_TO_N,
                             "rp": {
                                 "message_reference": 1,
                                 "rp_destination_address": {
                                     "ext":
                                     None,
                                     "number":
                                     "123456",
                                     "number_plan":
                                     plan.UNKNOWN,
                                     "type_of_number":
                                     number_type.INTERNATIONAL_NUMBER
                                 },
                                 "rp_originator_address": 0,
                                 "rp_user_data": {
                                     "tpdu": {
                                         "tp_udhi": False,
                                         "tp_srr":
                                         tp_srr.STATUS_REPORT_REQUESTED,
                                         "tp_mti":
                                         tp_mti.SMS_STATUS_OR_COMMAND,
                                         "tp_mr": 0xcd,
                                         "tp_pid": tp_pid.DEFAULT,
                                         "tp_ct":
                                         tp_ct.DELETE_PREVIOUSLY_SUBMITTED_SM,
                                         "tp_mn": 0xcc,
                                         "tp_da": {
                                             "ext":
                                             None,
                                             "number":
                                             "123456",
                                             "number_plan":
                                             plan.UNKNOWN,
                                             "type_of_number":
                                             number_type.INTERNATIONAL_NUMBER
                                         },
                                         "tp_cd": {
                                             "user_data_header": None,
                                             "user_data": b"Deliver us!"
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
def test_parsing_cp_error():
    assert parse(b"\x29\x10\x51") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_ERROR,
            "cp_layer_protocol": {
                "cp_cause": cp_cause.INVALID_TID
            }
        }
    }
def test_parsing_rp_smma():
    assert parse(b"\x29\x01\x02\x06\x04") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_DATA,
            "cp_layer_protocol": {
                "length_indicator": 2,
                "spare": None,
                "mti": rp_mti.RP_SMMA,
                "rp": {"message_reference": 4}
            }
        }
    }
def test_parsing_rp_error_full():
    assert parse(b"\x29\x01\x1c\x04\x04\x02\x01\x81\x41\x15\x40\xc3\x07\x20"
                 b"\x04\x0f\x03\x01\x01\xff\x01\x02\x03\x04\x05\x06\x07\x08"
                 b"\x09\x0a\x0b") == {
               "transaction_identifier": 2,
               "protocol_discriminator": protocol_discriminator.SMS,
               "l3_protocol": {
                   "message_type": message_type.CP_DATA,
                   "cp_layer_protocol": {
                       "length_indicator": 2,
                       "spare": None,
                       "mti": rp_mti.RP_ERROR_MS_TO_N,
                       "rp": {
                           "message_reference": 4,
                           "rp_cause": {
                               "ext": None,
                               "cause_value": rp_cause.UNASSIGNED_NUMBER,
                               "diagnostic_field": 0x81
                           },
                           "rp_user_data": {
                               "rp_user_data_iei": 0x41,
                               "tpdu": {
                                   "tp_udhi": True,
                                   "tp_mti": tp_mti.SMS_DELIVER_OR_REPORT,
                                   "tp_fcs": tp_fcs.INVALID_SME_ADDRESS,
                                   "tp_pi": {
                                       "tp_udl": True,
                                       "tp_dcs": True,
                                       "tp_pid": True
                                   },
                                   "tp_dcs": {
                                       "coding_group": dcs_coding_groups.GENERAL_DATA_CODING_INDICATION,
                                       "character_set": dcs_character_set.DATA_8BIT,
                                       "compressed": False
                                   },
                                   "tp_pid": tp_pid.IMPLICIT,
                                   "tp_ud": {
                                       "user_data_header": [
                                           {
                                               "element_type": tp_udh_elements.SPECIAL_SMS_MESSAGE,
                                               "element_data": b"\xff"}
                                       ],
                                       "user_data": b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b"
                                   }
                               }
                           }
                       }
                   }
               }
           }
def test_parsing_rp_ack_full():
    assert parse(
        b"\x29\x01\x1b\x02\x04\x41\x17\x40\x07\x20\x15\x12\x04\x01\x02"
        b"\xff\xff\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d") == {
            "transaction_identifier": 2,
            "protocol_discriminator": protocol_discriminator.SMS,
            "l3_protocol": {
                "message_type": message_type.CP_DATA,
                "cp_layer_protocol": {
                    "length_indicator": 2,
                    "spare": None,
                    "mti": rp_mti.RP_ACK_MS_TO_N,
                    "rp": {
                        "message_reference": 4,
                        "rp_user_data": {
                            "rp_user_data_iei": 0x41,
                            "tpdu": {
                                "tp_udhi": True,
                                "tp_mti": tp_mti.SMS_DELIVER_OR_REPORT,
                                "tp_pi": {
                                    "tp_udl": True,
                                    "tp_dcs": True,
                                    "tp_pid": True
                                },
                                "tp_pid": tp_pid.IMPLICIT,
                                "tp_dcs": {
                                    "coding_group": dcs_coding_groups.
                                    GENERAL_DATA_CODING_INDICATION,
                                    "compressed": False,
                                    "character_set":
                                    dcs_character_set.DATA_8BIT,
                                    "message_class": 1
                                },
                                "tp_ud": {
                                    "user_data_header": [{
                                        "element_type":
                                        tp_udh_elements.SPECIAL_SMS_MESSAGE,
                                        "element_data":
                                        b"\xff\xff"
                                    }],
                                    "user_data": (b"\x01\x02\x03\x04\x05"
                                                  b"\x06\x07\x08\x09\x0a"
                                                  b"\x0b\x0c\x0d")
                                }
                            }
                        }
                    }
                }
            }
        }
def test_parsing_rp_error_with_short_rp_user_data_submit():
    assert parse(b"\x29\x01\x10\x05\x04\x01\x01\x41\x0a\x01\xd2\x00\x81\x90"
                 b"\x10\x32\x60\x00\x8a") == {
               "transaction_identifier": 2,
               "protocol_discriminator": protocol_discriminator.SMS,
               "l3_protocol": {
                   "message_type": message_type.CP_DATA,
                   "cp_layer_protocol": {
                       "length_indicator": 2,
                       "spare": None,
                       "mti": rp_mti.RP_ERROR_N_TO_MS,
                       "rp": {
                           "message_reference": 4,
                           "rp_cause": {
                               "ext": None,
                               "cause_value": rp_cause.UNASSIGNED_NUMBER,
                               "diagnostic_field": None
                           },
                           "rp_user_data": {
                               "rp_user_data_iei": 0x41,
                               "tpdu": {
                                   "tp_udhi": False,
                                   "tp_mti": tp_mti.SMS_SUBMIT_OR_REPORT,
                                   "tp_fcs": tp_fcs.ERROR_IN_MS,
                                   "tp_pi": {
                                       "tp_udl": False,
                                       "tp_dcs": False,
                                       "tp_pid": False
                                   },
                                   "tp_scts": {
                                       "year": 18,
                                       "month": 9,
                                       "day": 1,
                                       "hour": 23,
                                       "minute": 6,
                                       "second": 0,
                                       "gmt": -7
                                   },
                                   "tp_dcs": None,
                                   "tp_pid": None,
                                   "tp_ud": None,
                               }
                           }
                       }
                   }
               }
           }
Esempio n. 10
0
def test_parsing_rp_ack_to_ms():
    assert parse(b"\x29\x01\x02\x03\x04") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_DATA,
            "cp_layer_protocol": {
                "length_indicator": 2,
                "spare": None,
                "mti": rp_mti.RP_ACK_N_TO_MS,
                "rp": {
                    "message_reference": 4,
                    "rp_user_data": None
                }
            }
        }
    }
Esempio n. 11
0
def test_parsing_rp_ack_with_short_rp_user_data_submit():
    assert parse(b"\x29\x01\x0d\x03\x04\x41\x09\x01\x00\x81\x90\x10\x32\x60"
                 b"\x00\x8a") == {
                     "transaction_identifier": 2,
                     "protocol_discriminator": protocol_discriminator.SMS,
                     "l3_protocol": {
                         "message_type": message_type.CP_DATA,
                         "cp_layer_protocol": {
                             "length_indicator": 2,
                             "spare": None,
                             "mti": rp_mti.RP_ACK_N_TO_MS,
                             "rp": {
                                 "message_reference": 4,
                                 "rp_user_data": {
                                     "rp_user_data_iei": 0x41,
                                     "tpdu": {
                                         "tp_udhi": False,
                                         "tp_mti": tp_mti.SMS_SUBMIT_OR_REPORT,
                                         "tp_pi": {
                                             "tp_udl": False,
                                             "tp_dcs": False,
                                             "tp_pid": False
                                         },
                                         "tp_scts": {
                                             "year": 18,
                                             "month": 9,
                                             "day": 1,
                                             "hour": 23,
                                             "minute": 6,
                                             "second": 0,
                                             "gmt": -7
                                         },
                                         "tp_dcs": None,
                                         "tp_pid": None,
                                         "tp_ud": None,
                                     }
                                 }
                             }
                         }
                     }
                 }
def test_parsing_rp_error_with_diagnostic_field():
    assert parse(b"\x29\x01\x05\x05\x04\x02\x01\x80") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_DATA,
            "cp_layer_protocol": {
                "length_indicator": 2,
                "spare": None,
                "mti": rp_mti.RP_ERROR_N_TO_MS,
                "rp": {
                    "message_reference": 4,
                    "rp_cause": {
                        "ext": None,
                        "cause_value": rp_cause.UNASSIGNED_NUMBER,
                        "diagnostic_field": 0x80
                    },
                    "rp_user_data": None
                }
            }
        }
    }
def test_parsing_minimal_rp_error():
    assert parse(b"\x29\x01\x04\x05\x04\x01\x29") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_DATA,
            "cp_layer_protocol": {
                "length_indicator": 2,
                "spare": None,
                "mti": rp_mti.RP_ERROR_N_TO_MS,
                "rp": {
                    "message_reference": 4,
                    "rp_cause": {
                        "ext": None,
                        "cause_value": rp_cause.TEMPORARY_FAILIURE,
                        "diagnostic_field": None
                    },
                    "rp_user_data": None
                }
            }
        }
    }
def test_parsing_rp_error_with_short_rp_user_data_deliver():
    assert parse(b"\x29\x01\x09\x04\x04\x01\x01\x41\x03\x00\xd2\x00") == {
        "transaction_identifier": 2,
        "protocol_discriminator": protocol_discriminator.SMS,
        "l3_protocol": {
            "message_type": message_type.CP_DATA,
            "cp_layer_protocol": {
                "length_indicator": 2,
                "spare": None,
                "mti": rp_mti.RP_ERROR_MS_TO_N,
                "rp": {
                    "message_reference": 4,
                    "rp_cause": {
                        "ext": None,
                        "cause_value": rp_cause.UNASSIGNED_NUMBER,
                        "diagnostic_field": None
                    },
                    "rp_user_data": {
                        "rp_user_data_iei": 0x41,
                        "tpdu": {
                            "tp_udhi": False,
                            "tp_mti": tp_mti.SMS_DELIVER_OR_REPORT,
                            "tp_fcs": tp_fcs.ERROR_IN_MS,
                            "tp_pi": {
                                "tp_udl": False,
                                "tp_dcs": False,
                                "tp_pid": False
                            },
                            "tp_scts": None,
                            "tp_dcs": None,
                            "tp_pid": None,
                            "tp_ud": None,
                        }
                    }
                }
            }
        }
    }
Esempio n. 15
0
def test_parsing_sms_submit_with_data_header():
    assert parse(b"\x39\x01\x2a\x00\x01\x00\x04\x90\x3a\x36\xf9\x21\x59\xcc"
                 b"\x05\x90\x3a\x36\xf9\x00\x00\x81\x90\x10\x32\x60\x00\x80"
                 b"\x12\x05\x00\x03\x03\x02\x01\x88\x65\x76\xda\x5e\x96\x83"
                 b"\xea\xf3\x10") == {
               "transaction_identifier": 3,
               "protocol_discriminator": protocol_discriminator.SMS,
               "l3_protocol": {
                   "message_type": message_type.CP_DATA,
                   "cp_layer_protocol": {
                       "spare": None,
                       "mti": rp_mti.RP_DATA_MS_TO_N,
                       "rp": {
                           "message_reference": 1,
                           "rp_destination_address": {
                               "ext": None,
                               "number": "*3639",
                               "number_plan": plan.UNKNOWN,
                               "type_of_number": number_type.INTERNATIONAL_NUMBER
                           },
                           "rp_originator_address": 0,
                           "rp_user_data": {"tpdu": {
                               "tp_rp": False,
                               "tp_udhi": True,
                               "tp_srr": tp_srr.STATUS_REPORT_NOT_REQUESTED,
                               "tp_vpf": tp_vpf.ABSOLUTE_FORMAT,
                               "tp_rd": tp_rd.ACCEPT,
                               "tp_mti": tp_mti.SMS_SUBMIT_OR_REPORT,
                               "tp_mr": 0xcc,
                               "tp_da": {
                                   "ext": None,
                                   "number": "*3639",
                                   "number_plan": plan.UNKNOWN,
                                   "type_of_number": number_type.INTERNATIONAL_NUMBER
                               },
                               "tp_pid": tp_pid.DEFAULT,
                               "tp_dcs": {
                                   "coding_group": dcs_coding_groups.GENERAL_DATA_CODING_INDICATION,
                                   "character_set": dcs_character_set.GSM_7,
                               },
                               "tp_vp": {
                                   "day": 1,
                                   "gmt": 2.0,
                                   "hour": 23,
                                   "minute": 6,
                                   "month": 9,
                                   "second": 0,
                                   "year": 18
                               },
                               "tp_ud": {
                                   "user_data_header": [
                                       {
                                           "element_type": tp_udh_elements.CONCATENATED_SHORT_MESSAGES_8_BIT,
                                           "element_data": b"\x03\x02\x01"
                                       }
                                   ],
                                   "user_data": "Deliver us!"
                               }
                           }}
                       }
                   }
               }
           }
Esempio n. 16
0
def test_parsing_sms_deliver_with_data_header():
    assert parse(
        b"\x39\x01\x29\x01\x01\x04\x90\x21\x43\x65\x00\x20\x64\x06"
        b"\x90\x21\x43\x65\x00\x00\x81\x90\x10\x32\x60\x00\x80\x12"
        b"\x05\x00\x03\x03\x02\x01\x88\x65\x76\xda\x5e\x96\x83\xea"
        b"\xf3\x10") == {
            "transaction_identifier": 3,
            "protocol_discriminator": protocol_discriminator.SMS,
            "l3_protocol": {
                "message_type": message_type.CP_DATA,
                "cp_layer_protocol": {
                    "spare": None,
                    "mti": rp_mti.RP_DATA_N_TO_MS,
                    "rp": {
                        "message_reference": 1,
                        "rp_originator_address": {
                            "ext": None,
                            "number": "123456",
                            "number_plan": plan.UNKNOWN,
                            "type_of_number": number_type.INTERNATIONAL_NUMBER
                        },
                        "rp_destination_address": 0,
                        "rp_user_data": {
                            "tpdu": {
                                "tp_rp":
                                False,
                                "tp_udhi": True,
                                "tp_sri":
                                tp_sri.STATUS_REPORT_SHALL_BE_RETURNED,
                                "tp_lp": tp_lp.NOT_FORWARDED_OR_SPAWNED,
                                "tp_mms": tp_mms.NO_MORE_MESSAGES_ARE_WAITING,
                                "tp_mti": tp_mti.SMS_DELIVER_OR_REPORT,
                                "tp_oa": {
                                    "ext":
                                    None,
                                    "number":
                                    "123456",
                                    "number_plan":
                                    plan.UNKNOWN,
                                    "type_of_number":
                                    number_type.INTERNATIONAL_NUMBER
                                },
                                "tp_pid": tp_pid.DEFAULT,
                                "tp_dcs": {
                                    "coding_group": dcs_coding_groups.
                                    GENERAL_DATA_CODING_INDICATION,
                                    "character_set": dcs_character_set.GSM_7,
                                },
                                "tp_scts": {
                                    "day": 1,
                                    "gmt": 2.0,
                                    "hour": 23,
                                    "minute": 6,
                                    "month": 9,
                                    "second": 0,
                                    "year": 18
                                },
                                "tp_ud": {
                                    "user_data_header": [{
                                        "element_type":
                                        tp_udh_elements.
                                        CONCATENATED_SHORT_MESSAGES_8_BIT,
                                        "element_data":
                                        b"\x03\x02\x01"
                                    }],
                                    "user_data":
                                    "Deliver us!"
                                }
                            }
                        }
                    }
                }
            }
        }