Skip to content

Commit

Permalink
Replace RunnableResponse with StreamedResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Aug 21, 2024
1 parent 581a7ab commit f8828bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/Controller/DiscoPower.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@

use Exception;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Module\discopower\PowerIdPDisco;
use SimpleSAML\Session;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response, StreamedResponse};

class DiscoPower
{
/**
* @param \Symfony\Component\HttpFoundation\Request $request The current request.
* @return \SimpleSAML\HTTP\RunnableResponse
* @return \Symfony\Component\HttpFoundation\StreamedResponse
*/
public function main(Request $request): RunnableResponse
public function main(Request $request): StreamedResponse
{
try {
$discoHandler = new PowerIdPDisco(
Expand All @@ -32,7 +29,7 @@ public function main(Request $request): RunnableResponse
}

try {
return new RunnableResponse([$discoHandler, 'handleRequest'], []);
return new StreamedResponse([$discoHandler, 'handleRequest']);
} catch (Exception $exception) {
// An error here should be caused by metadata
throw new Error\Error('METADATA', $exception);
Expand Down
5 changes: 2 additions & 3 deletions tests/src/Controller/DiscoPowerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
use PHPUnit\Framework\Attributes\CoversClass;
use SimpleSAML\Configuration;
use SimpleSAML\Error;
use SimpleSAML\HTTP\RunnableResponse;
use SimpleSAML\Module\discopower\Controller;
use SimpleSAML\Session;
use SimpleSAML\TestUtils\ClearStateTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\{Request, StreamedResponse};

/**
* Set of tests for the controllers in the "discopower" module.
Expand Down Expand Up @@ -83,7 +82,7 @@ public function testDiscoPowerHasDiscoParams(): void
$c = new Controller\DiscoPower();

$r = $c->main($request);
$this->assertInstanceOf(RunnableResponse::class, $r);
$this->assertInstanceOf(StreamedResponse::class, $r);
$this->assertTrue($r->isSuccessful());
}

Expand Down

0 comments on commit f8828bb

Please sign in to comment.