Skip to content

Commit ac5cce2

Browse files
authored
Stop bypassing the organization endpoint for subscriptions (#1532)
1 parent 514bbcb commit ac5cce2

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

go-tests/project_create_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func TestProjectCreate(t *testing.T) {
4444
assert.Contains(t, stdErr, "Project ID: "+projectID)
4545
assert.Contains(t, stdErr, "Project title: "+title)
4646
assert.Contains(t, stdErr, "Console URL: "+consoleURL)
47+
48+
f.Run("subscription:info", "-p", projectID)
4749
}
4850

4951
func TestProjectCreate_CanCreateError(t *testing.T) {

src/Command/SubscriptionInfoCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4545
$id = $project->getSubscriptionId();
4646
}
4747

48-
$subscription = $this->api()->loadSubscription($id, $project, $input->getArgument('value') !== null);
48+
$subscription = $this->api()->loadSubscription($id, $project);
4949
if (!$subscription) {
5050
$this->stdErr->writeln(sprintf('Subscription not found: <error>%s</error>', $id));
5151

src/Service/Api.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,14 +1438,13 @@ private function on403(ErrorEvent $event)
14381438
*
14391439
* @param string $id
14401440
* @param Project|null $project
1441-
* @param bool $forWrite
14421441
*
14431442
* @throws \GuzzleHttp\Exception\RequestException
14441443
*
14451444
* @return false|Subscription
14461445
* The subscription or false if not found.
14471446
*/
1448-
public function loadSubscription($id, Project $project = null, $forWrite = true)
1447+
public function loadSubscription($id, Project $project = null)
14491448
{
14501449
$organizations_enabled = $this->config->getWithDefault('api.organizations', false);
14511450
if (!$organizations_enabled) {
@@ -1454,25 +1453,6 @@ public function loadSubscription($id, Project $project = null, $forWrite = true)
14541453
return $this->getClient()->getSubscription($id);
14551454
}
14561455

1457-
// Attempt to load the subscription directly.
1458-
// This is possible if the user is on the project's access list, or
1459-
// if the user has access to all subscriptions.
1460-
// However, while this legacy API works for reading, it won't always work for writing.
1461-
if (!$forWrite) {
1462-
try {
1463-
$subscription = $this->getClient()->getSubscription($id);
1464-
} catch (BadResponseException $e) {
1465-
if (!$e->getResponse() || $e->getResponse()->getStatusCode() !== 403) {
1466-
throw $e;
1467-
}
1468-
$subscription = false;
1469-
}
1470-
if ($subscription) {
1471-
$this->debug('Loaded the subscription directly');
1472-
return $subscription;
1473-
}
1474-
}
1475-
14761456
// Use the project's organization, if known.
14771457
$organizationId = null;
14781458
if (isset($project)) {

0 commit comments

Comments
 (0)