1
0
Fork 0
mirror of synced 2024-06-14 08:44:49 +12:00

Fix storage tests

This commit is contained in:
Jake Barnby 2022-08-09 19:11:30 +12:00
parent 3611f9df94
commit a61fd030ff
8 changed files with 39 additions and 41 deletions

View file

@ -76,6 +76,7 @@
}
],
"require-dev": {
"ext-fileinfo": "*",
"appwrite/sdk-generator": "dev-master as 0.19.5",
"phpunit/phpunit": "9.5.20",
"squizlabs/php_codesniffer": "^3.6",

View file

@ -294,7 +294,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $deployment['headers']['status-code']);
$this->assertNotEmpty($deployment['body']['$id']);
$this->assertIsInt($deployment['body']['$createdAt']);
$this->assertIsString($deployment['body']['$createdAt']);
$this->assertEquals('index.php', $deployment['body']['entrypoint']);
// Wait for deployment to build.
@ -343,7 +343,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $largeTag['headers']['status-code']);
$this->assertNotEmpty($largeTag['body']['$id']);
$this->assertIsInt($largeTag['body']['$createdAt']);
$this->assertIsString($largeTag['body']['$createdAt']);
$this->assertEquals('index.php', $largeTag['body']['entrypoint']);
$this->assertGreaterThan(10000, $largeTag['body']['size']);
@ -487,7 +487,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertIsInt($execution['body']['$createdAt']);
$this->assertIsString($execution['body']['$createdAt']);
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('waiting', $execution['body']['status']);
$this->assertEquals(0, $execution['body']['statusCode']);
@ -504,7 +504,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($execution['body']['$id']);
$this->assertNotEmpty($execution['body']['functionId']);
$this->assertIsInt($execution['body']['$createdAt']);
$this->assertIsString($execution['body']['$createdAt']);
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals(200, $execution['body']['statusCode']);

View file

