-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from jaredhendrickson13/next_patch
- Loading branch information
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
namespace RESTAPI\Tests; | ||
|
||
use ReflectionClass; | ||
use ReflectionException; | ||
use RESTAPI; | ||
use RESTAPI\Caches\RESTAPIVersionReleasesCache; | ||
use RESTAPI\Core\Auth; | ||
use RESTAPI\Core\Model; | ||
use RESTAPI\Models\FirewallAlias; | ||
use RESTAPI\Models\SystemStatus; | ||
|
@@ -744,4 +744,24 @@ class APICoreModelTestCase extends RESTAPI\Core\TestCase { | |
$this->assert_equals($alias->address->value, []); | ||
$this->assert_equals($alias->detail->value, []); | ||
} | ||
|
||
/** | ||
* Ensures the authenticated username is properly retained whenever running Model::write_config() (#512) | ||
*/ | ||
public function test_write_config_retains_authenticated_username(): void { | ||
# Authenticate a user | ||
$client = new Auth(); | ||
$client->username = 'test_user'; | ||
$client->ip_address = '1.2.3.4'; | ||
|
||
# Create a new alias with the authenticated user | ||
$alias = new FirewallAlias(name: 'test_alias', type: 'host', client: $client); | ||
$alias->create(); | ||
|
||
# Ensure the 'revision' section of the config contains the authenticated username | ||
$this->assert_equals($alias->get_config('revision/username'), '[email protected]'); | ||
|
||
# Delete the alias | ||
$alias->delete(); | ||
} | ||
} |