Skip to content

Commit

Permalink
MDL-78337 tool_brickfield: Attempt immediate validation
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlkin committed Aug 14, 2023
1 parent a1d5d1b commit 481a260
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions admin/tool/brickfield/classes/registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public function set_keys_for_registration(string $apikey, string $secretkey): bo
$this->set_api_key($apikey);
$this->set_secret_key($secretkey);
$this->set_not_validated();
// Attempt to validate the registration.
$this->validate();
if (!$this->status_is_validated()) {
// If the validation failed here, start the grace period.
$this->set_not_validated();
$this->set_summary_time();
}
if ($this->summarytime <= 0) {
$this->set_summary_time();
}
Expand Down
3 changes: 2 additions & 1 deletion admin/tool/brickfield/tests/registration_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function test_set_keys_for_registration() {
// State when valid format keys are sent.
$this->assertTrue($regobj->set_keys_for_registration(mock_brickfieldconnect::VALIDAPIKEY,
mock_brickfieldconnect::VALIDSECRETKEY));
$this->assertTrue($regobj->validation_pending());
$this->assertTrue($regobj->toolkit_is_active());
$this->assertFalse($regobj->validation_pending());
$this->assertEquals($regobj->get_api_key(), mock_brickfieldconnect::VALIDAPIKEY);
$this->assertEquals($regobj->get_secret_key(), mock_brickfieldconnect::VALIDSECRETKEY);
}
Expand Down

0 comments on commit 481a260

Please sign in to comment.