Skip to content

Commit

Permalink
fix: composer v2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Naugrimm committed May 15, 2023
1 parent ef867e6 commit cd0bb14
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/Controller/RepoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function providerV2(Request $request, Organization $organization, string
throw new NotFoundHttpException();
}

$response = (new JsonResponse($providerData))
$response = (new JsonResponse(['packages' => $providerData]))
->setLastModified($lastModified)
->setPrivate();

Expand All @@ -169,6 +169,20 @@ public function providerV2(Request $request, Organization $organization, string
return $response;
}

/**
* @Route("/p2/{package}~dev.json",
* host="{organization}{sep1}repo{sep2}{domain}",
* name="repo_package_provider_v2_dev",
* methods={"GET"},
* defaults={"domain":"%domain%","sep1"="%organization_separator%","sep2"="%domain_separator%"},
* requirements={"domain"="%domain%","package"="%package_name_pattern%","sep1"="%organization_separator%","sep2"="%domain_separator%"})
* @Cache(public=false)
*/
public function providerV2Dev(Request $request, Organization $organization, string $package): JsonResponse
{
return $this->providerV2($request, $organization, $package);
}

/**
* @return array<string, string>
*/
Expand Down
32 changes: 31 additions & 1 deletion tests/Functional/Controller/RepoControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function testProviderV2Action(): void

self::assertMatchesPattern('
{
"buddy-works/repman": {
"packages": "buddy-works/repman": {
"1.2.3": {
"version": "1.2.3",
"version_normalized": "1.2.3.0",
Expand Down Expand Up @@ -254,4 +254,34 @@ public function testProviderV2ForMissingPackage(): void

self::assertTrue($this->client->getResponse()->isNotFound());
}

public function testProviderV2DevAction(): void
{
$adminId = $this->createAndLoginAdmin('[email protected]', 'secret');
$this->fixtures->createToken($this->fixtures->createOrganization('buddy', $adminId), 'secret-org-token');

$this->client->request('GET', '/p2/buddy-works/repman~dev.json', [], [], [
'HTTP_HOST' => 'buddy.repo.repman.wip',
'PHP_AUTH_USER' => 'token',
'PHP_AUTH_PW' => 'secret-org-token',
]);

self::assertTrue($this->client->getResponse()->isOk());

self::assertMatchesPattern('
{
"packages": "buddy-works/repman": {
"1.2.3": {
"version": "1.2.3",
"version_normalized": "1.2.3.0",
"dist": {
"type": "zip",
"url": "/path/to/reference.zip",
"reference": "ac7dcaf888af2324cd14200769362129c8dd8550"
}
}
}
}
', $this->client->getResponse()->getContent());
}
}

0 comments on commit cd0bb14

Please sign in to comment.