Skip to content

Commit

Permalink
tests: fix tests for APIKeys since we renamed 'name' to 'descr'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhendrickson13 committed Nov 10, 2023
1 parent 1a1518d commit 95d2dec
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ class APIModelsAPIKeyTestCase extends TestCase
code: 400,
callable: function () {
$key = new APIKey();
$key->client->username = "not_an_existing_user";
$key->validate_username("not_an_existing_user");
}
);

$this->assert_does_not_throw(
callable: function () {
$key = new APIKey();
$key->client->username = "admin";
$key->validate_username("admin");
}
);
Expand All @@ -35,7 +37,10 @@ class APIModelsAPIKeyTestCase extends TestCase
*/
public function test_key_and_hash_populated_after_creation() {
# Construct an APIKey model object to test with
$key = new APIKey(representation_data: ["name" => "test", "username" => "admin"]);
$key = new APIKey();

# Assign the client an actual username since it's required
$key->client->username = "admin";

# Ensure there is no `key` or `hash` value set before creation.
$this->assert_is_empty($key->key->value);
Expand Down Expand Up @@ -65,7 +70,8 @@ class APIModelsAPIKeyTestCase extends TestCase
*/
public function test_authenticate() {
# Construct an APIKey model object to test with
$key = new APIKey(representation_data: ["name" => "test", "username" => "admin"]);
$key = new APIKey();
$key->client->username = "admin";
$key->create();

# Ensure we can authenticate using the actual `key`
Expand All @@ -84,10 +90,11 @@ class APIModelsAPIKeyTestCase extends TestCase
response_id: "API_KEY_CANNOT_BE_UPDATED",
code: 500,
callable: function () {
$key = new APIKey(representation_data: ["name" => "test", "username" => "admin"]);
$key = new APIKey();
$key->client->username = "admin";
$key->create();
$key->update();
}
);
}
}
}

0 comments on commit 95d2dec

Please sign in to comment.