Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MW deprovision test #33

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions stepup/tests/behat/features/bootstrap/ReplayContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode;
use Behat\MinkExtension\Context\MinkContext;

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

/**
* @Given a replay is performed
* @Given a replay of :arg is performed
*/
public function replay()
public function replay($name)
{
// Generate test databases
echo "Preparing test schemas\n";
Expand All @@ -35,10 +36,28 @@ public function replay()

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

// Perform an event replay
echo "Replaying event stream\n";
FeatureContext::execCommand("docker exec -t stepup-middleware-1 php bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -vvv");
}


/**
* @Given the database should not contain
* @param TableNode $table
*/
public function tempDataBaseDoesNotContains(TableNode $table)
{
FeatureContext::execCommand("mysqldump -h mariadb -u root -psecret --single-transaction --databases middleware_test gateway_test > temp.sql");
$dataset = file_get_contents('temp.sql');

$hash = $table->getHash();
foreach ($hash as $row) {
if (str_contains($dataset, $row['value'])) {
throw new RuntimeException(sprintf("Data %s with value %s is still in the data set.", $row['name'], $row['value']));
}
}
}
}
15 changes: 15 additions & 0 deletions stepup/tests/behat/features/mw_deprovision.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: A user can be deprovisioned from Middleware
In order to deprovision a user for middleware
On the command line
I expect this to be reflected in the data set

Scenario: After a replay is performed I would expect the last event reflected in the data set
Given a replay of deprovision is performed
Given I authenticate with user "lifecycle" and password "secret"
And I request "DELETE /deprovision/urn:collab:person:institution-a.example.com:joe-a-raa"
Then the api response status code should be 200
And the database should not contain
| name | value |
| email | [email protected] |
| common_name | Joe RAA |
| document_number | 467890 |
2 changes: 1 addition & 1 deletion stepup/tests/behat/features/mw_replay.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Feature: A replay is performed on Middleware
I expect the last event to be reflected in the data set

Scenario: After a replay is performed I would expect the last event reflected in the data set
Given a replay is performed
Given a replay of eventstream is performed
Given I authenticate with user "ra" and password "secret"
And I request "GET /identity?institution=institution-b.example.com&NameID=urn:collab:person:institution-b.example.com:joe-b5"
Then the api response status code should be 200
Expand Down
244 changes: 244 additions & 0 deletions stepup/tests/behat/fixtures/deprovision.sql

Large diffs are not rendered by default.

Loading