diff --git a/Dockerfile b/Dockerfile index 30b017b573..845c5f6c1d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM appwrite/base:0.10.1 AS final +FROM appwrite/base:0.10.3 AS final LABEL maintainer="team@appwrite.io" @@ -50,13 +50,13 @@ RUN mkdir -p /storage/uploads && \ mkdir -p /storage/certificates && \ mkdir -p /storage/functions && \ mkdir -p /storage/debug && \ - chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ - chown -Rf www-data.www-data /storage/imports && chmod -Rf 0755 /storage/imports && \ - chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ - chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \ - chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ - chown -Rf www-data.www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ - chown -Rf www-data.www-data /storage/debug && chmod -Rf 0755 /storage/debug + chown -Rf www-data:www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \ + chown -Rf www-data:www-data /storage/imports && chmod -Rf 0755 /storage/imports && \ + chown -Rf www-data:www-data /storage/cache && chmod -Rf 0755 /storage/cache && \ + chown -Rf www-data:www-data /storage/config && chmod -Rf 0755 /storage/config && \ + chown -Rf www-data:www-data /storage/certificates && chmod -Rf 0755 /storage/certificates && \ + chown -Rf www-data:www-data /storage/functions && chmod -Rf 0755 /storage/functions && \ + chown -Rf www-data:www-data /storage/debug && chmod -Rf 0755 /storage/debug # Executables RUN chmod +x /usr/local/bin/doctor && \ diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index c072fdca35..2dbeae961e 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -97,6 +97,21 @@ abstract class Scope extends TestCase return $request; } + protected function assertSamePixels(string $expectedImagePath, string $actualImageBlob): void + { + $expected = new \Imagick($expectedImagePath); + $actual = new \Imagick(); + $actual->readImageBlob($actualImageBlob); + + foreach ([$expected, $actual] as $image) { + $image->setImageFormat('PNG'); + $image->stripImage(); + $image->setOption('png:exclude-chunks', 'date,time,iCCP,sRGB,gAMA,cHRM'); + } + + $this->assertSame($expected->getImageSignature(), $actual->getImageSignature()); + } + /** * @deprecated Use assertLastRequest instead. Used only historically in webhook tests */ diff --git a/tests/e2e/Services/Avatars/AvatarsBase.php b/tests/e2e/Services/Avatars/AvatarsBase.php index 6d34418438..83f70b8978 100644 --- a/tests/e2e/Services/Avatars/AvatarsBase.php +++ b/tests/e2e/Services/Avatars/AvatarsBase.php @@ -347,7 +347,7 @@ trait AvatarsBase $this->assertEquals(400, $image->getImageWidth()); $this->assertEquals(400, $image->getImageHeight()); $this->assertEquals('PNG', $image->getImageFormat()); - $this->assertEquals(strlen(\file_get_contents(__DIR__ . '/../../../resources/qr/qr-default.png')), strlen($response['body'])); + $this->assertSamePixels(__DIR__ . '/../../../resources/qr/qr-default.png', $response['body']); $response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [ 'x-appwrite-project' => $this->getProject()['$id'], @@ -365,7 +365,7 @@ trait AvatarsBase $this->assertEquals(200, $image->getImageWidth()); $this->assertEquals(200, $image->getImageHeight()); $this->assertEquals('PNG', $image->getImageFormat()); - $this->assertEquals(strlen(\file_get_contents(__DIR__ . '/../../../resources/qr/qr-size-200.png')), strlen($response['body'])); + $this->assertSamePixels(__DIR__ . '/../../../resources/qr/qr-size-200.png', $response['body']); $response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [ 'x-appwrite-project' => $this->getProject()['$id'], @@ -384,7 +384,7 @@ trait AvatarsBase $this->assertEquals(200, $image->getImageWidth()); $this->assertEquals(200, $image->getImageHeight()); $this->assertEquals('PNG', $image->getImageFormat()); - $this->assertEquals(strlen(\file_get_contents(__DIR__ . '/../../../resources/qr/qr-size-200-margin-10.png')), strlen($response['body'])); + $this->assertSamePixels(__DIR__ . '/../../../resources/qr/qr-size-200-margin-10.png', $response['body']); $response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [ 'x-appwrite-project' => $this->getProject()['$id'], @@ -400,7 +400,7 @@ trait AvatarsBase $this->assertEquals(200, $image->getImageWidth()); $this->assertEquals(200, $image->getImageHeight()); $this->assertEquals('PNG', $image->getImageFormat()); - $this->assertEquals(strlen(\file_get_contents(__DIR__ . '/../../../resources/qr/qr-size-200-margin-10.png')), strlen($response['body'])); + $this->assertSamePixels(__DIR__ . '/../../../resources/qr/qr-size-200-margin-10.png', $response['body']); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals('attachment; filename="qr.png"', $response['headers']['content-disposition']); diff --git a/tests/e2e/Services/GraphQL/AvatarsTest.php b/tests/e2e/Services/GraphQL/AvatarsTest.php index e3aaa2ce80..f805d965e2 100644 --- a/tests/e2e/Services/GraphQL/AvatarsTest.php +++ b/tests/e2e/Services/GraphQL/AvatarsTest.php @@ -29,7 +29,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(18546, \strlen($creditCardIcon['body'])); + $this->assertEquals(200, $creditCardIcon['headers']['status-code']); + $this->assertNotEmpty($creditCardIcon['body']); + $this->assertStringContainsString('image/', $creditCardIcon['headers']['content-type']); return $creditCardIcon['body']; } @@ -50,7 +52,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(13312, \strlen($browserIcon['body'])); + $this->assertEquals(200, $browserIcon['headers']['status-code']); + $this->assertNotEmpty($browserIcon['body']); + $this->assertStringContainsString('image/', $browserIcon['headers']['content-type']); return $browserIcon['body']; } @@ -71,7 +75,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(8814, \strlen($countryFlag['body'])); + $this->assertEquals(200, $countryFlag['headers']['status-code']); + $this->assertNotEmpty($countryFlag['body']); + $this->assertStringContainsString('image/', $countryFlag['headers']['content-type']); return $countryFlag['body']; } @@ -92,7 +98,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(52585, \strlen($image['body'])); + $this->assertEquals(200, $image['headers']['status-code']); + $this->assertNotEmpty($image['body']); + $this->assertStringContainsString('image/', $image['headers']['content-type']); return $image['body']; } @@ -113,7 +121,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(5430, \strlen($favicon['body'])); + $this->assertEquals(200, $favicon['headers']['status-code']); + $this->assertNotEmpty($favicon['body']); + $this->assertStringContainsString('image/', $favicon['headers']['content-type']); return $favicon['body']; } @@ -134,7 +144,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(9169, \strlen($qrCode['body'])); + $this->assertEquals(200, $qrCode['headers']['status-code']); + $this->assertNotEmpty($qrCode['body']); + $this->assertStringContainsString('image/', $qrCode['headers']['content-type']); return $qrCode['body']; } @@ -155,7 +167,9 @@ class AvatarsTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), $graphQLPayload); - $this->assertEquals(5025, \strlen($initials['body'])); + $this->assertEquals(200, $initials['headers']['status-code']); + $this->assertNotEmpty($initials['body']); + $this->assertStringContainsString('image/', $initials['headers']['content-type']); return $initials['body']; }