@@ -68,45 +68,6 @@ func NewAmfRan(conn net.Conn) *amf_context.AmfRan {
6868 return & ran
6969}
7070
71- func TestHandlePathSwitchRequestKeepsStoredUESecurityCapabilityOnMismatch (t * testing.T ) {
72- amfSelf := amf_context .GetSelf ()
73- NewAmfContext (amfSelf )
74-
75- sourceRan := NewAmfRan (nil )
76- sourceRan .AnType = "3GPP_ACCESS"
77- ranUe , err := sourceRan .NewRanUe (1 )
78- require .NoError (t , err )
79-
80- amfUe := amfSelf .NewAmfUe ("imsi-208930000007487" )
81- amfUe .SecurityContextAvailable = true
82- amfUe .NgKsi .Ksi = 1
83- amfUe .Kamf = strings .Repeat ("11" , 32 )
84- amfUe .NH = []byte (strings .Repeat ("\x22 " , 32 ))
85- amfUe .UESecurityCapability = nasType.UESecurityCapability {
86- Iei : nasMessage .RegistrationRequestUESecurityCapabilityType ,
87- Len : 2 ,
88- Buffer : []uint8 {0x00 , 0x00 },
89- }
90- amfUe .UESecurityCapability .SetIA2_128_5G (1 )
91-
92- ranUe .AmfUe = amfUe
93- amfUe .RanUe ["3GPP_ACCESS" ] = ranUe
94-
95- targetRan := NewAmfRan (nil )
96- targetRan .AnType = "3GPP_ACCESS"
97- sourceAMFUeNgapID := ngapType.AMFUENGAPID {Value : ranUe .AmfUeNgapId }
98- ranUeNgapID := ngapType.RANUENGAPID {Value : 2 }
99- received := & ngapType.UESecurityCapabilities {}
100- received .NRencryptionAlgorithms .Value = aper.BitString {Bytes : []byte {0x00 , 0x00 }, BitLength : 16 }
101- received .NRintegrityProtectionAlgorithms .Value = aper.BitString {Bytes : []byte {0x00 , 0x00 }, BitLength : 16 }
102-
103- handlePathSwitchRequestMain (targetRan , & ranUeNgapID , & sourceAMFUeNgapID , nil , received , nil , nil )
104-
105- require .Equal (t , uint8 (1 ), amfUe .UESecurityCapability .GetIA2_128_5G ())
106- require .Equal (t , uint8 (0 ), amfUe .UESecurityCapability .GetIA1_128_5G ())
107- require .Equal (t , uint8 (0 ), amfUe .UESecurityCapability .GetIA3_128_5G ())
108- }
109-
11071func NewAmfContext (amfCtx * amf_context.AMFContext ) {
11172 * amfCtx = amf_context.AMFContext {
11273 NfId : uuid .New ().String (),
@@ -196,6 +157,51 @@ func NewAmfContext(amfCtx *amf_context.AMFContext) {
196157 }
197158}
198159
160+ func TestHandlePathSwitchRequestKeepsStoredUESecurityCapabilityOnMismatch (t * testing.T ) {
161+ amfSelf := amf_context .GetSelf ()
162+ NewAmfContext (amfSelf )
163+
164+ sourceRan := NewAmfRan (nil )
165+ sourceRan .AnType = "3GPP_ACCESS"
166+ ranUe := & amf_context.RanUe {
167+ Ran : sourceRan ,
168+ RanUeNgapId : 1 ,
169+ AmfUeNgapId : 1 ,
170+ Log : sourceRan .Log ,
171+ }
172+ sourceRan .RanUeList .Store (ranUe .RanUeNgapId , ranUe )
173+ amfSelf .RanUePool .Store (ranUe .AmfUeNgapId , ranUe )
174+
175+ amfUe := amfSelf .NewAmfUe ("imsi-208930000007487" )
176+ amfUe .SecurityContextAvailable = true
177+ amfUe .NgKsi .Ksi = 1
178+ amfUe .Kamf = strings .Repeat ("11" , 32 )
179+ amfUe .NH = []byte (strings .Repeat ("\x22 " , 32 ))
180+ amfUe .UESecurityCapability = nasType.UESecurityCapability {
181+ Iei : nasMessage .RegistrationRequestUESecurityCapabilityType ,
182+ Len : 2 ,
183+ Buffer : []uint8 {0x00 , 0x00 },
184+ }
185+ amfUe .UESecurityCapability .SetIA2_128_5G (1 )
186+
187+ ranUe .AmfUe = amfUe
188+ amfUe .RanUe ["3GPP_ACCESS" ] = ranUe
189+
190+ targetRan := NewAmfRan (nil )
191+ targetRan .AnType = "3GPP_ACCESS"
192+ sourceAMFUeNgapID := ngapType.AMFUENGAPID {Value : ranUe .AmfUeNgapId }
193+ ranUeNgapID := ngapType.RANUENGAPID {Value : 2 }
194+ received := & ngapType.UESecurityCapabilities {}
195+ received .NRencryptionAlgorithms .Value = aper.BitString {Bytes : []byte {0x00 , 0x00 }, BitLength : 16 }
196+ received .NRintegrityProtectionAlgorithms .Value = aper.BitString {Bytes : []byte {0x00 , 0x00 }, BitLength : 16 }
197+
198+ handlePathSwitchRequestMain (targetRan , & ranUeNgapID , & sourceAMFUeNgapID , nil , received , nil , nil )
199+
200+ require .Equal (t , uint8 (1 ), amfUe .UESecurityCapability .GetIA2_128_5G ())
201+ require .Equal (t , uint8 (0 ), amfUe .UESecurityCapability .GetIA1_128_5G ())
202+ require .Equal (t , uint8 (0 ), amfUe .UESecurityCapability .GetIA3_128_5G ())
203+ }
204+
199205func BuildInitialUEMessage (ranUeNgapID int64 , nasPdu []byte , fiveGSTmsi string ) ngapType.NGAPPDU {
200206 var TestPlmn ngapType.PLMNIdentity
201207 var tmsi aper.OctetString
0 commit comments