mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Fix FLEXIAPI-408 Adjustments to allow custom JWT tests and hooks
This commit is contained in:
parent
e0f33da4ac
commit
25ddd330c1
5 changed files with 21 additions and 20 deletions
|
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers\Account;
|
|||
use App\ResetPasswordEmailToken;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ResetPasswordEmailController extends Controller
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,14 +52,14 @@ class AccountFactory extends Factory
|
|||
|
||||
public function fromSpace(Space $space)
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
return $this->state(fn(array $attributes) => [
|
||||
'domain' => $space->domain
|
||||
]);
|
||||
}
|
||||
|
||||
public function admin()
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
return $this->state(fn(array $attributes) => [
|
||||
'admin' => true,
|
||||
]);
|
||||
}
|
||||
|
|
@ -79,21 +79,21 @@ class AccountFactory extends Factory
|
|||
|
||||
public function deactivated()
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
return $this->state(fn(array $attributes) => [
|
||||
'activated' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withEmail()
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
return $this->state(fn(array $attributes) => [
|
||||
'email' => $this->faker->email,
|
||||
]);
|
||||
}
|
||||
|
||||
public function withConsumedAccountCreationToken()
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [])->afterCreating(function (Account $account) {
|
||||
return $this->state(fn(array $attributes) => [])->afterCreating(function (Account $account) {
|
||||
$accountCreationToken = new AccountCreationToken;
|
||||
$accountCreationToken->token = 'test_token';
|
||||
$accountCreationToken->account_id = $account->id;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class PasswordFactory extends Factory
|
|||
|
||||
return [
|
||||
'account_id' => $account->id,
|
||||
'password' => hash('md5', $account->username.':'.$account->resolvedRealm.':testtest'),
|
||||
'password' => hash('md5', $account->username . ':' . $account->resolvedRealm . ':testtest'),
|
||||
'algorithm' => 'MD5',
|
||||
];
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ class PasswordFactory extends Factory
|
|||
$account = Account::find($attributes['account_id']);
|
||||
|
||||
return [
|
||||
'password' => hash('sha256', $account->username.':'.$account->resolvedRealm.':testtest'),
|
||||
'password' => hash('sha256', $account->username . ':' . $account->resolvedRealm . ':testtest'),
|
||||
'account_id' => $account->id,
|
||||
'algorithm' => 'SHA-256',
|
||||
];
|
||||
|
|
@ -64,7 +64,7 @@ class PasswordFactory extends Factory
|
|||
|
||||
public function clrtxt()
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
return $this->state(fn(array $attributes) => [
|
||||
'password' => 'testtest',
|
||||
'algorithm' => 'CLRTXT',
|
||||
]);
|
||||
|
|
|
|||
5
flexiapi/resources/views/errors/400.blade.php
Normal file
5
flexiapi/resources/views/errors/400.blade.php
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
@extends('errors::minimal')
|
||||
|
||||
@section('title', __('Bad Request'))
|
||||
@section('code', '404')
|
||||
@section('message', __($exception->getMessage() ?: 'Bad Request'))
|
||||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Account;
|
||||
use App\Password;
|
||||
use DateTimeImmutable;
|
||||
use Lcobucci\Clock\FrozenClock;
|
||||
|
|
@ -198,7 +197,7 @@ class AccountJWTAuthenticationTest extends TestCase
|
|||
$value = 'authz_server="https://auth_bearer.com/" realm="realm"';
|
||||
config()->set('app.account_authentication_bearer', $value);
|
||||
|
||||
$password = Password::factory()->create();
|
||||
Password::factory()->create();
|
||||
|
||||
$response = $this->json($this->method, $this->routeAccountMe)
|
||||
->assertStatus(401);
|
||||
|
|
@ -209,8 +208,7 @@ class AccountJWTAuthenticationTest extends TestCase
|
|||
);
|
||||
|
||||
// Wrong From
|
||||
$reponse = $this
|
||||
->withHeaders(['From' => 'sip:missing@username'])
|
||||
$this->withHeaders(['From' => 'sip:missing@username'])
|
||||
->json($this->method, $this->routeAccountMe)
|
||||
->assertStatus(401);
|
||||
|
||||
|
|
@ -220,8 +218,7 @@ class AccountJWTAuthenticationTest extends TestCase
|
|||
);
|
||||
|
||||
// Wrong bearer message
|
||||
$reponse = $this
|
||||
->withHeaders([
|
||||
$this->withHeaders([
|
||||
'Authorization' => 'Bearer 1234'
|
||||
])
|
||||
->json($this->method, $this->routeAccountMe)
|
||||
|
|
@ -233,7 +230,7 @@ class AccountJWTAuthenticationTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
private function checkToken(UnencryptedToken $token): void
|
||||
protected function checkToken(UnencryptedToken $token): void
|
||||
{
|
||||
$this->withHeaders([
|
||||
'Authorization' => 'Bearer ' . $token->toString(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue