Restore Parcel2Go account reads for client credentials
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 1m48s

This commit is contained in:
Hickmeister
2026-10-11 17:59:59 +01:00
parent 141a1f9379
commit c892b615b6
4 changed files with 32 additions and 17 deletions
+18 -5
View File
@@ -91,7 +91,11 @@ class IntegrationsTest extends TestCase
return $request['scope'] === 'public-api'
? Http::response(['access_token' => 'test-token'])
: Http::response(['error' => 'invalid_scope'], 400);
}, 'https://shipping.example.test/api/me/orders/detail' => Http::response([], 403)]);
},
'https://shipping.example.test/api/me/orders/detail' => Http::response([], 403),
'https://shipping.example.test/api/me/detail' => Http::response([], 403),
'https://shipping.example.test/api/me/prepay/balance' => Http::response([], 403),
]);
config()->set('services.parcel2go', [
'client_id' => 'id', 'client_secret' => 'secret',
'auth_url' => 'https://auth.example.test/token',
@@ -102,7 +106,7 @@ class IntegrationsTest extends TestCase
$this->actingAs(User::factory()->create(['role' => 'admin']))->get(route('shipping'))
->assertOk()->assertSee('Pending Etsy orders')->assertSee('Parcel2Go denied shipment history')
->assertDontSee('Parcel2Go is unavailable');
Http::assertSentCount(2);
Http::assertSentCount(4);
}
public function test_shipping_shows_existing_shipments_when_basic_access_can_read_history(): void
@@ -115,6 +119,8 @@ class IntegrationsTest extends TestCase
'Tracking' => ['Delivered' => true], 'DeliveryAddress' => ['ContactName' => 'Buyer'],
'EstimatedDeliveryDate' => '2026-10-15', 'Hash' => 'hash',
]]]),
'https://shipping.example.test/api/me/detail' => Http::response(['Forename' => 'Lee', 'Surname' => 'Hickman']),
'https://shipping.example.test/api/me/prepay/balance' => Http::response(['Balance' => 12.5]),
]);
config()->set('services.parcel2go', [
'client_id' => 'id', 'client_secret' => 'secret',
@@ -125,8 +131,11 @@ class IntegrationsTest extends TestCase
$this->actingAs(User::factory()->create(['role' => 'admin']))->get(route('shipping'))
->assertOk()->assertSee('Existing shipments')->assertSee('Delivered')->assertSee('Buyer')
->assertSee('Lee Hickman')->assertSee('12.50')
->assertDontSee('Parcel2Go denied shipment history');
Http::assertSentCount(2);
Http::assertSent(fn ($request) => $request->url() === 'https://shipping.example.test/api/me/detail' && $request->hasHeader('Authorization', 'Bearer test-token'));
Http::assertSent(fn ($request) => $request->url() === 'https://shipping.example.test/api/me/prepay/balance' && $request->hasHeader('Authorization', 'Bearer test-token'));
Http::assertSentCount(4);
}
public function test_shipping_rejects_a_quote_for_an_order_that_is_not_pending(): void
@@ -149,7 +158,11 @@ class IntegrationsTest extends TestCase
return $request['scope'] === 'public-api'
? Http::response(['access_token' => 'test-token'])
: Http::response(['error' => 'invalid_scope'], 400);
}, 'https://shipping.example.test/api/me/orders/detail' => Http::response([], 403)]);
},
'https://shipping.example.test/api/me/orders/detail' => Http::response([], 403),
'https://shipping.example.test/api/me/detail' => Http::response([], 403),
'https://shipping.example.test/api/me/prepay/balance' => Http::response([], 403),
]);
config()->set('services.parcel2go', [
'client_id' => 'id', 'client_secret' => 'secret',
'auth_url' => 'https://auth.example.test/token',
@@ -160,7 +173,7 @@ class IntegrationsTest extends TestCase
$this->actingAs(User::factory()->create(['role' => 'admin']))->get(route('shipping'))
->assertOk()->assertSee('Parcel2Go denied shipment history')
->assertDontSee('Parcel2Go is unavailable');
Http::assertSentCount(3);
Http::assertSentCount(5);
}
public function test_shipping_label_is_downloaded_for_an_order_in_account_history(): void