mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-02-07 13:58:24 +00:00
Fix FLEXIAPI-341 Allow realm to be empty when creating a Space
This commit is contained in:
parent
a1f73095fd
commit
dd1345d1ba
7 changed files with 74 additions and 15 deletions
|
|
@ -56,6 +56,7 @@ v2.0
|
|||
- Fix FLEXIAPI-337 Generate the provisioning URLs based on the user space
|
||||
- Fix FLEXIAPI-326 Rework email templates and translations
|
||||
- Fix FLEXIAPI-340 Fix the space resolution when getting the realm on Accounts
|
||||
- Fix FLEXIAPI-341 Allow realm to be empty when creating a Space
|
||||
|
||||
v1.6
|
||||
----
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
# Releases
|
||||
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Space\Create;
|
||||
use App\Space;
|
||||
use App\Rules\Ini;
|
||||
use App\Rules\Domain;
|
||||
|
|
@ -55,7 +56,7 @@ class SpaceController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
public function store(Create $request)
|
||||
{
|
||||
$fullHost = empty($request->get('host'))
|
||||
? config('app.root_host')
|
||||
|
|
@ -63,11 +64,8 @@ class SpaceController extends Controller
|
|||
|
||||
$request->merge(['full_host' => $fullHost]);
|
||||
$request->validate([
|
||||
'name' => 'required|unique:spaces',
|
||||
'domain' => ['required', 'unique:spaces', new Domain()],
|
||||
'host' => 'nullable|regex:/'. Space::HOST_REGEX . '/',
|
||||
'full_host' => ['required', 'unique:spaces,host', new Domain()],
|
||||
'account_realm' => [new Domain()],
|
||||
]);
|
||||
|
||||
$space = new Space();
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@
|
|||
namespace App\Http\Controllers\Api\Admin;
|
||||
|
||||
use App\Space;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Space\Create;
|
||||
use App\Rules\Domain;
|
||||
use App\Rules\Ini;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
|
@ -34,15 +35,13 @@ class SpaceController extends Controller
|
|||
return Space::all();
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
public function store(Create $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|unique:spaces',
|
||||
'domain' => ['required', 'unique:spaces', new Domain()],
|
||||
'host' => ['required', 'unique:spaces', new Domain()],
|
||||
'max_accounts' => 'nullable|integer',
|
||||
'expire_at' => 'nullable|date|after_or_equal:today',
|
||||
'custom_provisioning_entries' => ['nullable', new Ini(Space::FORBIDDEN_KEYS)]
|
||||
'custom_provisioning_entries' => ['nullable', new Ini(Space::FORBIDDEN_KEYS)],
|
||||
]);
|
||||
|
||||
$space = new Space;
|
||||
|
|
@ -105,6 +104,7 @@ class SpaceController extends Controller
|
|||
'max_account' => 'required|integer',
|
||||
'max_accounts' => 'required|integer',
|
||||
'expire_at' => 'nullable|date|after_or_equal:today',
|
||||
'account_realm' => ['nullable', new Domain()],
|
||||
|
||||
'custom_provisioning_entries' => ['nullable', new Ini(Space::FORBIDDEN_KEYS)],
|
||||
'custom_provisioning_overwrite_all' => 'required|boolean',
|
||||
|
|
|
|||
38
flexiapi/app/Http/Requests/Space/Create.php
Normal file
38
flexiapi/app/Http/Requests/Space/Create.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/*
|
||||
Flexisip Account Manager is a set of tools to manage SIP accounts.
|
||||
Copyright (C) 2023 Belledonne Communications SARL, All rights reserved.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Http\Requests\Space;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
use App\EmailServer;
|
||||
use App\Rules\Domain;
|
||||
|
||||
class Create extends FormRequest
|
||||
{
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|unique:spaces',
|
||||
'domain' => ['required', 'unique:spaces', new Domain()],
|
||||
'account_realm' => ['nullable', new Domain()],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -140,13 +140,14 @@ Get a Space.
|
|||
### `POST /spaces`
|
||||
<span class="badge badge-error">Super Admin</span>
|
||||
|
||||
Create a new `sip_domain`.
|
||||
Create a new `space`.
|
||||
|
||||
JSON parameters:
|
||||
|
||||
* `name` **required**, the space name
|
||||
* `domain` **required**, the SIP domain to use, must be unique
|
||||
* `super` **required**, boolean, set the domain as a Super Domain
|
||||
* `host` **required**, the space host
|
||||
* `super` boolean, set the domain as a Super Domain
|
||||
* `disable_chat_feature` boolean, disable the chat feature, default to `false`
|
||||
* `disable_meetings_feature` boolean, disable the meeting feature, default to `false`
|
||||
* `disable_broadcast_feature` boolean, disable the broadcast feature, default to `true`
|
||||
|
|
|
|||
|
|
@ -78,15 +78,38 @@ class ApiSpaceTest extends TestCase
|
|||
$admin->generateUserApiKey();
|
||||
|
||||
$thirdDomain = 'third.domain';
|
||||
$accountRealm = 'account.realm';
|
||||
|
||||
$response = $this->keyAuthenticated($admin)
|
||||
-> json($this->method, $this->route, [
|
||||
'name' => $thirdDomain,
|
||||
'domain' => $thirdDomain,
|
||||
'host' => $thirdDomain,
|
||||
'super' => false
|
||||
])
|
||||
->assertStatus(201);
|
||||
->assertStatus(201)
|
||||
->assertJsonFragment([
|
||||
'super' => false,
|
||||
'account_realm' => null
|
||||
]);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
-> json($this->method, $this->route, [
|
||||
'name' => 'Another Domain',
|
||||
'domain' => 'baddomain',
|
||||
'host' => $thirdDomain,
|
||||
])
|
||||
->assertJsonValidationErrors(['domain']);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
-> json($this->method, $this->route, [
|
||||
'name' => 'Another Domain',
|
||||
'domain' => 'another.domain',
|
||||
'host' => 'another.host',
|
||||
'account_realm' => $accountRealm
|
||||
])
|
||||
->assertJsonFragment([
|
||||
'account_realm' => $accountRealm
|
||||
]);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->json('GET', $this->route)
|
||||
|
|
@ -94,7 +117,6 @@ class ApiSpaceTest extends TestCase
|
|||
'name' => $thirdDomain,
|
||||
'domain' => $thirdDomain,
|
||||
'host' => $thirdDomain,
|
||||
'super' => false
|
||||
])
|
||||
->assertStatus(200);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue