Skip to content

Commit 5c9e561

Browse files
committed
Add quick smoketest to assert the routes don't produce an error and the status code is correct
1 parent 40b6571 commit 5c9e561

8 files changed

Lines changed: 124 additions & 33 deletions

File tree

ci/qa/phpunit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --
1818
echo -e "\nPHPUnit unit tests\n"
1919
XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=unit --coverage-clover coverage.xml
2020

21-
echo -e "\nPHPUnit API acceptance tests\n"
21+
echo -e "\nPHPUnit acceptance tests\n"
2222
./bin/console cache:clear --env=test --no-warmup
2323
APP_ENV=test XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=functional --coverage-clover coverage.xml
2424

config/services/ci/controllers.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ services:
2525
class: OpenConext\EngineBlockFunctionalTestingBundle\Controllers\FeedbackController
2626
arguments:
2727
- '@twig'
28-
<<<<<<< HEAD
29-
=======
30-
- '@engineblock.compat.logger'
31-
>>>>>>> 41926c2bd (Fix feedbackInfo session bleed-through between auth flows (#1795))
3228
- '@OpenConext\EngineBlock\Service\FeedbackStateHelper'
3329
- '@OpenConext\EngineBlockBundle\Controller\FeedbackController'
3430

languages/messages.en.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
'error_clock_issue_desc' => 'This is likely because the difference in time between %idpName% and %suiteName% it too large. Please verify that the time on the %organisationNoun% is correct.',
266266
'error_clock_issue_desc_no_idp_name' => 'This is likely because the difference in time between %organisationNoun% and %suiteName% it too large. Please verify that the time on the IdP is correct.',
267267
'error_stepup_callout_unknown' => 'Error - Unknown strong authentication failure',
268-
'error_stepup_callout_unknown_desc' => 'Logging in with strong authentication has failed and we don\'t know exactly why . Please try again first by going back to the service and logging in again . If this doesn\'t work, please contact the service desk of your %organisationNoun%.',
268+
'error_stepup_callout_unknown_desc' => 'Logging in with strong authentication has failed and we don\'t know exactly why. Please try again first by going back to the service and logging in again. If this doesn\'t work, please contact the service desk of your %organisationNoun%.',
269269
'error_stepup_callout_unmet_loa_title' => 'Error - No suitable token found',
270270
'error_stepup_callout_unmet_loa_desc' => 'To continue to this service, a registered token with a certain level of assurance is required. Currently, you either haven\'t registered a token at all, or the level of assurance of the token you did register is too low. See the link below for more information about the registration process.',
271271
'error_stepup_callout_unmet_loa_link_text' => 'Read more about the registration process.',

src/OpenConext/EngineBlockBundle/Bridge/DiContainerRuntime.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
use OpenConext\EngineBlock\Service\FeedbackInfoCollectorInterface;
2222
use OpenConext\EngineBlock\Service\FeedbackStateHelperInterface;
23-
<<<<<<< HEAD
2423
use OpenConext\EngineBlockBundle\Service\WayfRenderer;
25-
=======
26-
>>>>>>> 41926c2bd (Fix feedbackInfo session bleed-through between auth flows (#1795))
2724
use Twig\Environment;
2825

2926
/**
@@ -37,7 +34,6 @@
3734

3835
public function __construct(
3936
public Environment $twig,
40-
<<<<<<< HEAD
4137
public WayfRenderer $wayfRenderer,
4238
public FeedbackStateHelperInterface $feedbackStateHelper,
4339
public FeedbackInfoCollectorInterface $feedbackInfoCollector,
@@ -48,10 +44,5 @@ public function __construct(
4844
public function getPreferredIdpEntityIds(): array
4945
{
5046
return $this->preferredIdpEntityIds;
51-
=======
52-
public FeedbackStateHelperInterface $feedbackStateHelper,
53-
public FeedbackInfoCollectorInterface $feedbackInfoCollector,
54-
) {
55-
>>>>>>> 41926c2bd (Fix feedbackInfo session bleed-through between auth flows (#1795))
5647
}
5748
}

src/OpenConext/EngineBlockFunctionalTestingBundle/Controllers/FeedbackController.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ public function __construct(
5858
public function feedbackAction(Request $request)
5959
{
6060
$key = $this->getTemplate($request);
61-
$feedbackInfo = $this->getFeedbackInfo($request);
6261
$parameters = $this->getTemplateParameters($request);
6362

64-
$this->feedbackStateHelper->storeFeedbackInfo($feedbackInfo);
63+
$this->feedbackStateHelper->storeFeedbackInfo($this->getFeedbackInfo($request));
6564

6665
$template = sprintf(
6766
'@theme/Authentication/View/Feedback/%s.html.twig',
@@ -91,19 +90,14 @@ private function getTemplate(Request $request)
9190

9291
/**
9392
* @param Request $request
94-
* @return mixed|string
93+
* @return array
9594
*/
96-
private function getFeedbackInfo(Request $request)
95+
private function getFeedbackInfo(Request $request): array
9796
{
98-
$default = '{
99-
"requestId":"5cb4bd3879b49",
100-
"ipAddress":"192.168.66.98",
101-
"artCode":"31914"
102-
}';
97+
$default = '{"requestId":"5cb4bd3879b49","ipAddress":"192.168.66.98","artCode":"31914"}';
10398

104-
$feedbackInfo = $request->query->getString('feedback-info', $default);
99+
$feedbackInfo = json_decode($request->query->getString('feedback-info', $default), true);
105100

106-
$feedbackInfo = json_decode($feedbackInfo, true);
107101
if (!empty($feedbackInfo['IdentityProvider']) || !empty($feedbackInfo['IdP'])) {
108102
$feedbackInfo['identityProviderName'] = 'OpenConext Identities Inc';
109103
}

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/FeedbackFooters.feature

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ Feature:
4545

4646

4747

48-
Scenario: The functional-testing feedback page renders correctly with feedback-info
48+
Scenario: The functional-testing feedback page renders feedback details
4949
When I go to Engineblock URL "/functional-testing/feedback?template=session-lost&feedback-info=%7B%22requestId%22%3A%22test-abc%22%2C%22ipAddress%22%3A%221.2.3.4%22%2C%22artCode%22%3A%2231914%22%7D"
5050
Then I should see "your session was lost"
51+
And I should see "test-abc"
52+
And I should see "1.2.3.4"
5153

5254
Scenario: The session-lost feedback route renders correctly
5355
When I go to Engineblock URL "/authentication/feedback/session-lost"
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2026 SURFnet B.V.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
namespace OpenConext\EngineBlockBundle\Tests;
20+
21+
use PHPUnit\Framework\Attributes\Test;
22+
use Symfony\Component\HttpFoundation\Response;
23+
24+
final class FeedbackControllerTest extends FunctionalWebTestCase
25+
{
26+
#[Test]
27+
public function session_lost_returns_400_with_expected_content(): void
28+
{
29+
$this->assertFeedbackPage('/authentication/feedback/session-lost', Response::HTTP_BAD_REQUEST, 'your session was lost');
30+
}
31+
32+
#[Test]
33+
public function session_not_started_returns_400_with_expected_content(): void
34+
{
35+
$this->assertFeedbackPage('/authentication/feedback/session-not-started', Response::HTTP_BAD_REQUEST, 'No session found');
36+
}
37+
38+
#[Test]
39+
public function unsolicited_response_returns_400_with_expected_content(): void
40+
{
41+
$this->assertFeedbackPage('/authentication/feedback/unsolicited-response', Response::HTTP_BAD_REQUEST, 'Sign-in could not be completed');
42+
}
43+
44+
#[Test]
45+
public function invalid_acs_binding_returns_400_with_expected_content(): void
46+
{
47+
$this->assertFeedbackPage('/authentication/feedback/invalid-acs-binding', Response::HTTP_BAD_REQUEST, 'Invalid ACS binding type');
48+
}
49+
50+
#[Test]
51+
public function received_error_status_code_returns_400_with_expected_content(): void
52+
{
53+
$this->assertFeedbackPage('/authentication/feedback/received-error-status-code', Response::HTTP_BAD_REQUEST, 'Identity Provider error');
54+
}
55+
56+
#[Test]
57+
public function unable_to_receive_message_returns_400_with_expected_content(): void
58+
{
59+
$this->assertFeedbackPage('/authentication/feedback/unable-to-receive-message', Response::HTTP_BAD_REQUEST, 'No message received');
60+
}
61+
62+
#[Test]
63+
public function unknown_requesterid_in_authnrequest_returns_400_with_expected_content(): void
64+
{
65+
$this->assertFeedbackPage('/authentication/feedback/unknown_requesterid_in_authnrequest', Response::HTTP_BAD_REQUEST, 'Unknown service');
66+
}
67+
68+
#[Test]
69+
public function authentication_limit_exceeded_returns_429_with_expected_content(): void
70+
{
71+
$this->assertFeedbackPage('/authentication/feedback/authentication-limit-exceeded', Response::HTTP_TOO_MANY_REQUESTS, 'too many authentications in progress');
72+
}
73+
74+
#[Test]
75+
public function stepup_callout_unknown_returns_400_with_expected_content(): void
76+
{
77+
$this->assertFeedbackPage('/authentication/feedback/stepup-callout-unknown', Response::HTTP_BAD_REQUEST, 'Unknown strong authentication failure');
78+
}
79+
80+
#[Test]
81+
public function stepup_callout_user_cancelled_returns_400_with_expected_content(): void
82+
{
83+
$this->assertFeedbackPage('/authentication/feedback/stepup-callout-user-cancelled', Response::HTTP_BAD_REQUEST, 'Logging in cancelled');
84+
}
85+
86+
#[Test]
87+
public function invalid_acs_location_returns_400_with_expected_content(): void
88+
{
89+
$this->assertFeedbackPage('/authentication/feedback/invalidAcsLocation', Response::HTTP_BAD_REQUEST, 'Invalid ACS location');
90+
}
91+
92+
#[Test]
93+
public function feedback_data_from_session_is_rendered_on_the_real_route(): void
94+
{
95+
$client = self::createClient();
96+
97+
// First prime, the session, then visit the actual route
98+
$client->request('GET', 'https://engine.dev.openconext.local/functional-testing/feedback?template=session-lost');
99+
$client->request('GET', 'https://engine.dev.openconext.local/authentication/feedback/session-lost');
100+
101+
$content = $client->getResponse()->getContent();
102+
$this->assertStringContainsString('feedback-info--requestid', $content);
103+
$this->assertStringContainsString('feedback-info--ipaddress', $content);
104+
}
105+
106+
private function assertFeedbackPage(string $path, int $expectedStatus, string $expectedPhrase): void
107+
{
108+
$client = self::createClient();
109+
$client->request('GET', 'https://engine.dev.openconext.local' . $path);
110+
111+
$this->assertEquals($expectedStatus, $client->getResponse()->getStatusCode());
112+
$this->assertStringContainsString($expectedPhrase, $client->getResponse()->getContent());
113+
}
114+
}

tests/library/EngineBlock/Test/Corto/Module/BindingsTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,10 @@ public function setUp(): void
6363

6464
$engineBlock = \EngineBlock_ApplicationSingleton::getInstance();
6565
$engineBlock->setDiContainerRuntime(new DiContainerRuntime(
66-
<<<<<<< HEAD
6766
$this->createStub(Twig\Environment::class),
6867
$this->createStub(WayfRenderer::class),
6968
$this->createStub(FeedbackStateHelperInterface::class),
7069
$this->createStub(FeedbackInfoCollectorInterface::class),
71-
=======
72-
Phake::mock(Twig\Environment::class),
73-
m::mock(FeedbackStateHelperInterface::class),
74-
m::mock(FeedbackInfoCollectorInterface::class),
75-
>>>>>>> 41926c2bd (Fix feedbackInfo session bleed-through between auth flows (#1795))
7670
));
7771

7872
$this->bindings = new EngineBlock_Corto_Module_Bindings($this->proxyServer);

0 commit comments

Comments
 (0)