@@ -7,135 +7,134 @@ use RESTAPI\Models\HAProxyBackend;
77use RESTAPI \Models \HAProxyBackendACL ;
88use RESTAPI \Models \HAProxyBackendAction ;
99
10- class APIModelsHAProxyBackendTestCase extends TestCase
11- {
12- public array $ required_packages = ["pfSense-pkg-haproxy " ];
13-
10+ class APIModelsHAProxyBackendTestCase extends TestCase {
11+ public array $ required_packages = ['pfSense-pkg-haproxy ' ];
12+
1413 /**
1514 * Ensure that the HAProxyBackend model can be created, updated, and deleted.
1615 */
1716 public function test_crud (): void {
1817 # Create a new HAProxyBackend model
1918 $ backend = new HAProxyBackend (
20- name: " example_backend " ,
21- balance: "" ,
19+ name: ' example_backend ' ,
20+ balance: '' ,
2221 acls: [
2322 [
24- " name " => " example_acl " ,
25- " expression " => " host_starts_with " ,
26- " value " => " example " ,
27- " casesensitive " => false ,
28- " not " => false
29- ]
23+ ' name ' => ' example_acl ' ,
24+ ' expression ' => ' host_starts_with ' ,
25+ ' value ' => ' example ' ,
26+ ' casesensitive ' => false ,
27+ ' not ' => false ,
28+ ],
3029 ],
3130 actions: [
3231 [
33- " action " => " http-response_lua " ,
34- " acl " => " example_acl " ,
35- " lua_function " => " example function "
36- ]
32+ ' action ' => ' http-response_lua ' ,
33+ ' acl ' => ' example_acl ' ,
34+ ' lua_function ' => ' example function ' ,
35+ ],
3736 ],
38- check_type: " HTTP " ,
37+ check_type: ' HTTP ' ,
3938 log_health_checks: false ,
40- httpcheck_method: " OPTIONS " ,
41- monitor_uri: "" ,
42- monitor_httpversion: "" ,
39+ httpcheck_method: ' OPTIONS ' ,
40+ monitor_uri: '' ,
41+ monitor_httpversion: '' ,
4342 agent_checks: false ,
44- agent_port: "" ,
43+ agent_port: '' ,
4544 persist_cookie_enabled: false ,
46- persist_cookie_name: "" ,
47- persist_cookie_mode: " passive " ,
45+ persist_cookie_name: '' ,
46+ persist_cookie_mode: ' passive ' ,
4847 haproxy_cookie_domains: [],
49- haproxy_cookie_dynamic_cookie_key: "" ,
50- persist_sticky_type: " none " ,
51- persist_stick_expire: "" ,
52- persist_stick_tablesize: "" ,
53- persist_stick_cookiename: "" ,
54- email_level: "" ,
55- email_to: "" ,
48+ haproxy_cookie_dynamic_cookie_key: '' ,
49+ persist_sticky_type: ' none ' ,
50+ persist_stick_expire: '' ,
51+ persist_stick_tablesize: '' ,
52+ persist_stick_cookiename: '' ,
53+ email_level: '' ,
54+ email_to: '' ,
5655 stats_enabled: true ,
57- stats_uri: " / " ,
58- stats_scope: [ " . " ],
59- stats_realm: "" ,
60- stats_username: "" ,
61- stats_admin: "" ,
62- stats_node: " NODE1 " ,
63- stats_desc: "" ,
56+ stats_uri: ' / ' ,
57+ stats_scope: [' . ' ],
58+ stats_realm: '' ,
59+ stats_username: '' ,
60+ stats_admin: '' ,
61+ stats_node: ' NODE1 ' ,
62+ stats_desc: '' ,
6463 stats_refresh: 10 ,
6564 cookie_attribute_secure: false ,
66- advanced: "" ,
67- advanced_backend: "" ,
65+ advanced: '' ,
66+ advanced_backend: '' ,
6867 transparent_clientip: true ,
69- transparent_interface: " lan "
68+ transparent_interface: ' lan ' ,
7069 );
7170 $ backend ->create ();
72-
71+
7372 # Ensure the model was created
7473 $ read_backend = HAProxyBackend::query (id: $ backend ->id );
7574 $ this ->assert_is_true ($ read_backend ->exists ());
7675 $ read_backend = $ read_backend ->first ();
77- $ this ->assert_equals ($ read_backend ->name ->value , " example_backend " );
78- $ this ->assert_equals ($ read_backend ->balance ->value , "" );
79- $ this ->assert_equals ($ read_backend ->check_type ->value , " HTTP " );
76+ $ this ->assert_equals ($ read_backend ->name ->value , ' example_backend ' );
77+ $ this ->assert_equals ($ read_backend ->balance ->value , '' );
78+ $ this ->assert_equals ($ read_backend ->check_type ->value , ' HTTP ' );
8079 $ this ->assert_equals ($ read_backend ->log_health_checks ->value , false );
81- $ this ->assert_equals ($ read_backend ->httpcheck_method ->value , " OPTIONS " );
82- $ this ->assert_equals ($ read_backend ->monitor_uri ->value , "" );
83- $ this ->assert_equals ($ read_backend ->monitor_httpversion ->value , "" );
84- $ this ->assert_is_empty ($ read_backend ->monitor_username ->value , "" );
85- $ this ->assert_is_empty ($ read_backend ->monitor_domain ->value , "" );
80+ $ this ->assert_equals ($ read_backend ->httpcheck_method ->value , ' OPTIONS ' );
81+ $ this ->assert_equals ($ read_backend ->monitor_uri ->value , '' );
82+ $ this ->assert_equals ($ read_backend ->monitor_httpversion ->value , '' );
83+ $ this ->assert_is_empty ($ read_backend ->monitor_username ->value , '' );
84+ $ this ->assert_is_empty ($ read_backend ->monitor_domain ->value , '' );
8685 $ this ->assert_equals ($ read_backend ->agent_checks ->value , false );
87- $ this ->assert_is_empty ($ read_backend ->agent_port ->value , "" );
86+ $ this ->assert_is_empty ($ read_backend ->agent_port ->value , '' );
8887 $ this ->assert_is_empty ($ read_backend ->persist_cookie_enabled ->value , false );
89- $ this ->assert_is_empty ($ read_backend ->persist_cookie_name ->value , "" );
90- $ this ->assert_is_empty ($ read_backend ->persist_cookie_mode ->value , " passive " );
91- $ this ->assert_is_empty ($ read_backend ->haproxy_cookie_dynamic_cookie_key ->value , "" );
92- $ this ->assert_equals ($ read_backend ->persist_sticky_type ->value , " none " );
93- $ this ->assert_is_empty ($ read_backend ->persist_stick_expire ->value , "" );
94- $ this ->assert_is_empty ($ read_backend ->persist_stick_tablesize ->value , "" );
95- $ this ->assert_is_empty ($ read_backend ->persist_stick_cookiename ->value , "" );
96- $ this ->assert_is_empty ($ read_backend ->email_level ->value , "" );
97- $ this ->assert_is_empty ($ read_backend ->email_to ->value , "" );
88+ $ this ->assert_is_empty ($ read_backend ->persist_cookie_name ->value , '' );
89+ $ this ->assert_is_empty ($ read_backend ->persist_cookie_mode ->value , ' passive ' );
90+ $ this ->assert_is_empty ($ read_backend ->haproxy_cookie_dynamic_cookie_key ->value , '' );
91+ $ this ->assert_equals ($ read_backend ->persist_sticky_type ->value , ' none ' );
92+ $ this ->assert_is_empty ($ read_backend ->persist_stick_expire ->value , '' );
93+ $ this ->assert_is_empty ($ read_backend ->persist_stick_tablesize ->value , '' );
94+ $ this ->assert_is_empty ($ read_backend ->persist_stick_cookiename ->value , '' );
95+ $ this ->assert_is_empty ($ read_backend ->email_level ->value , '' );
96+ $ this ->assert_is_empty ($ read_backend ->email_to ->value , '' );
9897 $ this ->assert_equals ($ read_backend ->stats_enabled ->value , true );
99- $ this ->assert_equals ($ read_backend ->stats_uri ->value , " / " );
100- $ this ->assert_equals ($ read_backend ->stats_scope ->value , [ " . " ]);
101- $ this ->assert_is_empty ($ read_backend ->stats_realm ->value , "" );
102- $ this ->assert_is_empty ($ read_backend ->stats_username ->value , "" );
103- $ this ->assert_is_empty ($ read_backend ->stats_admin ->value , "" );
104- $ this ->assert_equals ($ read_backend ->stats_node ->value , " NODE1 " );
105- $ this ->assert_is_empty ($ read_backend ->stats_desc ->value , "" );
98+ $ this ->assert_equals ($ read_backend ->stats_uri ->value , ' / ' );
99+ $ this ->assert_equals ($ read_backend ->stats_scope ->value , [' . ' ]);
100+ $ this ->assert_is_empty ($ read_backend ->stats_realm ->value , '' );
101+ $ this ->assert_is_empty ($ read_backend ->stats_username ->value , '' );
102+ $ this ->assert_is_empty ($ read_backend ->stats_admin ->value , '' );
103+ $ this ->assert_equals ($ read_backend ->stats_node ->value , ' NODE1 ' );
104+ $ this ->assert_is_empty ($ read_backend ->stats_desc ->value , '' );
106105 $ this ->assert_equals ($ read_backend ->stats_refresh ->value , 10 );
107106 $ this ->assert_equals ($ read_backend ->cookie_attribute_secure ->value , false );
108- $ this ->assert_is_empty ($ read_backend ->advanced ->value , "" );
109- $ this ->assert_is_empty ($ read_backend ->advanced_backend ->value , "" );
107+ $ this ->assert_is_empty ($ read_backend ->advanced ->value , '' );
108+ $ this ->assert_is_empty ($ read_backend ->advanced_backend ->value , '' );
110109 $ this ->assert_equals ($ read_backend ->transparent_clientip ->value , true );
111- $ this ->assert_equals ($ read_backend ->transparent_interface ->value , " lan " );
112-
110+ $ this ->assert_equals ($ read_backend ->transparent_interface ->value , ' lan ' );
111+
113112 # Ensure the HAProxyBackendACL model was created
114113 $ this ->assert_is_true (HAProxyBackendACL::query (parent_id: $ backend ->id , id: 0 )->exists ());
115114 $ this ->assert_equals ($ read_backend ->acls ->value , [
116115 [
117- " parent_id " => $ backend ->id ,
118- " id " => 0 ,
119- " name " => " example_acl " ,
120- " expression " => " host_starts_with " ,
121- " value " => " example " ,
122- " casesensitive " => false ,
123- " not " => false
124- ]
116+ ' parent_id ' => $ backend ->id ,
117+ ' id ' => 0 ,
118+ ' name ' => ' example_acl ' ,
119+ ' expression ' => ' host_starts_with ' ,
120+ ' value ' => ' example ' ,
121+ ' casesensitive ' => false ,
122+ ' not ' => false ,
123+ ],
125124 ]);
126-
125+
127126 # Ensure the HAProxyBackendAction model was created
128127 $ this ->assert_is_true (HAProxyBackendAction::query (parent_id: $ backend ->id , id: 0 )->exists ());
129- $ this ->assert_equals ($ read_backend ->actions ->value [0 ][" action " ], " http-response_lua " );
130- $ this ->assert_equals ($ read_backend ->actions ->value [0 ][" acl " ], " example_acl " );
131- $ this ->assert_equals ($ read_backend ->actions ->value [0 ][" lua_function " ], " example function " );
132-
128+ $ this ->assert_equals ($ read_backend ->actions ->value [0 ][' action ' ], ' http-response_lua ' );
129+ $ this ->assert_equals ($ read_backend ->actions ->value [0 ][' acl ' ], ' example_acl ' );
130+ $ this ->assert_equals ($ read_backend ->actions ->value [0 ][' lua_function ' ], ' example function ' );
131+
133132 # Update the HAProxyBackend model
134- $ backend ->balance ->value = " roundrobin " ;
133+ $ backend ->balance ->value = ' roundrobin ' ;
135134 $ backend ->update ();
136135 $ read_backend = HAProxyBackend::query (id: $ backend ->id )->first ();
137- $ this ->assert_equals ($ read_backend ->balance ->value , " roundrobin " );
138-
136+ $ this ->assert_equals ($ read_backend ->balance ->value , ' roundrobin ' );
137+
139138 # Delete the HAProxyBackend model
140139 $ backend ->delete ();
141140 $ this ->assert_is_false (HAProxyBackend::query (id: $ backend ->id )->exists ());
0 commit comments