Skip to content
15 changes: 15 additions & 0 deletions src/HelloClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,21 @@ public function route()
if ($this->helloRequest->fetch('code') || $this->helloRequest->fetch('error')) {
return $this->handleCallback();
}
// If the Redirect URI is not configured in Hello Wallet, we will prompt the user to add it.
if (
$this->helloRequest->fetch('wildcard_console') &&
empty($this->helloRequest->fetch('redirect_uri'))
) {
return $this->helloResponse->render($this->pageRenderer->renderWildcardConsole(
/** @phpstan-ignore-next-line */
strval($this->helloRequest->fetch('uri')),
/** @phpstan-ignore-next-line */
strval($this->helloRequest->fetch('target_uri')),
/** @phpstan-ignore-next-line */
strval($this->helloRequest->fetch('app_name')),
""
));
}

return; //TODO: add 500 error here;
}
Expand Down
36 changes: 34 additions & 2 deletions tests/HelloClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function testRouteHandlesCallback(): void
->method('handleCallback')
->willReturn('/dashboard');


$result = $this->client->route();
$this->assertSame('/dashboard', $result);
}
Expand Down Expand Up @@ -112,12 +111,45 @@ public function testRouteHandlesCallbackException(): void
->with('error_page')
->willReturn('render_response');

//throw exception
// Throw exception
$this->callbackMock
->method('handleCallback')
->willThrowException(new CallbackException(['error' => 'test', 'error_description' => 'desc', 'target_uri' => 'uri']));

$result = $this->client->route();
$this->assertSame('render_response', $result);
}

public function testRouteHandlesWildcardConsole(): void
{
// Simulate $_GET parameters
$_GET = ['wildcard_console' => 'true'];

$_GET += [
'uri' => 'https://example.com/wildcard',
'target_uri' => '/target',
'app_name' => 'TestApp',
'redirect_uri' => '',
];

$this->pageRendererMock
->expects($this->once())
->method('renderWildcardConsole')
->with(
'https://example.com/wildcard',
'/target',
'TestApp',
''
)
->willReturn('wildcard_console_page');

$this->helloResponseMock
->expects($this->once())
->method('render')
->with('wildcard_console_page')
->willReturn('render_response');

$result = $this->client->route();
$this->assertSame('render_response', $result);
}
}
Loading