@ -49,7 +49,7 @@ trait StorageBase
]);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertIsInt($file['body']['$createdAt']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@ -118,7 +118,7 @@ trait StorageBase
$this->assertEquals(201, $largeFile['headers']['status-code']);
$this->assertNotEmpty($largeFile['body']['$id']);
$this->assertIsInt($largeFile['body']['$createdAt']);
$this->assertIsString($largeFile['body']['$createdAt']);
$this->assertEquals('large-file.mp4', $largeFile['body']['name']);
$this->assertEquals('video/mp4', $largeFile['body']['mimeType']);
$this->assertEquals($totalSize, $largeFile['body']['sizeOriginal']);
@ -219,8 +219,6 @@ trait StorageBase
$this->assertEquals(400, $res['headers']['status-code']);
$this->assertEquals('File extension not allowed', $res['body']['message']);
return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id']];
/**
* Test for FAILURE create bucket with too high limit (bigger then _APP_STORAGE_LIMIT)
*/
@ -241,7 +239,10 @@ trait StorageBase
'delete(any)',
],
]);
$this->assertEquals(400, $failedBucket['headers']['status-code']);
return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id']];
}
/**
@ -289,16 +290,10 @@ trait StorageBase
$this->assertEquals(200, $file1['headers']['status-code']);
$this->assertNotEmpty($file1['body']['$id']);
$this->assertIsInt($file1['body']['$createdAt']);
$this->assertIsString($file1['body']['$createdAt']);
$this->assertEquals('logo.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
$this->assertEquals(47218, $file1['body']['sizeOriginal']);
//$this->assertEquals(54944, $file1['body']['sizeActual']);
//$this->assertEquals('gzip', $file1['body']['algorithm']);
//$this->assertEquals('1', $file1['body']['fileOpenSSLVersion']);
//$this->assertEquals('aes-128-gcm', $file1['body']['fileOpenSSLCipher']);
//$this->assertNotEmpty($file1['body']['fileOpenSSLTag']);
//$this->assertNotEmpty($file1['body']['fileOpenSSLIV']);
$this->assertIsArray($file1['body']['$permissions']);
$this->assertCount(4, $file1['body']['$permissions']);
@ -593,7 +588,7 @@ trait StorageBase
$this->assertEquals(200, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertIsInt($file['body']['$createdAt']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);

View file

@ -52,7 +52,7 @@ class StorageCustomClientTest extends Scope
$fileId = $file['body']['$id'];
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($fileId);
$this->assertIsInt($file['body']['$createdAt']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@ -143,8 +143,10 @@ class StorageCustomClientTest extends Scope
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($file['body']['$id']);
$this->assertContains('user:' . $this->getUser()['$id'], $file['body']['$permissions']);
$this->assertIsInt($file['body']['$createdAt']);
$this->assertContains('read(user:' . $this->getUser()['$id'] . ')', $file['body']['$permissions']);
$this->assertContains('update(user:' . $this->getUser()['$id'] . ')', $file['body']['$permissions']);
$this->assertContains('delete(user:' . $this->getUser()['$id'] . ')', $file['body']['$permissions']);
$this->assertIsString($file['body']['$createdAt']);
$this->assertEquals('permissions.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
$this->assertEquals(47218, $file['body']['sizeOriginal']);
@ -173,7 +175,7 @@ class StorageCustomClientTest extends Scope
]);
$this->assertEquals(400, $file['headers']['status-code']);
$this->assertStringStartsWith('Read permissions must be one of:', $file['body']['message']);
$this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']);
$this->assertStringContainsString('any', $file['body']['message']);
$this->assertStringContainsString('users', $file['body']['message']);
$this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']);
@ -193,7 +195,7 @@ class StorageCustomClientTest extends Scope
]);
$this->assertEquals($file['headers']['status-code'], 400);
$this->assertStringStartsWith('Write permissions must be one of:', $file['body']['message']);
$this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']);
$this->assertStringContainsString('any', $file['body']['message']);
$this->assertStringContainsString('users', $file['body']['message']);
$this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']);
@ -214,7 +216,7 @@ class StorageCustomClientTest extends Scope
]);
$this->assertEquals($file['headers']['status-code'], 400);
$this->assertStringStartsWith('Read permissions must be one of:', $file['body']['message']);
$this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']);
$this->assertStringContainsString('any', $file['body']['message']);
$this->assertStringContainsString('users', $file['body']['message']);
$this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']);
@ -238,7 +240,7 @@ class StorageCustomClientTest extends Scope
]);
$this->assertEquals($file['headers']['status-code'], 400);
$this->assertStringStartsWith('Read permissions must be one of:', $file['body']['message']);
$this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']);
$this->assertStringContainsString('any', $file['body']['message']);
$this->assertStringContainsString('users', $file['body']['message']);
$this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']);
@ -255,7 +257,7 @@ class StorageCustomClientTest extends Scope
]);
$this->assertEquals($file['headers']['status-code'], 400);
$this->assertStringStartsWith('Write permissions must be one of:', $file['body']['message']);
$this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']);
$this->assertStringContainsString('any', $file['body']['message']);
$this->assertStringContainsString('users', $file['body']['message']);
$this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']);
@ -273,7 +275,7 @@ class StorageCustomClientTest extends Scope
]);
$this->assertEquals($file['headers']['status-code'], 400);
$this->assertStringStartsWith('Read permissions must be one of:', $file['body']['message']);
$this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']);
$this->assertStringContainsString('any', $file['body']['message']);
$this->assertStringContainsString('users', $file['body']['message']);
$this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']);

View file

@ -28,7 +28,7 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(201, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertIsInt($bucket['body']['$createdAt']);
$this->assertIsString($bucket['body']['$createdAt']);
$this->assertIsArray($bucket['body']['$permissions']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);
$this->assertEquals('Test Bucket', $bucket['body']['name']);
@ -186,7 +186,7 @@ class StorageCustomServerTest extends Scope
]);
$this->assertEquals(200, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$this->assertIsInt($bucket['body']['$createdAt']);
$this->assertIsString($bucket['body']['$createdAt']);
$this->assertIsArray($bucket['body']['$permissions']);
$this->assertIsArray($bucket['body']['allowedFileExtensions']);

View file

@ -45,7 +45,7 @@ trait TeamsBase
$this->assertEquals('Manchester United', $response2['body']['name']);
$this->assertGreaterThan(-1, $response2['body']['total']);
$this->assertIsInt($response2['body']['total']);
$this->assertIsInt($response2['body']['$createdAt']);
$this->assertIsString($response2['body']['$createdAt']);
$response3 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
@ -60,7 +60,7 @@ trait TeamsBase
$this->assertEquals('Newcastle', $response3['body']['name']);
$this->assertGreaterThan(-1, $response3['body']['total']);
$this->assertIsInt($response3['body']['total']);
$this->assertIsInt($response3['body']['$createdAt']);
$this->assertIsString($response3['body']['$createdAt']);
/**
* Test for FAILURE
@ -96,7 +96,7 @@ trait TeamsBase
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['$createdAt']);
$this->assertIsString($response['body']['$createdAt']);
/**
* Test for FAILURE
@ -260,7 +260,7 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['$createdAt']);
$this->assertIsString($response['body']['$createdAt']);
$response = $this->client->call(Client::METHOD_PUT, '/teams/' . $response['body']['$id'], array_merge([
'content-type' => 'application/json',
@ -275,7 +275,7 @@ trait TeamsBase
$this->assertEquals('Demo New', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['$createdAt']);
$this->assertIsString($response['body']['$createdAt']);
/**
* Test for FAILURE
@ -311,7 +311,7 @@ trait TeamsBase
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['$createdAt']);
$this->assertIsString($response['body']['$createdAt']);
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid, array_merge([
'content-type' => 'application/json',

View file

@ -204,7 +204,7 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(1, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['$createdAt']);
$this->assertIsString($response['body']['$createdAt']);
/** Delete User */
@ -230,6 +230,6 @@ trait TeamsBaseServer
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertEquals(0, $response['body']['total']);
$this->assertIsInt($response['body']['total']);
$this->assertIsInt($response['body']['$createdAt']);
$this->assertIsString($response['body']['$createdAt']);
}
}

