Skip to content

Commit 5fe6083

Browse files
committed
Add dedicated replay test
1 parent 5d18d49 commit 5fe6083

File tree

6 files changed

+142
-2
lines changed

6 files changed

+142
-2
lines changed

stepup/tests/behat/config/behat.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ default:
2222
raUrl: 'https://ra.dev.openconext.local'
2323
- ApiFeatureContext:
2424
apiUrl: 'https://middleware.dev.openconext.local'
25+
- ReplayContext: ~
2526
- Behat\MinkExtension\Context\MinkContext
2627

2728
extensions:

stepup/tests/behat/features/bootstrap/ApiFeatureContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function iRequest($httpMethod, $resource)
154154
$method = strtoupper($httpMethod);
155155
// Construct request
156156
$this->lastRequest = new Request($method, $resource, $this->requestHeaders, $this->requestPayload);
157-
157+
var_dump($this->authUser, $this->authPassword);
158158
$options = array();
159159
if ($this->authUser) {
160160
$options = [

stepup/tests/behat/features/bootstrap/FeatureContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class FeatureContext implements Context
4545
*/
4646
private $institutionConfiguration;
4747

48-
private static function execCommand(string $command): void
48+
public static function execCommand(string $command): void
4949
{
5050
$output = [];
5151
$returnCode = -1;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
use Behat\Behat\Context\Context;
4+
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
5+
use Behat\MinkExtension\Context\MinkContext;
6+
7+
class ReplayContext implements Context
8+
{
9+
/**
10+
* @var \Behat\MinkExtension\Context\MinkContext
11+
*/
12+
private $minkContext;
13+
14+
/**
15+
* @BeforeScenario
16+
*/
17+
public function gatherContexts(BeforeScenarioScope $scope)
18+
{
19+
$environment = $scope->getEnvironment();
20+
21+
$this->minkContext = $environment->getContext(MinkContext::class);
22+
}
23+
24+
/**
25+
* @Given a replay is performed
26+
*/
27+
public function replay()
28+
{
29+
// Generate test databases
30+
echo "Preparing test schemas\n";
31+
FeatureContext::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:drop --em=middleware --env=smoketest --force');
32+
FeatureContext::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:drop --em=gateway --env=smoketest --force');
33+
FeatureContext::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:create --em=middleware --env=smoketest');
34+
FeatureContext::execCommand('docker exec -t stepup-middleware-1 bin/console doctrine:schema:create --em=gateway --env=smoketest');
35+
36+
// Import the events.sql into middleware
37+
echo "Add events to test database\n";
38+
FeatureContext::execCommand("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/eventstream.sql");
39+
40+
// Perform an event replay
41+
echo "Replaying event stream\n";
42+
FeatureContext::execCommand("docker exec -t stepup-middleware-1 bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -vvv");
43+
}
44+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Feature: A replay is performed on Middleware
2+
In order to replay an event stream
3+
On the command line
4+
I expect tha last event to be reflected in the data set
5+
6+
Scenario: After a replay is performed I would expect the last event reflected in the data set
7+
Given a replay is performed
8+
Given I authenticate with user "ra" and password "secret"
9+
And I request "GET /identity?institution=institution-b.example.com&NameID=urn:collab:person:institution-b.example.com:joe-b5"
10+
Then the api response status code should be 200
11+
And the "items" property should contain 1 items

stepup/tests/behat/fixtures/eventstream.sql

Lines changed: 84 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)