@@ -3514,6 +3514,31 @@ def rfc_total(length: int) -> int:
35143514 with self .assertRaisesRegex (FieldValueError , 'invalid parameter length' ):
35153515 hip_schema .encrypted_data_len ({'len' : 19 , 'iv' : b'\x11 ' * 16 })
35163516
3517+ def test_hip_echo_response_unsigned_maker_builds_the_response_schema (self ) -> None :
3518+ # #2170: the maker built the ECHO_REQUEST_UNSIGNED schema class, and its
3519+ # ``param`` and return annotations named the Request classes.
3520+ from pcapkit .const .hip .parameter import Parameter
3521+ from pcapkit .protocols .data .internet import hip as hip_data
3522+ from pcapkit .protocols .internet .hip import HIP
3523+ from pcapkit .protocols .schema .internet import hip as hip_schema
3524+
3525+ proto = object .__new__ (HIP )
3526+ param = hip_data .EchoResponseUnsignedParameter (type = Parameter .ECHO_RESPONSE_UNSIGNED ,
3527+ critical = False , length = 4 , opaque = b'abcd' )
3528+ for name , schema in (
3529+ ('keywords' , proto ._make_param_echo_response_unsigned (
3530+ Parameter .ECHO_RESPONSE_UNSIGNED , version = 2 , opaque = b'abcd' )),
3531+ ('data' , proto ._make_param_echo_response_unsigned (
3532+ Parameter .ECHO_RESPONSE_UNSIGNED , param , version = 2 )),
3533+ ):
3534+ with self .subTest (source = name ):
3535+ self .assertIs (type (schema ), hip_schema .EchoResponseUnsignedParameter )
3536+ self .assertEqual (schema .opaque , b'abcd' )
3537+
3538+ hints = HIP ._make_param_echo_response_unsigned .__annotations__
3539+ self .assertEqual (hints ['param' ], 'Optional[Data_EchoResponseUnsignedParameter]' )
3540+ self .assertEqual (hints ['return' ], 'Schema_EchoResponseUnsignedParameter' )
3541+
35173542
35183543if __name__ == '__main__' :
35193544 unittest .main ()
0 commit comments