View file

@ -527,7 +527,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertIsInt($webhook['data']['$createdAt']);
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@ -586,7 +586,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertIsInt($webhook['data']['$createdAt']);
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@ -636,7 +636,7 @@ trait WebhooksBase
$this->assertNotEmpty($webhook['data']['$id']);
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertEquals($webhook['data']['name'], 'logo.png');
$this->assertIsInt($webhook['data']['$createdAt']);
$this->assertIsString($webhook['data']['$createdAt']);
$this->assertNotEmpty($webhook['data']['signature']);
$this->assertEquals($webhook['data']['mimeType'], 'image/png');
$this->assertEquals($webhook['data']['sizeOriginal'], 47218);
@ -718,7 +718,7 @@ trait WebhooksBase
$this->assertEquals('Arsenal', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsInt($webhook['data']['$createdAt']);
$this->assertIsString($webhook['data']['$createdAt']);
/**
* Test for FAILURE
@ -763,7 +763,7 @@ trait WebhooksBase
$this->assertEquals('Demo New', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsInt($webhook['data']['$createdAt']);
$this->assertIsString($webhook['data']['$createdAt']);
/**
* Test for FAILURE
@ -812,7 +812,7 @@ trait WebhooksBase
$this->assertEquals('Chelsea', $webhook['data']['name']);
$this->assertGreaterThan(-1, $webhook['data']['total']);
$this->assertIsInt($webhook['data']['total']);
$this->assertIsInt($webhook['data']['$createdAt']);
$this->assertIsString($webhook['data']['$createdAt']);
/**
* Test for FAILURE