@@ -114,6 +114,63 @@ pub struct SessionConfig {
114114
115115 /// The schedule configuration for the session
116116 pub schedule : Option < ScheduleConfig > ,
117+
118+ /// The validation configuration for the session
119+ #[ serde( default ) ]
120+ pub verification : VerificationConfig ,
121+ }
122+
123+ #[ derive( Clone , Debug , Deserialize ) ]
124+ /// The configuration of validation rules.
125+ pub struct VerificationConfig {
126+ /// Specifies whether we should check the original sending time for admin messages.
127+ #[ serde( default = "default_true" ) ]
128+ pub check_orig_sending_time_for_admin : bool ,
129+ }
130+
131+ impl VerificationConfig {
132+ pub fn builder ( ) -> VerificationConfigBuilder {
133+ VerificationConfigBuilder :: default ( )
134+ }
135+ }
136+
137+ impl Default for VerificationConfig {
138+ fn default ( ) -> Self {
139+ VerificationConfigBuilder :: default ( ) . build ( )
140+ }
141+ }
142+
143+ pub struct VerificationConfigBuilder {
144+ check_orig_sending_time_for_admin : bool ,
145+ }
146+
147+ impl Default for VerificationConfigBuilder {
148+ fn default ( ) -> Self {
149+ Self {
150+ check_orig_sending_time_for_admin : true ,
151+ }
152+ }
153+ }
154+
155+ impl VerificationConfigBuilder {
156+ pub fn new ( ) -> Self {
157+ Self :: default ( )
158+ }
159+
160+ pub fn check_orig_sending_time_for_admin ( mut self , value : bool ) -> Self {
161+ self . check_orig_sending_time_for_admin = value;
162+ self
163+ }
164+
165+ pub fn build ( self ) -> VerificationConfig {
166+ VerificationConfig {
167+ check_orig_sending_time_for_admin : self . check_orig_sending_time_for_admin ,
168+ }
169+ }
170+ }
171+
172+ fn default_true ( ) -> bool {
173+ true
117174}
118175
119176/// Errors that may occur when loading configuration.
@@ -170,6 +227,11 @@ reset_on_logon = false
170227 assert_eq ! ( session_config. tls_config, Some ( expected_tls_config) ) ;
171228 assert_eq ! ( session_config. reconnect_interval, 30 ) ;
172229 assert_eq ! ( session_config. logon_timeout, 10 ) ;
230+ assert ! (
231+ session_config
232+ . verification
233+ . check_orig_sending_time_for_admin
234+ ) ;
173235 }
174236
175237 #[ test]
@@ -439,6 +501,53 @@ end_day = "Friday"
439501 assert_eq ! ( session_config. reconnect_interval, 15 ) ;
440502 }
441503
504+ #[ test]
505+ fn test_verification_config_defaults_when_omitted ( ) {
506+ let config_contents = r#"
507+ [[sessions]]
508+ begin_string = "FIX.4.4"
509+ sender_comp_id = "send-comp-id"
510+ target_comp_id = "target-comp-id"
511+ connection_port = 443
512+ connection_host = "127.0.0.1"
513+ heartbeat_interval = 30
514+ "# ;
515+
516+ let config: Config = toml:: from_str ( config_contents) . unwrap ( ) ;
517+ let session_config = config. sessions . first ( ) . unwrap ( ) ;
518+
519+ assert ! (
520+ session_config
521+ . verification
522+ . check_orig_sending_time_for_admin
523+ ) ;
524+ }
525+
526+ #[ test]
527+ fn test_verification_config_can_disable_admin_orig_sending_time_check ( ) {
528+ let config_contents = r#"
529+ [[sessions]]
530+ begin_string = "FIX.4.4"
531+ sender_comp_id = "send-comp-id"
532+ target_comp_id = "target-comp-id"
533+ connection_port = 443
534+ connection_host = "127.0.0.1"
535+ heartbeat_interval = 30
536+
537+ [sessions.verification]
538+ check_orig_sending_time_for_admin = false
539+ "# ;
540+
541+ let config: Config = toml:: from_str ( config_contents) . unwrap ( ) ;
542+ let session_config = config. sessions . first ( ) . unwrap ( ) ;
543+
544+ assert ! (
545+ !session_config
546+ . verification
547+ . check_orig_sending_time_for_admin
548+ ) ;
549+ }
550+
442551 #[ test]
443552 fn test_load_from_path_success ( ) {
444553 let config_contents = r#"
0 commit comments