Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Infrastructure/ChwalaTest.php
- This file was added.
<?php | |||||
namespace Tests\Infrastructure; | |||||
use Tests\TestCase; | |||||
class ChwalaTest extends TestCase | |||||
{ | |||||
private \GuzzleHttp\Client $client; | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function setUp(): void | |||||
{ | |||||
parent::setUp(); | |||||
//FIXME test users are probably not created in imap, | |||||
//which is why this fails. So we're using john@kolab.org for now. | |||||
// $user = $this->getTestUser('jane@kolabnow.com'); | |||||
// $user->password = "simple123"; | |||||
// $user->save(); | |||||
$this->client = new \GuzzleHttp\Client([ | |||||
'base_uri' => "http://roundcube/chwala/", | |||||
'verify' => false, | |||||
// 'auth' => [$user->email, $user->password], | |||||
'auth' => ['john@kolab.org', 'simple123'], | |||||
'connect_timeout' => 10, | |||||
'timeout' => 10 | |||||
]); | |||||
} | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function tearDown(): void | |||||
{ | |||||
// $this->deleteTestUser('jane@kolabnow.com'); | |||||
parent::tearDown(); | |||||
} | |||||
public function testAccess() | |||||
{ | |||||
$response = $this->client->request('GET', 'api/?method=authenticate&version=4'); | |||||
$this->assertEquals($response->getStatusCode(), 200); | |||||
$json = json_decode($response->getBody(), true); | |||||
$this->assertEquals('OK', $json['status']); | |||||
$token = $json['result']['token']; | |||||
$this->assertTrue(!empty($token)); | |||||
//FIXME the session token doesn't seem to be required here? | |||||
$response = $this->client->request('GET', 'api/?method=mimetypes', [ | |||||
'headers' => [ | |||||
'X-Session_token' => $token | |||||
] | |||||
]); | |||||
$this->assertEquals($response->getStatusCode(), 200); | |||||
$json = json_decode($response->getBody(), true); | |||||
$this->assertEquals('OK', $json['status']); | |||||
$this->assertEquals('OK', $json['status']); | |||||
$this->assertContains('image/png', $json['result']['view']); | |||||
$this->assertArrayHasKey('text/plain', $json['result']['edit']); | |||||
} | |||||
} |