Fall back when Parcel2Go profile scope is denied
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s

This commit is contained in:
Hickmeister
2026-10-11 17:02:13 +01:00
parent 53ca438b0e
commit 55c987ef47
5 changed files with 67 additions and 12 deletions
+22
View File
@@ -103,6 +103,28 @@ class IntegrationsTest extends TestCase
Http::assertSentCount(1);
}
public function test_shipping_falls_back_to_basic_access_when_parcel2go_rejects_profile_scope(): void
{
Http::preventStrayRequests();
Http::fake(['https://auth.example.test/token' => function ($request) {
return $request['scope'] === 'public-api'
? Http::response(['access_token' => 'test-token'])
: Http::response(['error' => 'invalid_scope'], 400);
}]);
config()->set('services.parcel2go', [
'client_id' => 'id', 'client_secret' => 'secret',
'auth_url' => 'https://auth.example.test/token',
'base_url' => 'https://shipping.example.test/api',
'scope' => 'public-api my-profile',
]);
$this->actingAs(User::factory()->create(['role' => 'admin']))->get(route('shipping'))
->assertOk()->assertSee('Parcel2Go rejected the selected API access')
->assertDontSee('Parcel2Go connected, but account history is unavailable')
->assertDontSee('Parcel2Go is unavailable');
Http::assertSentCount(2);
}
public function test_shipping_label_is_downloaded_for_an_order_in_account_history(): void
{
Http::preventStrayRequests();