## Summary <!-- Kurz: Was ändert sich und warum? --> ## Spec-Driven Development (SDD) - [ ] Es gibt eine Spec unter `specs/<NNN>-<feature>/` - [ ] Enthaltene Dateien: `plan.md`, `tasks.md`, `spec.md` - [ ] Spec beschreibt Verhalten/Acceptance Criteria (nicht nur Implementation) - [ ] Wenn sich Anforderungen während der Umsetzung geändert haben: Spec/Plan/Tasks wurden aktualisiert ## Implementation - [ ] Implementierung entspricht der Spec - [ ] Edge cases / Fehlerfälle berücksichtigt - [ ] Keine unbeabsichtigten Änderungen außerhalb des Scopes ## Tests - [ ] Tests ergänzt/aktualisiert (Pest/PHPUnit) - [ ] Relevante Tests lokal ausgeführt (`./vendor/bin/sail artisan test` oder `php artisan test`) ## Migration / Config / Ops (falls relevant) - [ ] Migration(en) enthalten und getestet - [ ] Rollback bedacht (rückwärts kompatibel, sichere Migration) - [ ] Neue Env Vars dokumentiert (`.env.example` / Doku) - [ ] Queue/cron/storage Auswirkungen geprüft ## UI (Filament/Livewire) (falls relevant) - [ ] UI-Flows geprüft - [ ] Screenshots/Notizen hinzugefügt ## Notes <!-- Links, Screenshots, Follow-ups, offene Punkte --> Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #3
48 lines
1.4 KiB
PHP
48 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Services\Graph\GraphContractRegistry;
|
|
use App\Services\Graph\GraphLogger;
|
|
use App\Services\Graph\MicrosoftGraphClient;
|
|
use Illuminate\Http\Client\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
it('falls back to default graph scope when config is empty', function () {
|
|
Cache::flush();
|
|
|
|
Config::set('graph.scope', '');
|
|
Config::set('graph.tenant_id', 'tenant-scope');
|
|
Config::set('graph.client_id', 'client-id');
|
|
Config::set('graph.client_secret', 'client-secret');
|
|
|
|
Http::fake([
|
|
'https://login.microsoftonline.com/*/oauth2/v2.0/token' => Http::response([
|
|
'access_token' => 'token',
|
|
'expires_in' => 3600,
|
|
'token_type' => 'Bearer',
|
|
]),
|
|
'https://graph.microsoft.com/*' => Http::response(['value' => []]),
|
|
]);
|
|
|
|
$client = new MicrosoftGraphClient(
|
|
app(GraphLogger::class),
|
|
app(GraphContractRegistry::class)
|
|
);
|
|
|
|
$client->getOrganization();
|
|
|
|
Http::assertSent(function (Request $request): bool {
|
|
if (! str_contains($request->url(), '/oauth2/v2.0/token')) {
|
|
return false;
|
|
}
|
|
|
|
return $request['scope'] === 'https://graph.microsoft.com/.default'
|
|
&& $request['client_id'] === 'client-id'
|
|
&& $request['grant_type'] === 'client_credentials';
|
|
});
|
|
});
|