Skip to content

Commit 480a548

Browse files
committed
Add MW deprovision test
1 parent 98e9f7c commit 480a548

File tree

4 files changed

+282
-4
lines changed

4 files changed

+282
-4
lines changed

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Behat\Behat\Context\Context;
44
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
5+
use Behat\Gherkin\Node\TableNode;
56
use Behat\MinkExtension\Context\MinkContext;
67

78
class ReplayContext implements Context
@@ -22,9 +23,9 @@ public function gatherContexts(BeforeScenarioScope $scope)
2223
}
2324

2425
/**
25-
* @Given a replay is performed
26+
* @Given a replay of :arg is performed
2627
*/
27-
public function replay()
28+
public function replay($name)
2829
{
2930
// Generate test databases
3031
echo "Preparing test schemas\n";
@@ -35,10 +36,28 @@ public function replay()
3536

3637
// Import the events.sql into middleware
3738
echo "Add events to test database\n";
38-
FeatureContext::execCommand("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/eventstream.sql");
39+
FeatureContext::execCommand("mysql -uroot -psecret middleware_test -h mariadb < ./fixtures/".$name.".sql");
3940

4041
// Perform an event replay
4142
echo "Replaying event stream\n";
4243
FeatureContext::execCommand("docker exec -t stepup-middleware-1 php bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -vvv");
4344
}
45+
46+
47+
/**
48+
* @Given the database should not contain
49+
* @param TableNode $table
50+
*/
51+
public function tempDataBaseDoesNotContains(TableNode $table)
52+
{
53+
FeatureContext::execCommand("mysqldump -h mariadb -u root -psecret --single-transaction --databases middleware_test gateway_test > temp.sql");
54+
$dataset = file_get_contents('temp.sql');
55+
56+
$hash = $table->getHash();
57+
foreach ($hash as $row) {
58+
if (str_contains($dataset, $row['value'])) {
59+
throw new RuntimeException(sprintf("Data %s with value %s is still in the data set.", $row['name'], $row['value']));
60+
}
61+
}
62+
}
4463
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: A user can be deprovisioned from Middleware
2+
In order to deprovision a user for middleware
3+
On the command line
4+
I expect this 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 of deprovision is performed
8+
Given I authenticate with user "lifecycle" and password "secret"
9+
And I request "DELETE /deprovision/urn:collab:person:institution-a.example.com:joe-a-raa"
10+
Then the api response status code should be 200
11+
And the database should not contain
12+
| name | value |
13+
| email | joe-a-raa@institution-a.nl |
14+
| common_name | Joe RAA |
15+
| document_number | 467890 |

stepup/tests/behat/features/mw_replay.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Feature: A replay is performed on Middleware
44
I expect the last event to be reflected in the data set
55

66
Scenario: After a replay is performed I would expect the last event reflected in the data set
7-
Given a replay is performed
7+
Given a replay of eventstream is performed
88
Given I authenticate with user "ra" and password "secret"
99
And I request "GET /identity?institution=institution-b.example.com&NameID=urn:collab:person:institution-b.example.com:joe-b5"
1010
Then the api response status code should be 200

stepup/tests/behat/fixtures/deprovision.sql

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

0 commit comments

Comments
 (0)