@@ -195,6 +195,162 @@ fn build_fail_valid_prop_rs_mt() {
195195 assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
196196}
197197
198+ #[ test]
199+ fn build_fail_valid_prop_wsa_mt ( ) {
200+ common:: init_tracing ( ) ;
201+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
202+ . session_present ( true )
203+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
204+ . props ( vec ! [
205+ mqtt:: packet:: WildcardSubscriptionAvailable :: new( 1 )
206+ . unwrap( )
207+ . into( ) ,
208+ mqtt:: packet:: WildcardSubscriptionAvailable :: new( 0 )
209+ . unwrap( )
210+ . into( ) ,
211+ ] )
212+ . build ( )
213+ . unwrap_err ( ) ;
214+
215+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
216+ }
217+
218+ #[ test]
219+ fn build_fail_valid_prop_sia_mt ( ) {
220+ common:: init_tracing ( ) ;
221+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
222+ . session_present ( true )
223+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
224+ . props ( vec ! [
225+ mqtt:: packet:: SubscriptionIdentifierAvailable :: new( 1 )
226+ . unwrap( )
227+ . into( ) ,
228+ mqtt:: packet:: SubscriptionIdentifierAvailable :: new( 0 )
229+ . unwrap( )
230+ . into( ) ,
231+ ] )
232+ . build ( )
233+ . unwrap_err ( ) ;
234+
235+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
236+ }
237+
238+ #[ test]
239+ fn build_fail_valid_prop_ssa_mt ( ) {
240+ common:: init_tracing ( ) ;
241+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
242+ . session_present ( true )
243+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
244+ . props ( vec ! [
245+ mqtt:: packet:: SharedSubscriptionAvailable :: new( 1 )
246+ . unwrap( )
247+ . into( ) ,
248+ mqtt:: packet:: SharedSubscriptionAvailable :: new( 0 )
249+ . unwrap( )
250+ . into( ) ,
251+ ] )
252+ . build ( )
253+ . unwrap_err ( ) ;
254+
255+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
256+ }
257+
258+ #[ test]
259+ fn build_fail_valid_prop_ska_mt ( ) {
260+ common:: init_tracing ( ) ;
261+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
262+ . session_present ( true )
263+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
264+ . props ( vec ! [
265+ mqtt:: packet:: ServerKeepAlive :: new( 10 ) . unwrap( ) . into( ) ,
266+ mqtt:: packet:: ServerKeepAlive :: new( 20 ) . unwrap( ) . into( ) ,
267+ ] )
268+ . build ( )
269+ . unwrap_err ( ) ;
270+
271+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
272+ }
273+
274+ #[ test]
275+ fn build_fail_valid_prop_ri_mt ( ) {
276+ common:: init_tracing ( ) ;
277+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
278+ . session_present ( true )
279+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
280+ . props ( vec ! [
281+ mqtt:: packet:: ResponseInformation :: new( "info1" )
282+ . unwrap( )
283+ . into( ) ,
284+ mqtt:: packet:: ResponseInformation :: new( "info2" )
285+ . unwrap( )
286+ . into( ) ,
287+ ] )
288+ . build ( )
289+ . unwrap_err ( ) ;
290+
291+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
292+ }
293+
294+ #[ test]
295+ fn build_fail_valid_prop_sr_mt ( ) {
296+ common:: init_tracing ( ) ;
297+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
298+ . session_present ( true )
299+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
300+ . props ( vec ! [
301+ mqtt:: packet:: ServerReference :: new( "server1" )
302+ . unwrap( )
303+ . into( ) ,
304+ mqtt:: packet:: ServerReference :: new( "server2" )
305+ . unwrap( )
306+ . into( ) ,
307+ ] )
308+ . build ( )
309+ . unwrap_err ( ) ;
310+
311+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
312+ }
313+
314+ #[ test]
315+ fn build_fail_valid_prop_am_mt ( ) {
316+ common:: init_tracing ( ) ;
317+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
318+ . session_present ( true )
319+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
320+ . props ( vec ! [
321+ mqtt:: packet:: AuthenticationMethod :: new( "method1" )
322+ . unwrap( )
323+ . into( ) ,
324+ mqtt:: packet:: AuthenticationMethod :: new( "method2" )
325+ . unwrap( )
326+ . into( ) ,
327+ ] )
328+ . build ( )
329+ . unwrap_err ( ) ;
330+
331+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
332+ }
333+
334+ #[ test]
335+ fn build_fail_valid_prop_ad_mt ( ) {
336+ common:: init_tracing ( ) ;
337+ let err = mqtt:: packet:: v5_0:: Connack :: builder ( )
338+ . session_present ( true )
339+ . reason_code ( mqtt:: result_code:: ConnectReasonCode :: Success )
340+ . props ( vec ! [
341+ mqtt:: packet:: AuthenticationData :: new( b"data1" )
342+ . unwrap( )
343+ . into( ) ,
344+ mqtt:: packet:: AuthenticationData :: new( b"data2" )
345+ . unwrap( )
346+ . into( ) ,
347+ ] )
348+ . build ( )
349+ . unwrap_err ( ) ;
350+
351+ assert_eq ! ( err, mqtt:: result_code:: MqttError :: ProtocolError ) ;
352+ }
353+
198354// build success tests
199355
200356#[ test]
@@ -216,6 +372,28 @@ fn build_succes_svalid_prop() {
216372 mqtt:: packet:: ReasonString :: new( "Connection successful" )
217373 . unwrap( )
218374 . into( ) ,
375+ mqtt:: packet:: WildcardSubscriptionAvailable :: new( 1 )
376+ . unwrap( )
377+ . into( ) ,
378+ mqtt:: packet:: SubscriptionIdentifierAvailable :: new( 1 )
379+ . unwrap( )
380+ . into( ) ,
381+ mqtt:: packet:: SharedSubscriptionAvailable :: new( 1 )
382+ . unwrap( )
383+ . into( ) ,
384+ mqtt:: packet:: ServerKeepAlive :: new( 30 ) . unwrap( ) . into( ) ,
385+ mqtt:: packet:: ResponseInformation :: new( "response info" )
386+ . unwrap( )
387+ . into( ) ,
388+ mqtt:: packet:: ServerReference :: new( "mqtt.example.com" )
389+ . unwrap( )
390+ . into( ) ,
391+ mqtt:: packet:: AuthenticationMethod :: new( "SCRAM-SHA-256" )
392+ . unwrap( )
393+ . into( ) ,
394+ mqtt:: packet:: AuthenticationData :: new( b"auth_data" )
395+ . unwrap( )
396+ . into( ) ,
219397 mqtt:: packet:: UserProperty :: new( "key1" , "value1" )
220398 . unwrap( )
221399 . into( ) ,
0 commit comments