Skip to content

Commit

Permalink
tests: removed api key field tests from APISettings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhendrickson13 committed Nov 9, 2023
1 parent 4bff8e4 commit 6c59f3c
Showing 1 changed file with 0 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,90 +400,6 @@ class APIModelsAPISettingsTestCase extends TestCase
);
}

/**
* Checks that validation on the `key_hash_algo` field works as intended.
*/
public function test_key_hash_algo() {
# Ensure value must be a string
$this->assert_throws_response(
"FIELD_INVALID_TYPE",
code: 400,
callable: function () {
$api_settings = new APISettings(
representation_data: ["key_hash_algo" => 0]
);
$api_settings->validate();
}
);

# Ensure values must be either `sha256`, `sha384`, or `sha512`
$this->assert_throws_response(
"FIELD_INVALID_CHOICE",
code: 400,
callable: function () {
$api_settings = new APISettings(
representation_data: ["key_hash_algo" => "not a valid choice"]
);
$api_settings->validate();
}
);

# Ensure valid values are accepted
$this->assert_does_not_throw(
callable: function () {
$api_settings = new APISettings(representation_data: ["key_hash_algo" => "sha256"]);
$api_settings->validate();
$api_settings = new APISettings(representation_data: ["key_hash_algo" => "sha384"]);
$api_settings->validate();
$api_settings = new APISettings(representation_data: ["key_hash_algo" => "sha512"]);
$api_settings->validate();
}
);
}

/**
* Checks that validation on the `key_length_bytes` field works as intended.
*/
public function test_key_length_bytes() {
# Ensure value must be an integer
$this->assert_throws_response(
"FIELD_INVALID_TYPE",
code: 400,
callable: function () {
$api_settings = new APISettings(
representation_data: ["key_length_bytes" => "not an integer"]
);
$api_settings->validate();
}
);

# Ensure values must be either `16`, `24`, `32` or `64`
$this->assert_throws_response(
"FIELD_INVALID_CHOICE",
code: 400,
callable: function () {
$api_settings = new APISettings(
representation_data: ["key_length_bytes" => 12]
);
$api_settings->validate();
}
);

# Ensure valid values are accepted
$this->assert_does_not_throw(
callable: function () {
$api_settings = new APISettings(representation_data: ["key_length_bytes" => 16]);
$api_settings->validate();
$api_settings = new APISettings(representation_data: ["key_length_bytes" => 24]);
$api_settings->validate();
$api_settings = new APISettings(representation_data: ["key_length_bytes" => 32]);
$api_settings->validate();
$api_settings = new APISettings(representation_data: ["key_length_bytes" => 64]);
$api_settings->validate();
}
);
}

/**
* Checks that validation on the `ha_sync` field works as intended.
*/
Expand Down

0 comments on commit 6c59f3c

Please sign in to comment.