1
0
Fork 0
mirror of synced 2024-09-28 07:21:35 +12:00

Fix more failing tests

This commit is contained in:
Matej Baco 2022-11-18 14:13:33 +01:00
parent b39aa060c8
commit 5ec548cc06
4 changed files with 23 additions and 5 deletions

2
.env
View file

@ -63,7 +63,7 @@ _APP_MAINTENANCE_RETENTION_EXECUTION=1209600
_APP_MAINTENANCE_RETENTION_ABUSE=86400
_APP_MAINTENANCE_RETENTION_AUDIT=1209600
_APP_MAINTENANCE_RETENTION_SCHEDULES=86400
_APP_USAGE_TIMESERIES_INTERVAL=15
_APP_USAGE_TIMESERIES_INTERVAL=20
_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000
_APP_USAGE_STATS=enabled
_APP_LOGGING_PROVIDER=

View file

@ -279,6 +279,7 @@ App::get('/v1/account/sessions/oauth2/:provider')
->action(function (string $provider, string $success, string $failure, array $scopes, Request $request, Response $response, Document $project) use ($oauthDefaultSuccess, $oauthDefaultFailure) {
$protocol = $request->getProtocol();
$callback = $protocol . '://' . $request->getHostname() . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId();
$appId = $project->getAttribute('authProviders', [])[$provider . 'Appid'] ?? '';
$appSecret = $project->getAttribute('authProviders', [])[$provider . 'Secret'] ?? '{}';

View file

@ -494,6 +494,7 @@ class TimeSeries extends Calculator
if (empty($point['projectInternalId'] ?? null)) {
continue;
}
$this->createOrUpdateMetric(
$point['projectInternalId'],
$point['time'],

View file

@ -97,6 +97,8 @@ class UsageTest extends Scope
'origin' => 'http://localhost',
'x-appwrite-project' => 'console',
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => $projectId,
'x-appwrite-mode' => 'admin',
];
$res = $this->client->call(Client::METHOD_GET, '/project/usage?range=30d', $headers);
@ -146,11 +148,20 @@ class UsageTest extends Scope
for ($i = 0; $i < 10; $i++) {
$name = uniqid() . ' bucket';
$res = $this->client->call(Client::METHOD_POST, '/storage/buckets', $headers, [
$res = $this->client->call(Client::METHOD_POST, '/storage/buckets', \array_merge($headers, [
'content-type' => 'application/json'
]), [
'bucketId' => 'unique()',
'name' => $name,
'permission' => 'bucket'
'fileSecurity' => false,
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
Permission::update(Role::any()),
Permission::delete(Role::any()),
],
]);
\var_dump($res['body']);
$this->assertEquals($name, $res['body']['name']);
$this->assertNotEmpty($res['body']['$id']);
$bucketId = $res['body']['$id'];
@ -263,9 +274,11 @@ class UsageTest extends Scope
'origin' => 'http://localhost',
'x-appwrite-project' => 'console',
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => $projectId,
'x-appwrite-mode' => 'admin',
];
$res = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/usage?range=30d', $headers);
$res = $this->client->call(Client::METHOD_GET, '/project/usage?range=30d', $headers);
$res = $res['body'];
$this->assertEquals(9, count($res));
@ -503,8 +516,11 @@ class UsageTest extends Scope
'origin' => 'http://localhost',
'x-appwrite-project' => 'console',
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
'x-appwrite-project' => $projectId,
'x-appwrite-mode' => 'admin',
];
$res = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/usage?range=30d', $headers);
$res = $this->client->call(Client::METHOD_GET, '/project/usage?range=30d', $headers);
$res = $res['body'];
$this->assertEquals(9, count($res));