Skip to content

Commit 8d46825

Browse files
style: ran prettier on changed files
1 parent aad2d66 commit 8d46825

2 files changed

Lines changed: 32 additions & 37 deletions

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/InterfaceGRE.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ class InterfaceGRE extends Model {
146146
/**
147147
* Extend the default _create method to create the GRE interface and obtain the real interface name.
148148
*/
149-
public function _create(): void
150-
{
149+
public function _create(): void {
151150
$this->greif->value = interface_gre_configure($this->to_internal());
152151
parent::_create();
153152
}

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

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,64 @@ use RESTAPI\Core\Command;
66
use RESTAPI\Core\TestCase;
77
use RESTAPI\Models\InterfaceGRE;
88

9-
class APIModelsInterfaceGRETestCase extends TestCase
10-
{
9+
class APIModelsInterfaceGRETestCase extends TestCase {
1110
/**
1211
* Ensure that either a `tunnel_local_addr` or `tunnel_local_addr6` is required.
1312
*/
1413
public function test_tunnel_local_addr_or_tunnel_local_addr6_required(): void {
1514
# Ensure an error is thrown if no local address is provided
1615
$this->assert_throws_response(
17-
response_id: "INTERFACE_GRE_HAS_NO_LOCAL_ADDRESS",
16+
response_id: 'INTERFACE_GRE_HAS_NO_LOCAL_ADDRESS',
1817
code: 400,
1918
callable: function () {
2019
$gre = new InterfaceGRE();
2120
$gre->validate_extra();
22-
}
21+
},
2322
);
2423

2524
# Ensure no error is thrown in a tunnel_local_addr is assigned
2625
$this->assert_does_not_throw(
2726
callable: function () {
28-
$gre = new InterfaceGRE(tunnel_local_addr: "1.2.3.4");
27+
$gre = new InterfaceGRE(tunnel_local_addr: '1.2.3.4');
2928
$gre->validate_extra();
30-
}
29+
},
3130
);
3231

3332
# Ensure no error is thrown in a tunnel_local_addr6 is assigned
3433
$this->assert_does_not_throw(
3534
callable: function () {
36-
$gre = new InterfaceGRE(tunnel_local_addr6: "1234::1");
35+
$gre = new InterfaceGRE(tunnel_local_addr6: '1234::1');
3736
$gre->validate_extra();
38-
}
37+
},
3938
);
4039
}
4140

4241
/**
4342
* Ensure an existing GRE cannot be deleted if it is in use.
4443
*/
45-
public function test_delete_in_use(): void
46-
{
44+
public function test_delete_in_use(): void {
4745
# Ensure an error is thrown if the GRE is in use
4846
$this->assert_throws_response(
49-
response_id: "INTERFACE_GRE_CANNOT_DELETE_WHILE_IN_USE",
47+
response_id: 'INTERFACE_GRE_CANNOT_DELETE_WHILE_IN_USE',
5048
code: 409,
5149
callable: function () {
5250
$gre = new InterfaceGRE(
53-
if: "lan",
54-
remote_addr: "1.2.3.4",
55-
tunnel_local_addr: "4.3.2.1",
56-
tunnel_remote_addr: "1.1.2.2",
57-
tunnel_remote_net: 32
51+
if: 'lan',
52+
remote_addr: '1.2.3.4',
53+
tunnel_local_addr: '4.3.2.1',
54+
tunnel_remote_addr: '1.1.2.2',
55+
tunnel_remote_net: 32,
5856
);
5957
$gre->create();
6058

6159
# Mock a GRE interface in use
62-
InterfaceGRE::set_config("interfaces/opt99", ["if" => $gre->greif->value]);
60+
InterfaceGRE::set_config('interfaces/opt99', ['if' => $gre->greif->value]);
6361
$gre->delete();
64-
}
62+
},
6563
);
6664

6765
# Remove all GRE interfaces used in the test
68-
InterfaceGRE::del_config("interfaces/opt99");
66+
InterfaceGRE::del_config('interfaces/opt99');
6967
InterfaceGRE::delete_all();
7068
}
7169

@@ -75,30 +73,28 @@ class APIModelsInterfaceGRETestCase extends TestCase
7573
public function test_crud(): void {
7674
# Create a new GRE tunnel and ensure it's interface is seen in ifconfig
7775
$gre = new InterfaceGRE(
78-
if: "lan",
79-
remote_addr: "1.2.3.4",
80-
tunnel_local_addr: "4.3.2.1",
81-
tunnel_remote_addr: "1.1.2.2",
82-
tunnel_remote_net: 32
76+
if: 'lan',
77+
remote_addr: '1.2.3.4',
78+
tunnel_local_addr: '4.3.2.1',
79+
tunnel_remote_addr: '1.1.2.2',
80+
tunnel_remote_net: 32,
8381
);
8482
$gre->create();
85-
$ifconfig_output = new Command("ifconfig");
83+
$ifconfig_output = new Command('ifconfig');
8684
$this->assert_str_contains($ifconfig_output->output, $gre->greif->value);
87-
$this->assert_str_contains($ifconfig_output->output, "tunnel inet 192.168.1.1 --> 1.2.3.4");
88-
$this->assert_str_contains($ifconfig_output->output, "inet 4.3.2.1 --> 1.1.2.2 netmask 0xffffffff");
85+
$this->assert_str_contains($ifconfig_output->output, 'tunnel inet 192.168.1.1 --> 1.2.3.4');
86+
$this->assert_str_contains($ifconfig_output->output, 'inet 4.3.2.1 --> 1.1.2.2 netmask 0xffffffff');
8987

9088
# Update the GRE tunnel and ensure the changes are reflected in ifconfig
91-
$gre->remote_addr->value = "2.3.4.5";
89+
$gre->remote_addr->value = '2.3.4.5';
9290
$gre->update();
93-
$ifconfig_output = new Command("ifconfig");
94-
$this->assert_str_does_not_contain($ifconfig_output->output, "tunnel inet 192.168.1.1 --> 1.2.3.4");
95-
$this->assert_str_contains($ifconfig_output->output, "tunnel inet 192.168.1.1 --> 2.3.4.5");
91+
$ifconfig_output = new Command('ifconfig');
92+
$this->assert_str_does_not_contain($ifconfig_output->output, 'tunnel inet 192.168.1.1 --> 1.2.3.4');
93+
$this->assert_str_contains($ifconfig_output->output, 'tunnel inet 192.168.1.1 --> 2.3.4.5');
9694

9795
# Delete the GRE tunnel and ensure it's interface is no longer seen in ifconfig
9896
$gre->delete();
99-
$ifconfig_output = new Command("ifconfig");
97+
$ifconfig_output = new Command('ifconfig');
10098
$this->assert_str_does_not_contain($ifconfig_output->output, $gre->greif->value);
101-
102-
10399
}
104-
}
100+
}

0 commit comments

Comments
 (0)