Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Infrastructure/AutodiscoverTest.php
- This file was added.
<?php | |||||
namespace Tests\Infrastructure; | |||||
use Tests\TestCase; | |||||
class AutodiscoverTest extends TestCase | |||||
{ | |||||
private static ?\GuzzleHttp\Client $client = null; | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function setUp(): void | |||||
{ | |||||
parent::setUp(); | |||||
if (!self::$client) { | |||||
self::$client = new \GuzzleHttp\Client([ | |||||
'http_errors' => false, // No exceptions | |||||
machniak: This too needs to be configurable. The chwala and webmail locations too. Then maybe instead of… | |||||
Done Inline ActionsI understand the sentiment, but until we actually use the configs elsewhere I don't think it matters (which is why I didn't do it in the first place). I like the idea of having a services.php file, and another variable in there also doesn't hurt, so I'll do that. mollekopf: I understand the sentiment, but until we actually use the configs elsewhere I don't think it… | |||||
'base_uri' => "http://roundcube/", | |||||
'verify' => false, | |||||
'connect_timeout' => 10, | |||||
'timeout' => 10, | |||||
]); | |||||
} | |||||
} | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function tearDown(): void | |||||
{ | |||||
parent::tearDown(); | |||||
} | |||||
public function testWellKnownOutlook() | |||||
{ | |||||
$body = <<<EOF | |||||
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"> | |||||
<Request> | |||||
<EMailAddress>admin@example.local</EMailAddress> | |||||
<AcceptableResponseSchema> | |||||
http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a | |||||
</AcceptableResponseSchema> | |||||
</Request> | |||||
</Autodiscover> | |||||
EOF; | |||||
$response = self::$client->request('POST', 'autodiscover/autodiscover.xml', [ | |||||
'headers' => [ | |||||
"Content-Type" => "text/xml; charset=utf-8" | |||||
], | |||||
'body' => $body | |||||
]); | |||||
$this->assertEquals($response->getStatusCode(), 200); | |||||
$data = $response->getBody(); | |||||
$this->assertTrue(str_contains($data, '<Server>example.local</Server>')); | |||||
$this->assertTrue(str_contains($data, 'admin@example.local')); | |||||
} | |||||
public function testWellKnownActivesync() | |||||
{ | |||||
$body = <<<EOF | |||||
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006"> | |||||
<Request> | |||||
<EMailAddress>admin@example.local</EMailAddress> | |||||
<AcceptableResponseSchema> | |||||
http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006 | |||||
</AcceptableResponseSchema> | |||||
</Request> | |||||
</Autodiscover> | |||||
EOF; | |||||
$response = self::$client->request('POST', 'autodiscover/autodiscover.xml', [ | |||||
'headers' => [ | |||||
"Content-Type" => "text/xml; charset=utf-8" | |||||
], | |||||
'body' => $body | |||||
]); | |||||
$this->assertEquals($response->getStatusCode(), 200); | |||||
$data = $response->getBody(); | |||||
$this->assertTrue(str_contains($data, '<Url>https://example.local/Microsoft-Server-ActiveSync</Url>')); | |||||
$this->assertTrue(str_contains($data, 'admin@example.local')); | |||||
} | |||||
public function testWellKnownMail() | |||||
{ | |||||
$response = self::$client->request( | |||||
'GET', | |||||
'.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=fred@example.com' | |||||
); | |||||
$this->assertEquals($response->getStatusCode(), 200); | |||||
} | |||||
} |
This too needs to be configurable. The chwala and webmail locations too. Then maybe instead of creating a separate config file for each "self" service we should put them somewhere together, e.g. in services.php or another file?