Skip to content

Commit

Permalink
OPENEUROPA-1485: Fix code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
imanoleguskiza committed Dec 18, 2018
1 parent 1e96920 commit 065de08
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 60 deletions.
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ default:
- %paths.base%/tests/features
contexts:
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\Tests\oe_authentication\Behat\AuthenticationContext
- Drupal\Tests\oe_authentication\Behat\DrupalContext
extensions:
Behat\MinkExtension:
goutte: ~
Expand Down
5 changes: 0 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@
"build/profiles/contrib/{$name}": ["type:drupal-profile"],
"build/modules/contrib/{$name}": ["type:drupal-module"],
"build/themes/contrib/{$name}": ["type:drupal-theme"]
},
"patches": {
"drupal/cas": {
"https://www.drupal.org/project/cas/issues/3020014": "https://www.drupal.org/files/issues/2018-12-12/3020014-2.patch"
}
}
},
"config": {
Expand Down
25 changes: 25 additions & 0 deletions tests/Behat/AuthenticationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,29 @@ public function setConfigProxyInitialize(): void {
$this->setConfig('cas.settings', 'proxy.initialize', TRUE);
}

/**
* Blocks a user given its username.
*
* @var string $username
* The name of the user to be blocked.
*
* @When the user :username is blocked
*
* @throws \Exception
* Thrown when the user with the given name does not exist.
*/
public function blockUser(string $username): void {
$users = \Drupal::entityTypeManager()
->getStorage('user')
->loadByProperties([
'name' => $username,
]);
/** @var \Drupal\user\Entity\User $user */
$user = $users ? reset($users) : FALSE;
if ($user) {
$user->block();
$user->save();
}
}

}
34 changes: 0 additions & 34 deletions tests/Behat/DrupalContext.php

This file was deleted.

24 changes: 5 additions & 19 deletions tests/features/ecas-login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,14 @@ Feature: Login through OE Authentication
And I should see the link "Log in"

Scenario: A blocked user should not be able to log in
Given the user "chucknorris" is blocked
When I am on the homepage
And I click "Log in"
And I click "European Commission"

# Redirected to the mock server.
And I fill in "Username or e-mail address" with "texasranger@chuck_norris.com.eu"
And I fill in "Password" with "Qwerty098"
And I press the "Login!" button

# Redirected back to Drupal.
Then I should see "You have been logged in."
And I should see the link "My account"
And I should see the link "Log out"
And I should not see the link "Log in"

# After being blocked a user is logged out.
When the user "chucknorris" is blocked
And I reload the page
And I should see the link "Log in"
Then I should see the link "Log in"
And I should not see the link "Log out"

# When I try to log in again I will be denied access.
When I click "Log in"
And I press "Proceed"
And I fill in "Username or e-mail address" with "texasranger@chuck_norris.com.eu"
And I fill in "Password" with "Qwerty098"
And I press the "Login!" button
Then I should see "There was a problem logging in, please contact a site administrator."
2 changes: 1 addition & 1 deletion tests/features/ecas-register.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Feature: Register through OE Authentication
And I visit "/user/register"

# Redirected to the Ecas mockup server.
Then I should see "Service Create an account"
Then I should see "Create an account"

0 comments on commit 065de08

Please sign in to comment.