Use Parcel2Go public API scope by default
Deploy HickLab3D Dashboard / Deploy to production (push) Successful in 1m1s

This commit is contained in:
Hickmeister
2026-10-11 16:50:13 +01:00
parent 75d8df532b
commit 61dd05384f
13 changed files with 102 additions and 9 deletions
+4
View File
@@ -47,6 +47,7 @@ class DashboardAccessTest extends TestCase
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',
]);
config()->set('services.dryer', ['url' => 'https://dryer.example.test/api/v1', 'api_key' => 'key']);
EtsyConnection::create(['shop_id' => 42, 'shop_name' => 'HickLab3D', 'access_token' => '123.token', 'refresh_token' => '123.refresh', 'expires_at' => now()->addHour()]);
@@ -191,10 +192,13 @@ class DashboardAccessTest extends TestCase
'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',
]);
$admin = User::factory()->create(['role' => 'admin']);
$this->actingAs($admin)->get(route('shipping'))->assertOk()->assertSee('Lee Hickman')->assertSee('12.50');
Http::assertSentCount(6);
Http::assertSent(fn ($request) => $request->url() === 'https://auth.example.test/token'
&& $request['scope'] === 'public-api my-profile');
}
}
+15
View File
@@ -97,4 +97,19 @@ class IntegrationSettingsTest extends TestCase
])->assertSessionHasErrors('url');
$this->assertDatabaseCount('integration_settings', 0);
}
public function test_parcel2go_scope_is_validated_and_saved(): void
{
$admin = User::factory()->create(['role' => 'admin']);
$this->actingAs($admin)->put(route('settings.integrations.update', 'parcel2go'), [
'scope' => 'admin',
])->assertSessionHasErrors('scope');
$this->assertDatabaseCount('integration_settings', 0);
$this->actingAs($admin)->put(route('settings.integrations.update', 'parcel2go'), [
'scope' => 'public-api my-profile',
])->assertRedirect(route('settings.index'));
$this->assertSame('public-api my-profile', IntegrationSetting::findOrFail('parcel2go')->settings['scope']);
}
}
+21
View File
@@ -82,6 +82,27 @@ class IntegrationsTest extends TestCase
Http::assertSent(fn ($request) => $request->url() === 'https://shipping.example.test/api/quotes' && $request['Parcels'][0]['Weight'] === 2);
}
public function test_shipping_page_works_with_public_api_scope_without_profile_access(): 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',
]);
$this->actingAs(User::factory()->create(['role' => 'admin']))->get(route('shipping'))
->assertOk()->assertSee('Parcel2Go connected for quotes and collections')
->assertDontSee('Parcel2Go is unavailable');
Http::assertSentCount(1);
}
public function test_shipping_label_is_downloaded_for_an_order_in_account_history(): void
{
Http::preventStrayRequests();