Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package libnas
- import (
- "bytes"
- "testing"
- )
- func TestNewAttachAccept(t *testing.T) {
- xMsg := TEmmAttachAccept{
- ProtocolDiscriminator: PROTOCOL_DISCRIMINATOR_EPS_MOBILITY_MANAGEMENT_MESSAGES,
- SecurityHeaderType: NAS_SECURITY_PLAIN_NAS_MESSAGE,
- MessageType: NAS_EMM_MESSAGE_TYPE_ATTACH_ACCEPT,
- EpsAttachResult: NAS_EPS_ATTACH_RESULT_COMBINED_EPS_IMSI_ATTACH,
- Spare: 0,
- Timer3412value: 0x49,
- //TaiList: []byte{0x2, 0x52, 0xf0, 0x99, 0x8e, 0x58, 0x8d, 0xf4, 0x8d, 0x2c},
- TaiList: TIeTaiList{
- taiList: []tTai{
- {
- plmn: []byte{0x52, 0xf0, 0x99},
- tac: 0x8e58,
- },
- {
- plmn: []byte{0x52, 0xf0, 0x99},
- tac: 0x8df4,
- },
- {
- plmn: []byte{0x52, 0xf0, 0x99},
- tac: 0x8d2c,
- },
- },
- },
- EsmMessageContainer: []byte{0x52, 0x1, 0xc1, 0x1, 0x9, 0x27, 0x8, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
- 0x65, 0x74, 0x7, 0x62, 0x65, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x2, 0x72, 0x75, 0x6, 0x6d, 0x6e, 0x63, 0x30,
- 0x39, 0x39, 0x6, 0x6d, 0x63, 0x63, 0x32, 0x35, 0x30, 0x4, 0x67, 0x70, 0x72, 0x73, 0x5, 0x1, 0xa, 0x46, 0xda,
- 0x23, 0x5d, 0x1, 0x0, 0x30, 0x10, 0x23, 0x92, 0x1f, 0x91, 0x97, 0xfe, 0xfe, 0x46, 0x48, 0x0, 0x0, 0x0, 0xfa,
- 0x0, 0xde, 0x0, 0x32, 0x3, 0x82, 0x5e, 0x6, 0xfe, 0xfe, 0x96, 0xde, 0x2, 0x0, 0x58, 0x32, 0x27, 0x28, 0x80,
- 0x80, 0x21, 0xa, 0x3, 0x0, 0x0, 0xa, 0x81, 0x6, 0x55, 0xf9, 0x16, 0xf8, 0x0, 0xd, 0x4, 0x55, 0xf9, 0x16,
- 0xf8, 0x0, 0x3, 0x10, 0x20, 0x1, 0x48, 0x60, 0x48, 0x60, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x88, 0x88},
- Guti: &[]byte{0xf6, 0x52, 0xf0, 0x99, 0x80, 0x3, 0xc8, 0xc2, 0x1, 0xca, 0x19},
- LocationAreaIdentification: &[]byte{0x52, 0xf0, 0x99, 0xa5, 0x0},
- MsIdentity: &[]byte{0xf4, 0x6d, 0x50, 0xc0, 0x15},
- EmmCause: nil,
- Timer3402: &[]byte{0x2c},
- Timer3423: &[]byte{0x2c},
- EquivalentPLMNs: nil,
- EmergencyNumberList: nil,
- EpsNetworkFeature: &[]byte{0x01},
- AdditionalUpdateResults: &[]byte{0},
- }
- a, err := MarshalNasPdu(&xMsg)
- if err != nil {
- t.Error(err)
- }
- nas, err := NewNAS(a, nil, nil, DIRECTION_DOWNLINK)
- if err != nil {
- t.Error(err)
- }
- var mt TNAS_MESSAGE_TYPE
- if mt, err = nas.Type(); err != nil {
- t.Error(err)
- }
- if mt != NAS_EMM_MESSAGE_TYPE_ATTACH_ACCEPT {
- t.Errorf("Wrong MessageType, expected %d but %d found", NAS_EMM_MESSAGE_TYPE_ATTACH_ACCEPT, mt)
- }
- var msg *TEmmAttachAccept
- var ok bool
- if msg, ok = nas.NasMsg.(*TEmmAttachAccept); !ok {
- t.Error("NasMsg is not a TEmmAttachAccept but a must")
- }
- if msg == nil {
- t.Fatalf("msg is nil")
- }
- if bytes.Compare(msg.EsmMessageContainer, xMsg.EsmMessageContainer) != 0 {
- t.Error("Wrong EsmMessageContainer")
- }
- if msg.ProtocolDiscriminator != xMsg.ProtocolDiscriminator {
- t.Error("Wrong ProtocolDiscriminator")
- }
- if msg.SecurityHeaderType != xMsg.SecurityHeaderType {
- t.Error("Wrong SecurityHeaderType")
- }
- if msg.MessageType != xMsg.MessageType {
- t.Error("Wrong MessageType")
- }
- if msg.EpsAttachResult != xMsg.EpsAttachResult {
- t.Error("Wrong EpsAttachResult")
- }
- if msg.Timer3412value != xMsg.Timer3412value {
- t.Error("Wrong Timer3412value")
- }
- if bytes.Compare(*msg.Guti, *xMsg.Guti) != 0 {
- t.Error("Wrong Guti")
- }
- if bytes.Compare(*msg.LocationAreaIdentification, *xMsg.LocationAreaIdentification) != 0 {
- t.Error("Wrong LocationAreaIdentification")
- }
- if bytes.Compare(*msg.MsIdentity, *xMsg.MsIdentity) != 0 {
- t.Error("Wrong MsIdentity")
- }
- if msg.EmmCause != xMsg.EmmCause {
- t.Error("Wrong EmmCause")
- }
- if bytes.Compare(*msg.Timer3402, *xMsg.Timer3402) != 0 {
- t.Error("Wrong Timer3402")
- }
- if bytes.Compare(*msg.Timer3423, *xMsg.Timer3423) != 0 {
- t.Error("Wrong Timer3423")
- }
- if bytes.Compare(*msg.EpsNetworkFeature, *xMsg.EpsNetworkFeature) != 0 {
- t.Error("Wrong EpsNetworkFeature")
- }
- if bytes.Compare(*msg.AdditionalUpdateResults, *xMsg.AdditionalUpdateResults) != 0 {
- t.Error("Wrong AdditionalUpdateResults")
- }
- if len(msg.TaiList.taiList) != len(xMsg.TaiList.taiList) {
- t.Error("Length of taiList should be the same!")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement