diff --git a/CHANGELOG.md b/CHANGELOG.md index ac78ca5..e58352d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Flexisip Account Manager Changelog +v1.6.9 +--- +- Fix FLEXIAPI-378 Return a valid JSON containing the vCard and not the raw vCard in VcardsStorage controller + v1.6.8 --- - Fix FLEXIAPI-375 Fix VcardsStorage table UUID size, recover the UUID from the stored vCard diff --git a/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php b/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php index 6e06b98..2bf270b 100644 --- a/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php +++ b/flexiapi/app/Http/Controllers/Api/Admin/VcardsStorageController.php @@ -57,7 +57,7 @@ class VcardsStorageController extends Controller $vcard->vcard = preg_replace('/\r\n?/', "\n", $vcardo->serialize()); $vcard->save(); - return $vcard->vcard; + return $vcard; } public function update(Request $request, int $accountId, string $uuid) @@ -76,7 +76,7 @@ class VcardsStorageController extends Controller $vcard->vcard = preg_replace('/\r\n?/', "\n", $vcardo->serialize()); $vcard->save(); - return $vcard->vcard; + return $vcard; } public function destroy(int $accountId, string $uuid) diff --git a/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php b/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php index f77a486..0b000fc 100644 --- a/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php +++ b/flexiapi/tests/Feature/ApiAccountVcardsStorageTest.php @@ -95,13 +95,23 @@ VERSION:4.0 FN:Simon Perreault UID:' . $uid . ' END:VCARD' - ])->assertStatus(200); + ])->assertJsonFragment([ + 'vcard' => +'BEGIN:VCARD +VERSION:4.0 +FN:Simon Perreault +UID:' . $uid . ' +END:VCARD +' + ])->assertStatus(201); // Admin create $this->keyAuthenticated($admin) ->json($this->method, $adminRoute, [ 'vcard' => $thirdVcard]) - ->assertStatus(200); + ->assertJson([ + 'vcard' => $thirdVcard + ])->assertStatus(201); // Again... $this->keyAuthenticated($account) @@ -117,7 +127,7 @@ END:VCARD' $this->keyAuthenticated($account) ->json($this->method, $this->route, [ 'vcard' => $secondVcard - ])->assertStatus(200); + ])->assertStatus(201); $this->assertDatabaseHas('vcards_storage', [ 'uuid' => $uid @@ -135,6 +145,8 @@ END:VCARD' $this->keyAuthenticated($account) ->json('PUT', $this->route . '/' . $uid, [ 'vcard' => $lastVcard + ])->assertJsonFragment([ + 'vcard' => $lastVcard ])->assertStatus(200); // Update with wrong UID @@ -161,7 +173,7 @@ END:VCARD' $this->keyAuthenticated($account) ->get($this->route . '/' . $uid) ->assertStatus(200) - ->assertJson([ + ->assertJsonFragment([ 'vcard' => $lastVcard ]); @@ -169,7 +181,7 @@ END:VCARD' $this->keyAuthenticated($admin) ->get($adminRoute . '/' . $uid) ->assertStatus(200) - ->assertJson([ + ->assertJsonFragment([ 'vcard' => $lastVcard ]);