Skip to content

Commit

Permalink
Start work on running the behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MKodde committed Jan 17, 2024
1 parent 3eece65 commit c95ae92
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 29 deletions.
10 changes: 10 additions & 0 deletions stepup/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ services:
- ${PWD}/dbschema:/docker-entrypoint-initdb.d
- stepup_mariadb:/var/lib/mysql

behat:
image: ghcr.io/openconext/openconext-devconf/openconext-devconf:test
environment:
- APP_ENV=${APP_ENV:-prod}
networks:
openconextdev:
volumes:
- ${PWD}/:/config
- /var/run/docker.sock:/var/run/docker.sock

webauthn:
image: ghcr.io/openconext/stepup-webauthn/stepup-webauthn:${STEPUP_VERSION:-prod}
ports:
Expand Down
2 changes: 1 addition & 1 deletion stepup/tests/behat/behat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# For now the only feature is that it pipes on any argument provided
# to the script, into the behat command

./vendor/bin/behat --config config/behat.yml $1
./vendor/bin/behat --config config/behat.yml --strict $1
7 changes: 0 additions & 7 deletions stepup/tests/behat/features/bootstrap/ApiFeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,9 @@ class ApiFeatureContext implements Context
*/
public function __construct($apiUrl)
{
// Configure the testcookie for the guzzle client that will be handling the Api calls.
$domain = 'middleware.dev.openconext.local';
$values = ['testcookie' => 'testcookie'];

$cookieJar = CookieJar::fromArray($values, $domain);

$this->client = new Client(
[
'base_uri' => $apiUrl,
'cookies' => $cookieJar,
]
);
}
Expand Down
8 changes: 0 additions & 8 deletions stepup/tests/behat/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public static function setupDatabase(BeforeFeatureScope $scope)
shell_exec("./fixtures/middleware-push-config.sh");
// Perform an event replay
shell_exec("docker exec -ti stepup-middleware-1 bin/console middleware:event:replay --env=smoketest_event_replay --no-interaction -q");

echo "Update the keys\n";
// Update the `saml_entities` projection in `gateway_test`
// shell_exec("/vagrant/deploy/tests/behat/fixtures/bin/override_sp_public_keys");
}

/**
Expand All @@ -79,10 +75,6 @@ public function gatherContexts(BeforeScenarioScope $scope)
$this->apiContext = $environment->getContext(ApiFeatureContext::class);
$this->serlfServiceContext = $environment->getContext(SelfServiceContext::class);

// Set the testcookie for both sessions, effectively putting the Stepup suite in test mode
$this->minkContext->getSession()->setCookie('testcookie', 'testcookie');
$this->minkContext->getSession('second')->setCookie('testcookie', 'testcookie');

$this->payloadFactory = new CommandPayloadFactory();
$this->repository = new SecondFactorRepository();
$this->institutionConfiguration = new InstitutionConfiguration();
Expand Down
12 changes: 7 additions & 5 deletions stepup/tests/behat/features/bootstrap/RaContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,11 @@ public function iAmLoggedInIntoTheRaPortalAs($userName, $tokenType)
*/
public function iTryToLoginIntoTheRaPortalAs($userName, $tokenType)
{
$this->minkContext->getSession()->stop();
$this->minkContext->getSession()->setCookie('testcookie', 'testcookie');

// We visit the RA location url
$this->minkContext->visit($this->raUrl);

// The admin user logs in and gives a Yubikey second factor
$this->authContext->authenticateWithIdentityProviderFor($userName);

switch ($tokenType) {
case "yubikey":
$this->authContext->verifyYuikeySecondFactor();
Expand All @@ -129,7 +125,6 @@ public function iTryToLoginIntoTheRaPortalAs($userName, $tokenType)
$tokenType
)
);
break;
}
}

Expand Down Expand Up @@ -644,4 +639,11 @@ public function iVerifyTheUsersIdentityByFillingTheLastCharactersOfTheDocumentNu
$this->minkContext->checkOption('ra_verify_identity_identityVerified');
$this->minkContext->pressButton('Verify identity');
}

private function diePrintingContent()
{
echo $this->minkContext->getSession()->getCurrentUrl();
echo $this->minkContext->getSession()->getPage()->getContent();
die;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ public function authenticateWithIdentityProviderFor($userName)
$this->minkContext->fillField('password', $userName);

$this->minkContext->pressButton('Login');
$this->passTroughIdentityProviderAssertionConsumerService();
$this->minkContext->pressButton('Yes, continue');
$this->minkContext->assertPageAddress('https://gateway.dev.openconext.local/authentication/consume-assertion');
$this->minkContext->assertPageNotContainsText('Incorrect username or password');
}

private function passTroughIdentityProviderAssertionConsumerService()
Expand Down Expand Up @@ -438,4 +440,11 @@ public function theVerificationCodeIsInvalid()
{
$this->minkContext->assertResponseContains('This code is not correct. Please try again or request a new code.');
}

private function diePrintingContent()
{
echo $this->minkContext->getSession()->getCurrentUrl();
echo $this->minkContext->getSession()->getPage()->getContent();
die;
}
}
7 changes: 7 additions & 0 deletions stepup/tests/behat/features/bootstrap/SelfServiceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,11 @@ public function getVerifiedSecondFactorId()
{
return $this->verifiedSecondFactorId;
}

private function diePrintingContent()
{
echo $this->minkContext->getSession()->getCurrentUrl();
echo $this->minkContext->getSession()->getPage()->getContent();
die;
}
}
4 changes: 2 additions & 2 deletions stepup/tests/behat/features/ra_profile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Feature: A RA(A) can view profile information
And institution "institution-a.example.com" can "use_raa" from institution "institution-a.example.com"
And institution "institution-a.example.com" can "select_raa" from institution "institution-a.example.com"
And a user "Jane Toppan" identified by "urn:collab:person:institution-a.example.com:jane-a-ra" from institution "institution-a.example.com" with UUID "00000000-0000-4000-A000-000000000001"
And the user "urn:collab:person:institution-a.example.com:jane-a-ra" has a vetted "yubikey"
And the user "urn:collab:person:institution-a.example.com:jane-a-ra" has a vetted "yubikey" identified by "00000000-0000-4000-A000-000000000001"
And the user "urn:collab:person:institution-a.example.com:jane-a-ra" has the role "raa" for institution "institution-a.example.com"
And a user "Joe Satriani" identified by "urn:collab:person:institution-a.example.com:joe-a-ra" from institution "institution-a.example.com" with UUID "00000000-0000-4000-A000-000000000002"
And the user "urn:collab:person:institution-a.example.com:joe-a-ra" has a vetted "yubikey"
And the user "urn:collab:person:institution-a.example.com:joe-a-ra" has a vetted "yubikey" identified by "00000000-0000-4000-A000-000000000002"
And the user "urn:collab:person:institution-a.example.com:joe-a-ra" has the role "ra" for institution "institution-a.example.com"

Scenario: RAA user for one institution sees the authorization for that institution
Expand Down
13 changes: 8 additions & 5 deletions stepup/tests/behat/fixtures/events.sql

Large diffs are not rendered by default.

0 comments on commit c95ae92

Please sign in to comment.