Skip to content

Commit d922f40

Browse files
committed
Cleanup en improve test coverage
1 parent baad08d commit d922f40

4 files changed

Lines changed: 30 additions & 21 deletions

File tree

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/Context/LoggingContext.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ public function theFollowingLogMessagesShouldHaveACorrelationId(TableNode $table
8989
}
9090
}
9191

92+
/**
93+
* @Then the log should contain multiple distinct request_ids
94+
*/
95+
public function theLogShouldContainMultipleDistinctRequestIds(): void
96+
{
97+
$records = $this->readRecords();
98+
99+
$requestIds = array_column($records, 'extra')
100+
|> (static fn($x) => array_column($x, 'request_id',))
101+
|> array_unique(...);
102+
103+
if (count($requestIds) < 2) {
104+
throw new RuntimeException(sprintf(
105+
'Expected multiple distinct request_ids in the log, but found only %d: %s.',
106+
count($requestIds),
107+
implode(', ', $requestIds),
108+
));
109+
}
110+
}
111+
92112
/**
93113
* @Then I dump the log records
94114
*/

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/CorrelationId.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Feature:
1919
And I give my consent
2020
And I pass through EngineBlock
2121
Then the url should match "functional-testing/CorrId-SP/acs"
22-
#And I dump the log records
22+
And the log should contain multiple distinct request_ids
2323
And the following log messages should have a correlation_id:
2424
| message |
2525
| Multiple candidate IdPs: redirecting to WAYF |

tests/library/EngineBlock/Test/Saml2/AuthnRequestSessionRepositoryTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ public function test_store_and_find_multiple_requests(): void
9090
$this->assertSame($req2, $this->repo->findRequestById('_req-2'));
9191
}
9292

93-
// ── SessionNotFoundException safety ──────────────────────────────────────
94-
9593
public function test_store_is_noop_when_no_session_available(): void
9694
{
9795
$requestStack = $this->createMock(RequestStack::class);

tests/unit/OpenConext/EngineBlock/Request/CorrelationIdFlowTest.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
2525

2626
/**
27-
* Integration test: simulates the complete 4-leg SAML authentication flow and
28-
* verifies that a single correlation ID flows through every leg via
29-
* CorrelationIdService.
27+
* Integration test: simulates the complete 4-leg SAML authentication flow and verifies that a single
28+
* correlation ID flows through every leg via CorrelationIdService.
3029
*
31-
* Leg 1 SSO SP AuthnRequest ID = A → mint → correlation_id = CX
32-
* Leg 2 ContinueToIdp ID = A (POST) → resolve(A) → CX
33-
* EB AuthnRequest ID = B → link(B, A) → B also maps to CX
34-
* Leg 3 ACS IdP Response InResponseTo=B → resolve(B) → CX
35-
* Leg 4 Consent SP request ID = A → resolve(A) → CX
30+
* Leg 1 SSO SP AuthnRequest ID = A > mint > correlation_id = CX
31+
*
32+
* Leg 2 ContinueToIdp ID = A (POST) > resolve(A) → CX
33+
* EB AuthnRequest ID = B > link(B, A) > B also maps to CX
34+
*
35+
* Leg 3 ACS IdP Response InResponseTo=B > resolve(B) > CX
36+
* Leg 4 Consent SP request ID = A > resolve(A) > CX
3637
*/
3738
class CorrelationIdFlowTest extends TestCase
3839
{
@@ -67,8 +68,6 @@ private function newServiceWithCurrent(CurrentCorrelationId $current): Correlati
6768
return new CorrelationIdService($repository, $current);
6869
}
6970

70-
// ── WAYF path ────────────────────────────────────────────────────────────
71-
7271
public function test_wayf_flow_all_four_legs_share_the_same_correlation_id(): void
7372
{
7473
$spRequestId = '_sp-request-A';
@@ -99,8 +98,6 @@ public function test_wayf_flow_all_four_legs_share_the_same_correlation_id(): vo
9998
$this->assertSame($mintedCx, $leg4Current->correlationId, 'Consent must see the same correlation ID');
10099
}
101100

102-
// ── Direct path (no WAYF) ─────────────────────────────────────────────────
103-
104101
public function test_direct_flow_acs_and_consent_share_the_correlation_id_minted_at_sso(): void
105102
{
106103
$spRequestId = '_sp-direct-A';
@@ -117,8 +114,6 @@ public function test_direct_flow_acs_and_consent_share_the_correlation_id_minted
117114
$this->assertSame($mintedCx, $ids[$spRequestId], 'Consent resolves via SP request ID');
118115
}
119116

120-
// ── Concurrent flows ──────────────────────────────────────────────────────
121-
122117
public function test_two_concurrent_flows_have_independent_correlation_ids(): void
123118
{
124119
$this->service->mint('_sp-A1');
@@ -138,8 +133,6 @@ public function test_two_concurrent_flows_have_independent_correlation_ids(): vo
138133
$this->assertSame($cx2, $ids['_idp-B2']);
139134
}
140135

141-
// ── Back-button replay guard ───────────────────────────────────────────────
142-
143136
public function test_replaying_an_sso_request_does_not_change_the_correlation_id(): void
144137
{
145138
$spRequestId = '_sp-replay-A';
@@ -152,8 +145,6 @@ public function test_replaying_an_sso_request_does_not_change_the_correlation_id
152145
$this->assertSame($cx, $this->session->get('CorrelationIds')[$spRequestId], 'Back-button replay must not change the correlation ID');
153146
}
154147

155-
// ── Null safety ───────────────────────────────────────────────────────────
156-
157148
public function test_unknown_request_id_does_not_set_correlation_id(): void
158149
{
159150
$this->service->resolve('_unknown-id');

0 commit comments

Comments
 (0)