Skip to content

Commit 97323ed

Browse files
tests: ensure we can update non-applied static routes #654
1 parent 9c37bf2 commit 97323ed

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Tests/APIModelsStaticRouteTestCase.inc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,34 @@ class APIModelsStaticRouteTestCase extends TestCase {
341341
# Delete the gateway used for testing
342342
$test_gw->delete(apply: true);
343343
}
344+
345+
/**
346+
* Checks that we can update a newly created static route that has not yet been applied. Regression test for #654.
347+
*/
348+
public function test_update_static_route_before_its_applied(): void {
349+
# Create a gateway to use for testing
350+
$test_gw = new RoutingGateway(
351+
name: 'TESTGW',
352+
interface: 'lan',
353+
ipprotocol: 'inet',
354+
gateway: '192.168.1.10',
355+
async: false,
356+
);
357+
$test_gw->create();
358+
359+
# Create a static route using the gateway above, but do not apply it!
360+
$test_route = new StaticRoute(
361+
gateway: $test_gw->name->value,
362+
network: '1.2.3.4/32'
363+
);
364+
$test_route->create();
365+
366+
# Ensure we can update the static route before applying it
367+
$test_route->network->value = '4.3.2.1/32';
368+
$test_route->update();
369+
370+
# Remove the static route and gateway
371+
$test_route->delete();
372+
$test_gw->delete(apply: true);
373+
}
344374
}

0 commit comments

Comments
 (0)