mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 01:58:07 +00:00
Fix FLEXIAPI-257 Return a more coherent message when search API endpoints returns a 404
This commit is contained in:
parent
786258da1f
commit
07458db5c9
4 changed files with 17 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ v1.7
|
|||
- Fix FLEXIAPI-252 Update the hCaptcha Laravel library, use file instead of cookies to store the session to prevent empty errors bags
|
||||
- Fix FLEXIAPI-254 Allow no data on POST requests to not trigger the ValidateJSON middleware
|
||||
- Fix FLEXIAPI-255 Create a INSTALL.md tutorial and log FlexisipPusherConnector errors
|
||||
* Fix FLEXIAPI-257 Return a more coherent message when search API endpoints returns a 404
|
||||
|
||||
v1.6
|
||||
----
|
||||
|
|
|
|||
|
|
@ -58,12 +58,20 @@ class AccountController extends Controller
|
|||
|
||||
public function search(string $sip)
|
||||
{
|
||||
return Account::sip($sip)->firstOrFail();
|
||||
$account = Account::sip($sip)->first();
|
||||
|
||||
if (!$account) abort(404, 'SIP address not found');
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
public function searchByEmail(string $email)
|
||||
{
|
||||
return Account::where('email', $email)->firstOrFail();
|
||||
$account = Account::where('email', $email)->first();
|
||||
|
||||
if (!$account) abort(404, 'Email address not found');
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
public function destroy(Request $request, int $accountId)
|
||||
|
|
|
|||
|
|
@ -1231,6 +1231,10 @@ class ApiAccountTest extends TestCase
|
|||
'activated' => true
|
||||
]);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->get($this->route . '/wrong/search')
|
||||
->assertStatus(404);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->get($this->route . '/' . $account->email . '/search-by-email')
|
||||
->assertStatus(200)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ trait TestUtilsTrait
|
|||
{
|
||||
return $this->withHeaders([
|
||||
'x-api-key' => $account->apiKey->key,
|
||||
'content-type' => 'application/json',
|
||||
'accept' => 'application/json',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue