mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add more tests
This commit is contained in:
@@ -405,7 +405,6 @@ App::get('/v1/health/certificate')
|
||||
->param('domain', null, new Multiple([new Domain(), new PublicDomain()]), Multiple::TYPE_STRING, 'Domain name')
|
||||
->inject('response')
|
||||
->action(function (string $domain, Response $response) {
|
||||
// Extract domain from URL if provided
|
||||
if (filter_var($domain, FILTER_VALIDATE_URL)) {
|
||||
$domain = parse_url($domain, PHP_URL_HOST);
|
||||
}
|
||||
@@ -417,6 +416,14 @@ App::get('/v1/health/certificate')
|
||||
}
|
||||
$certificate = stream_context_get_params($read);
|
||||
$certificateInfo = openssl_x509_parse($certificate['options']['ssl']['peer_certificate']);
|
||||
$certificatePayload = [
|
||||
'name' => $certificateInfo['name'],
|
||||
'subject' => $certificateInfo['subject'],
|
||||
'issuer' => $certificateInfo['issuer'],
|
||||
'validFrom' => $certificateInfo['validFrom_time_t'],
|
||||
'validTo' => $certificateInfo['validTo_time_t'],
|
||||
'signatureTypeSN' => $certificateInfo['signatureTypeSN'],
|
||||
];
|
||||
$sslExpiration = $certificateInfo['validTo_time_t'];
|
||||
$status = ($sslExpiration < time()) ? 'fail' : 'pass';
|
||||
|
||||
|
||||
@@ -477,6 +477,13 @@ class HealthCustomServerTest extends Scope
|
||||
|
||||
$this->assertEquals(404, $response['headers']['status-code']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=www.google.com/usr/src/local', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user