diff --git a/CHANGELOG.md b/CHANGELOG.md index 57f8411..b4e9e18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ---- diff --git a/RELEASE.md b/RELEASE.md index 7c8af26..07c98b7 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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/). diff --git a/flexiapi/app/Http/Controllers/Admin/SpaceController.php b/flexiapi/app/Http/Controllers/Admin/SpaceController.php index c985293..ddf2b85 100644 --- a/flexiapi/app/Http/Controllers/Admin/SpaceController.php +++ b/flexiapi/app/Http/Controllers/Admin/SpaceController.php @@ -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(); diff --git a/flexiapi/app/Http/Controllers/Api/Admin/SpaceController.php b/flexiapi/app/Http/Controllers/Api/Admin/SpaceController.php index 3e5cc6f..e44e131 100644 --- a/flexiapi/app/Http/Controllers/Api/Admin/SpaceController.php +++ b/flexiapi/app/Http/Controllers/Api/Admin/SpaceController.php @@ -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', diff --git a/flexiapi/app/Http/Requests/Space/Create.php b/flexiapi/app/Http/Requests/Space/Create.php new file mode 100644 index 0000000..56fb7f3 --- /dev/null +++ b/flexiapi/app/Http/Requests/Space/Create.php @@ -0,0 +1,38 @@ +. +*/ + +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()], + ]; + } +} diff --git a/flexiapi/resources/views/api/documentation_markdown.blade.php b/flexiapi/resources/views/api/documentation_markdown.blade.php index 30c2b2e..6005b4c 100644 --- a/flexiapi/resources/views/api/documentation_markdown.blade.php +++ b/flexiapi/resources/views/api/documentation_markdown.blade.php @@ -140,13 +140,14 @@ Get a Space. ### `POST /spaces` Super Admin -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` diff --git a/flexiapi/tests/Feature/ApiSpaceTest.php b/flexiapi/tests/Feature/ApiSpaceTest.php index d4ada00..4300988 100644 --- a/flexiapi/tests/Feature/ApiSpaceTest.php +++ b/flexiapi/tests/Feature/ApiSpaceTest.php @@ -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);