Skip to content

Commit fa810fd

Browse files
committed
some fix
1 parent dc77265 commit fa810fd

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

api/config/packages/messenger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ when@test:
2626
framework:
2727
messenger:
2828
transports:
29-
async: 'in-memory://'
29+
async: 'sync://'

api/src/Consumer/Handler/BuildArchive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class BuildArchive
88
{
9-
public function __construct(private string $id = '')
9+
public function __construct(private string $id)
1010
{
1111
}
1212

api/src/Security/ApiClientAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function authenticate(Request $request): Passport
3535
$auth = $request->headers->get('Authorization');
3636
$parts = explode(':', $auth, 2);
3737
if (2 !== count($parts)) {
38-
throw new CustomUserMessageAuthenticationException('Invalid authorization explode');
38+
throw new CustomUserMessageAuthenticationException('Invalid token format');
3939
}
4040

4141
$userIdentifier = $parts[0];

api/tests/Archive/ArchiveApiTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,31 @@ public function testPostArchive(): void
3434
$id = $json['id'];
3535
$this->assertMatchesRegularExpression('#^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$#', $id);
3636
$this->assertEquals($identifier, $json['identifier']);
37-
$this->assertEquals('created', $json['status']);
37+
$this->assertEquals('ready', $json['status']);
3838
$this->assertArrayHasKey('downloadUrl', $json);
3939
$this->assertMatchesRegularExpression(sprintf('#^http://localhost/archives/%s/download\?jwt=.+$#', $id), $json['downloadUrl']);
4040

4141
$archive = $this->getArchiveFromDatabase($id);
4242
$this->expectedFiles($files, $archive);
43+
44+
$archivePath = $this->getArchiveDir().DIRECTORY_SEPARATOR.$id.'.zip';
45+
$this->assertTrue(file_exists($archivePath));
46+
47+
$response = $this->request('GET', $json['downloadUrl']);
48+
$html = $response->getContent();
49+
if (1 !== preg_match('#document\.location = \'([^\']+)\'#', $html, $matches)) {
50+
throw new \Exception('Cannot find redirect location in HTML');
51+
}
52+
$downloadUrl = $matches[1];
53+
54+
ob_start();
55+
ob_start();
56+
$response = $this->request('GET', $downloadUrl);
57+
ob_end_clean();
58+
ob_end_clean();
59+
$this->assertEquals('attachment; filename="foo.zip"', $response->getHeaders()['content-disposition'][0]);
60+
61+
$this->removeArchive($id);
4362
}
4463

4564
public function testPutArchiveReturnsMethodNotAllowed(): void

api/tests/Archive/PostArchiveApiTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,17 @@ private function doTestPostArchiveOK(array $files, array $options = []): void
9191
} else {
9292
$this->assertNull($json['expiresAt']);
9393
}
94-
$this->assertEquals('created', $json['status']);
94+
$this->assertEquals('ready', $json['status']);
9595
$this->assertArrayHasKey('downloadUrl', $json);
9696
$this->assertMatchesRegularExpression(sprintf('#^http://localhost/archives/%s/download\?jwt=.+$#', $id), $json['downloadUrl']);
9797

9898
$archive = $this->getArchiveFromDatabase($id);
9999
$this->expectedFiles($files, $archive);
100+
101+
$archivePath = $this->getArchiveDir().DIRECTORY_SEPARATOR.$id.'.zip';
102+
$this->assertTrue(file_exists($archivePath));
103+
104+
$this->removeArchive($id);
100105
}
101106

102107
public function testPostArchiveWithEmptyIdentifierReturns422(): void

0 commit comments

Comments
 (0)