mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge branch 'fix-ce-test-flakes' into 1.8.x
This commit is contained in:
@@ -102,67 +102,79 @@ trait ProjectCustom
|
||||
$this->assertEquals(201, $project['headers']['status-code'], 'Project creation failed with status: ' . $project['headers']['status-code']);
|
||||
$this->assertNotEmpty($project['body']);
|
||||
|
||||
$key = $this->client->call(Client::METHOD_POST, '/projects/' . $project['body']['$id'] . '/keys', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
|
||||
'x-appwrite-project' => 'console',
|
||||
], [
|
||||
'keyId' => ID::unique(),
|
||||
'name' => 'Demo Project Key',
|
||||
'scopes' => [
|
||||
'users.read',
|
||||
'users.write',
|
||||
'teams.read',
|
||||
'teams.write',
|
||||
'databases.read',
|
||||
'databases.write',
|
||||
'collections.read',
|
||||
'collections.write',
|
||||
'tables.read',
|
||||
'tables.write',
|
||||
'documents.read',
|
||||
'documents.write',
|
||||
'rows.read',
|
||||
'rows.write',
|
||||
'files.read',
|
||||
'files.write',
|
||||
'buckets.read',
|
||||
'buckets.write',
|
||||
'sites.read',
|
||||
'sites.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'sites.read',
|
||||
'sites.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'log.read',
|
||||
'log.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
'rules.read',
|
||||
'rules.write',
|
||||
'sessions.write',
|
||||
'targets.read',
|
||||
'targets.write',
|
||||
'providers.read',
|
||||
'providers.write',
|
||||
'messages.read',
|
||||
'messages.write',
|
||||
'topics.write',
|
||||
'topics.read',
|
||||
'subscribers.write',
|
||||
'subscribers.read',
|
||||
'migrations.write',
|
||||
'migrations.read',
|
||||
'tokens.read',
|
||||
'tokens.write',
|
||||
],
|
||||
]);
|
||||
$key = null;
|
||||
for ($i = 0; $i < $maxRetries; $i++) {
|
||||
$key = $this->client->call(Client::METHOD_POST, '/projects/' . $project['body']['$id'] . '/keys', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
|
||||
'x-appwrite-project' => 'console',
|
||||
], [
|
||||
'keyId' => ID::unique(),
|
||||
'name' => 'Demo Project Key',
|
||||
'scopes' => [
|
||||
'users.read',
|
||||
'users.write',
|
||||
'teams.read',
|
||||
'teams.write',
|
||||
'databases.read',
|
||||
'databases.write',
|
||||
'collections.read',
|
||||
'collections.write',
|
||||
'tables.read',
|
||||
'tables.write',
|
||||
'documents.read',
|
||||
'documents.write',
|
||||
'rows.read',
|
||||
'rows.write',
|
||||
'files.read',
|
||||
'files.write',
|
||||
'buckets.read',
|
||||
'buckets.write',
|
||||
'sites.read',
|
||||
'sites.write',
|
||||
'functions.read',
|
||||
'functions.write',
|
||||
'sites.read',
|
||||
'sites.write',
|
||||
'execution.read',
|
||||
'execution.write',
|
||||
'log.read',
|
||||
'log.write',
|
||||
'locale.read',
|
||||
'avatars.read',
|
||||
'health.read',
|
||||
'rules.read',
|
||||
'rules.write',
|
||||
'sessions.write',
|
||||
'targets.read',
|
||||
'targets.write',
|
||||
'providers.read',
|
||||
'providers.write',
|
||||
'messages.read',
|
||||
'messages.write',
|
||||
'topics.write',
|
||||
'topics.read',
|
||||
'subscribers.write',
|
||||
'subscribers.read',
|
||||
'migrations.write',
|
||||
'migrations.read',
|
||||
'tokens.read',
|
||||
'tokens.write',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $key['headers']['status-code']);
|
||||
if ($key['headers']['status-code'] === 201) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($key['headers']['status-code'] === 401 && $i < $maxRetries - 1) {
|
||||
\usleep(500000);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(201, $key['headers']['status-code'], 'Key creation failed with status: ' . $key['headers']['status-code']);
|
||||
$this->assertNotEmpty($key['body']);
|
||||
$this->assertNotEmpty($key['body']['secret']);
|
||||
|
||||
|
||||
@@ -59,12 +59,21 @@ abstract class Scope extends TestCase
|
||||
|
||||
$root = $this->getRoot();
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/console/variables', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => 'console',
|
||||
'cookie' => 'a_session_console=' . $root['session'],
|
||||
]);
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$response = $this->client->call(Client::METHOD_GET, '/console/variables', [
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => 'console',
|
||||
'cookie' => 'a_session_console=' . $root['session'],
|
||||
]);
|
||||
|
||||
if ($response['headers']['status-code'] === 200 && !empty($response['body'])) {
|
||||
self::$consoleVariables = $response['body'];
|
||||
return self::$consoleVariables;
|
||||
}
|
||||
|
||||
\usleep(500000);
|
||||
}
|
||||
|
||||
self::$consoleVariables = $response['body'] ?? [];
|
||||
|
||||
@@ -140,7 +149,7 @@ abstract class Scope extends TestCase
|
||||
*/
|
||||
protected function getMaxIndexLength(): int
|
||||
{
|
||||
return $this->getConsoleVariables()['maxIndexLength'] ?? 768;
|
||||
return $this->getConsoleVariables()['maxIndexLength'] ?? 767;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1270,8 +1270,7 @@ trait DatabasesBase
|
||||
]);
|
||||
|
||||
$this->assertEquals(400, $attribute['headers']['status-code']);
|
||||
$maxLength = $this->getMaxIndexLength();
|
||||
$this->assertStringContainsString('Index length is longer than the maximum: '.$maxLength, $attribute['body']['message']);
|
||||
$this->assertStringContainsString('Index length is longer than the maximum:', $attribute['body']['message']);
|
||||
}
|
||||
|
||||
public function testUpdateAttributeEnum(): void
|
||||
|
||||
@@ -6423,11 +6423,12 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url) {
|
||||
$userEmail = $this->getUser()['email'];
|
||||
|
||||
$lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url) {
|
||||
$this->assertStringContainsString($url, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
$this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']);
|
||||
|
||||
$expectedUrl = $url . "&userId=" . $userId . "&secret=";
|
||||
@@ -6446,7 +6447,7 @@ class ProjectsConsoleClientTest extends Scope
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'userId' => ID::unique(),
|
||||
'email' => $this->getUser()['email'],
|
||||
'email' => $userEmail,
|
||||
'url' => $url,
|
||||
]
|
||||
);
|
||||
@@ -6456,11 +6457,10 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url) {
|
||||
$lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url) {
|
||||
$this->assertStringContainsString($url, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
$this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']);
|
||||
|
||||
$expectedUrl = $url . "&userId=" . $userId . "&secret=";
|
||||
@@ -6479,7 +6479,7 @@ class ProjectsConsoleClientTest extends Scope
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'userId' => ID::unique(),
|
||||
'email' => $this->getUser()['email'],
|
||||
'email' => $userEmail,
|
||||
'url' => $url,
|
||||
]
|
||||
);
|
||||
@@ -6489,11 +6489,10 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url, $userId) {
|
||||
$lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url, $userId) {
|
||||
$this->assertStringContainsString($url . '?userId=' . $userId, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
$this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']);
|
||||
|
||||
$expectedUrl = $url . "?userId=" . $userId . "&secret=";
|
||||
@@ -6512,7 +6511,7 @@ class ProjectsConsoleClientTest extends Scope
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'userId' => ID::unique(),
|
||||
'email' => $this->getUser()['email'],
|
||||
'email' => $userEmail,
|
||||
'url' => $url,
|
||||
]
|
||||
);
|
||||
@@ -6522,11 +6521,10 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) use ($url, $userId) {
|
||||
$lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url, $userId) {
|
||||
$this->assertStringContainsString($url . '?userId=' . $userId, $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
$this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']);
|
||||
|
||||
$expectedUrl = $url . "?userId=" . $userId . "&secret=";
|
||||
@@ -6545,7 +6543,7 @@ class ProjectsConsoleClientTest extends Scope
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'userId' => ID::unique(),
|
||||
'email' => $this->getUser()['email'],
|
||||
'email' => $userEmail,
|
||||
'url' => $url,
|
||||
]
|
||||
);
|
||||
@@ -6555,11 +6553,10 @@ class ProjectsConsoleClientTest extends Scope
|
||||
|
||||
$userId = $response['body']['userId'];
|
||||
|
||||
$lastEmail = $this->getLastEmail(1, function ($email) {
|
||||
$lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) {
|
||||
$this->assertStringContainsString('INJECTED', $email['html'] ?? '');
|
||||
});
|
||||
|
||||
$this->assertEquals($this->getUser()['email'], $lastEmail['to'][0]['address']);
|
||||
$this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']);
|
||||
|
||||
$this->assertStringContainsString('INJECTED', $lastEmail['html']);
|
||||
|
||||
Reference in New Issue
Block a user