Skip to content

Commit 579a412

Browse files
committed
Adjust SBS flow integration test to updated specs
Prior to this change, the test still assumed the entitlements call was used. This change adjusts the test to prime the sbs functional test endpoint for multiple calls on the authz endpoint instead.
1 parent 5e24038 commit 579a412

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/OpenConext/EngineBlockBundle/Sbs/SbsClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function authz(AuthzRequest $request): AuthzResponse
9090
}
9191

9292
// Entitlements use authzLocation !!
93-
public function requestEntitlementsFor(EntitlementsRequest $request): EntitlementsResponse
93+
public function requestEntitlementsFor(EntitlementsRequest $request): AuthzResponse
9494
{
9595
$jsonData = $this->httpClient->post(
9696
json_encode($request),
@@ -104,7 +104,7 @@ public function requestEntitlementsFor(EntitlementsRequest $request): Entitlemen
104104
throw new InvalidSbsResponseException('Received non-array from SBS server');
105105
}
106106

107-
return EntitlementsResponse::fromData($jsonData);
107+
return AuthzResponse::fromData($jsonData);
108108
}
109109

110110
private function requestHeaders(): array

src/OpenConext/EngineBlockBundle/Sbs/SbsClientInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface SbsClientInterface
3030

3131
public function getInterruptLocationLink(string $nonce);
3232

33-
public function requestEntitlementsFor(EntitlementsRequest $request) : EntitlementsResponse;
33+
public function requestEntitlementsFor(EntitlementsRequest $request) : AuthzResponse;
3434

3535
public function authz(AuthzRequest $request) : AuthzResponse;
3636
}

src/OpenConext/EngineBlockFunctionalTestingBundle/Features/SbsFlowIntegration.feature

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ Feature:
1414
Given the SP "SSO-SP" requires SRAM collaboration
1515
And feature "eb.feature_enable_sram_interrupt" is enabled
1616
And the sbs server will trigger the "interrupt" authz flow when called
17-
And the sbs server will return valid entitlements
17+
# And the sbs server will return valid entitlements ## @TODO Remove this endpoint call altogether?
1818
When I log in at "SSO-SP"
1919
And I pass through EngineBlock
2020
And I pass through the IdP
2121
Then the url should match "/functional-testing/interrupt"
22+
Given the sbs server will trigger the "authorized" authz flow when called
2223
And I pass through SBS
2324
Then the url should match "/authentication/idp/process-sraminterrupt"
2425
And the response should contain "Review your information that will be shared."
@@ -61,23 +62,25 @@ Feature:
6162
Given the SP "SSO-SP" requires SRAM collaboration
6263
And feature "eb.feature_enable_sram_interrupt" is enabled
6364
And the sbs server will trigger the "interrupt" authz flow when called
64-
And the sbs server will return invalid entitlements
65+
# And the sbs server will return invalid entitlements ## @TODO remove entitlements call?
6566
When I log in at "SSO-SP"
6667
And I pass through EngineBlock
6768
And I pass through the IdP
6869
Then the url should match "/functional-testing/interrupt"
70+
And the sbs server will trigger the "error" authz flow when called
6971
And I pass through SBS
7072
And the response should contain "Logging in has failed"
7173

72-
Scenario: If the authz call returns unknown attributes, the flow is halted
74+
Scenario: If the authz call returns unknown attributes, the unknown attributes are ignored
7375
Given the SP "SSO-SP" requires SRAM collaboration
7476
And feature "eb.feature_enable_sram_interrupt" is enabled
7577
And the sbs server will trigger the 'authorized' authz flow and will return invalid attributes
7678
When I log in at "SSO-SP"
7779
And I pass through EngineBlock
7880
And I pass through the IdP
79-
Then the url should match "/feedback/unknown-error"
80-
And the response should contain "Logging in has failed"
81+
Then the url should match "/authentication/sp/consume-assertion"
82+
And the response should not contain "foo"
83+
And the response should not contain "baz"
8184

8285
Scenario: If the sbs flow is active, other filters like PDP are still executed
8386
Given SP "SSO-SP" requires a policy enforcement decision

tests/unit/OpenConext/EngineBlockBundle/Sbs/SbsClientTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public function testAuthz(): void
7575
public function testRequestEntitlementsFor(): void
7676
{
7777
$requestMock = $this->createMock(EntitlementsRequest::class);
78-
$jsonResponse = ['attributes' => ['name' => 'value']];
78+
$jsonResponse = [
79+
'msg' => 'authorized',
80+
'attributes' => ['name' => 'value']
81+
];
7982

8083
$this->httpClient->expects($this->once())
8184
->method('post')
@@ -93,6 +96,6 @@ public function testRequestEntitlementsFor(): void
9396

9497
$entitlementsResponse = $this->sbsClient->requestEntitlementsFor($requestMock);
9598

96-
$this->assertInstanceOf(EntitlementsResponse::class, $entitlementsResponse);
99+
$this->assertInstanceOf(AuthzResponse::class, $entitlementsResponse);
97100
}
98101
}

0 commit comments

Comments
 (0)