@@ -6,8 +6,10 @@ import (
66 "testing"
77
88 "github.com/stretchr/testify/require"
9+ "gotest.tools/v3/assert"
910
1011 "github.com/free5gc/aper"
12+ "github.com/free5gc/ngap/ngapConvert"
1113 "github.com/free5gc/ngap/ngapType"
1214)
1315
@@ -347,3 +349,148 @@ func TestDecoder(t *testing.T) {
347349 })
348350 }
349351}
352+
353+ func TestCorrectAperReferenceFieldValueSetting (t * testing.T ) {
354+ testCases := []struct {
355+ name string
356+ pdu interface {}
357+ }{
358+ {
359+ name : "PathSwitchRequestTransferWithAdditionalDLQosFlowPerTNLInformation" ,
360+ pdu : ngapType.PathSwitchRequestTransfer {
361+ DLNGUUPTNLInformation : ngapType.UPTransportLayerInformation {
362+ Present : ngapType .UPTransportLayerInformationPresentGTPTunnel ,
363+ GTPTunnel : & ngapType.GTPTunnel {
364+ GTPTEID : ngapType.GTPTEID {
365+ Value : aper.OctetString {0x00 , 0x00 , 0x00 , 0x01 },
366+ },
367+ TransportLayerAddress : ngapConvert .IPAddressToNgap ("127.0.0.1" , "" ),
368+ },
369+ },
370+ QosFlowAcceptedList : ngapType.QosFlowAcceptedList {
371+ List : []ngapType.QosFlowAcceptedItem {
372+ {
373+ QosFlowIdentifier : ngapType.QosFlowIdentifier {
374+ Value : 1 ,
375+ },
376+ },
377+ },
378+ },
379+ IEExtensions : & ngapType.ProtocolExtensionContainerPathSwitchRequestTransferExtIEs {
380+ List : []ngapType.PathSwitchRequestTransferExtIEs {
381+ {
382+ Id : ngapType.ProtocolExtensionID {
383+ Value : ngapType .ProtocolIEIDAdditionalDLQosFlowPerTNLInformation ,
384+ },
385+ Criticality : ngapType.Criticality {
386+ Value : ngapType .CriticalityPresentIgnore ,
387+ },
388+ ExtensionValue : ngapType.PathSwitchRequestTransferExtIEsExtensionValue {
389+ Present : ngapType .PathSwitchRequestTransferExtIEsPresentAdditionalDLQosFlowPerTNLInformation ,
390+ AdditionalDLQosFlowPerTNLInformation : & ngapType.QosFlowPerTNLInformationList {
391+ List : []ngapType.QosFlowPerTNLInformationItem {
392+ {
393+ QosFlowPerTNLInformation : ngapType.QosFlowPerTNLInformation {
394+ UPTransportLayerInformation : ngapType.UPTransportLayerInformation {
395+ Present : ngapType .UPTransportLayerInformationPresentGTPTunnel ,
396+ GTPTunnel : & ngapType.GTPTunnel {
397+ GTPTEID : ngapType.GTPTEID {
398+ Value : aper.OctetString {0x00 , 0x00 , 0x00 , 0x01 },
399+ },
400+ TransportLayerAddress : ngapConvert .IPAddressToNgap ("127.0.0.1" , "" ),
401+ },
402+ },
403+ AssociatedQosFlowList : ngapType.AssociatedQosFlowList {
404+ List : []ngapType.AssociatedQosFlowItem {
405+ {
406+ QosFlowIdentifier : ngapType.QosFlowIdentifier {
407+ Value : 1 ,
408+ },
409+ },
410+ },
411+ },
412+ },
413+ },
414+ },
415+ },
416+ },
417+ },
418+ },
419+ },
420+ },
421+ },
422+ {
423+ name : "PathSwitchRequestAcknowledgeTransferWithAdditionalNGUUPTNLInformation" ,
424+ pdu : ngapType.PathSwitchRequestAcknowledgeTransfer {
425+ ULNGUUPTNLInformation : & ngapType.UPTransportLayerInformation {
426+ Present : ngapType .UPTransportLayerInformationPresentGTPTunnel ,
427+ GTPTunnel : & ngapType.GTPTunnel {
428+ GTPTEID : ngapType.GTPTEID {
429+ Value : aper.OctetString {0x00 , 0x00 , 0x00 , 0x01 },
430+ },
431+ TransportLayerAddress : ngapConvert .IPAddressToNgap ("127.0.0.1" , "" ),
432+ },
433+ },
434+ IEExtensions : & ngapType.ProtocolExtensionContainerPathSwitchRequestAcknowledgeTransferExtIEs {
435+ List : []ngapType.PathSwitchRequestAcknowledgeTransferExtIEs {
436+ {
437+ Id : ngapType.ProtocolExtensionID {
438+ Value : ngapType .ProtocolIEIDAdditionalNGUUPTNLInformation ,
439+ },
440+ Criticality : ngapType.Criticality {
441+ Value : ngapType .CriticalityPresentIgnore ,
442+ },
443+ ExtensionValue : ngapType.PathSwitchRequestAcknowledgeTransferExtIEsExtensionValue {
444+ Present : ngapType .PathSwitchRequestAcknowledgeTransferExtIEsPresentAdditionalNGUUPTNLInformation ,
445+ AdditionalNGUUPTNLInformation : & ngapType.UPTransportLayerInformationPairList {
446+ List : []ngapType.UPTransportLayerInformationPairItem {
447+ {
448+ ULNGUUPTNLInformation : ngapType.UPTransportLayerInformation {
449+ Present : ngapType .UPTransportLayerInformationPresentGTPTunnel ,
450+ GTPTunnel : & ngapType.GTPTunnel {
451+ GTPTEID : ngapType.GTPTEID {
452+ Value : aper.OctetString {0x00 , 0x00 , 0x00 , 0x01 },
453+ },
454+ TransportLayerAddress : ngapConvert .IPAddressToNgap ("127.0.0.1" , "" ),
455+ },
456+ },
457+ DLNGUUPTNLInformation : ngapType.UPTransportLayerInformation {
458+ Present : ngapType .UPTransportLayerInformationPresentGTPTunnel ,
459+ GTPTunnel : & ngapType.GTPTunnel {
460+ GTPTEID : ngapType.GTPTEID {
461+ Value : aper.OctetString {0x00 , 0x00 , 0x00 , 0x01 },
462+ },
463+ TransportLayerAddress : ngapConvert .IPAddressToNgap ("127.0.0.1" , "" ),
464+ },
465+ },
466+ },
467+ },
468+ },
469+ },
470+ },
471+ },
472+ },
473+ },
474+ },
475+ }
476+
477+ for _ , testCase := range testCases {
478+ t .Run (testCase .name , func (t * testing.T ) {
479+ t .Parallel ()
480+
481+ marshaledData , err := aper .MarshalWithParams (testCase .pdu , "valueExt" )
482+ if err != nil {
483+ t .Fatalf ("Failed to marshal data: %v" , err )
484+ }
485+
486+ unmarshaledDataPtr := reflect .New (reflect .TypeOf (testCase .pdu )).Interface ()
487+ err = aper .UnmarshalWithParams (marshaledData , unmarshaledDataPtr , "valueExt" )
488+ if err != nil {
489+ t .Fatalf ("Failed to unmarshal data: %v" , err )
490+ }
491+
492+ unmarshaledData := reflect .ValueOf (unmarshaledDataPtr ).Elem ().Interface ()
493+ assert .DeepEqual (t , testCase .pdu , unmarshaledData )
494+ })
495+ }
496+ }
0 commit comments