2018-11-09 18:22:43 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
2019-11-28 08:16:50 +08:00
|
|
|
* For detailed copyright and license information, please view the
|
|
|
|
* LICENSE file that was distributed with this source code.
|
2018-11-09 18:22:43 +08:00
|
|
|
*/
|
|
|
|
|
2020-03-27 19:22:22 +08:00
|
|
|
namespace Flarum\Tests\integration\api\users;
|
2018-11-09 18:22:43 +08:00
|
|
|
|
2020-03-27 19:22:22 +08:00
|
|
|
use Flarum\Tests\integration\RetrievesAuthorizedUsers;
|
|
|
|
use Flarum\Tests\integration\TestCase;
|
2018-11-09 18:22:43 +08:00
|
|
|
|
2020-03-27 19:22:22 +08:00
|
|
|
class UpdateTest extends TestCase
|
2018-11-09 18:22:43 +08:00
|
|
|
{
|
2020-03-27 19:22:22 +08:00
|
|
|
use RetrievesAuthorizedUsers;
|
2018-11-09 18:22:43 +08:00
|
|
|
|
2021-01-07 11:16:26 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2020-03-28 08:26:26 +08:00
|
|
|
protected function setUp(): void
|
2019-01-31 04:15:27 +08:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->prepareDatabase([
|
|
|
|
'users' => [
|
|
|
|
$this->normalUser(),
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
}
|
2018-11-09 18:22:43 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function users_can_see_their_private_information()
|
|
|
|
{
|
2020-03-27 19:22:22 +08:00
|
|
|
$response = $this->send(
|
|
|
|
$this->request('PATCH', '/api/users/2', [
|
|
|
|
'authenticatedAs' => 2,
|
|
|
|
'json' => [],
|
|
|
|
])
|
|
|
|
);
|
2018-11-09 18:22:43 +08:00
|
|
|
|
|
|
|
// Test for successful response and that the email is included in the response
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
2021-01-27 06:53:28 +08:00
|
|
|
$this->assertStringContainsString('normal@machine.local', (string) $response->getBody());
|
2018-11-09 18:22:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function users_can_not_see_other_users_private_information()
|
|
|
|
{
|
2020-03-27 19:22:22 +08:00
|
|
|
$response = $this->send(
|
|
|
|
$this->request('PATCH', '/api/users/1', [
|
|
|
|
'authenticatedAs' => 2,
|
|
|
|
'json' => [],
|
|
|
|
])
|
|
|
|
);
|
2018-11-09 18:22:43 +08:00
|
|
|
|
|
|
|
// Make sure sensitive information is not made public
|
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
2021-01-27 06:53:28 +08:00
|
|
|
$this->assertStringNotContainsString('admin@machine.local', (string) $response->getBody());
|
2018-11-09 18:22:43 +08:00
|
|
|
}
|
|
|
|
}
|