Fall back when Parcel2Go profile scope is denied
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 26s
This commit is contained in:
@@ -197,7 +197,7 @@ class DashboardAccessTest extends TestCase
|
||||
$admin = User::factory()->create(['role' => 'admin']);
|
||||
|
||||
$this->actingAs($admin)->get(route('shipping'))->assertOk()->assertSee('Lee Hickman')->assertSee('12.50');
|
||||
Http::assertSentCount(6);
|
||||
Http::assertSentCount(4);
|
||||
Http::assertSent(fn ($request) => $request->url() === 'https://auth.example.test/token'
|
||||
&& $request['scope'] === 'public-api my-profile');
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user