-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from openeuropa/OPENEUROPA-1177
OPENEUROPA-1177: Consolidate oe_authentication
- Loading branch information
Showing
8 changed files
with
149 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* OpenEuropa Authentication module. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Implements hook_form_alter(). | ||
*/ | ||
function oe_authentication_form_user_form_alter(&$form, FormStateInterface $form_state, $form_id) { | ||
$form['account']['mail']['#disabled'] = TRUE; | ||
$form['account']['name']['#disabled'] = TRUE; | ||
unset($form['account']['pass']); | ||
unset($form['account']['current_pass']); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Drupal\oe_authentication\Exception; | ||
|
||
/** | ||
* Base class for the Open Europa Authentication exceptions. | ||
*/ | ||
class AuthenticationException extends \Exception {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
|
||
namespace Drupal\Tests\oe_authentication\Kernel; | ||
|
||
use Drupal\KernelTests\KernelTestBase; | ||
use Drupal\oe_authentication\PCasFactory; | ||
|
||
/** | ||
* Class InstallationTest. | ||
*/ | ||
class PCasFactoryTest extends KernelTestBase { | ||
|
||
/** | ||
* Modules to enable. | ||
* | ||
* @var array | ||
*/ | ||
public static $modules = [ | ||
'oe_authentication', | ||
'system', | ||
'user', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp() { | ||
parent::setUp(); | ||
|
||
$this->installConfig([ | ||
'oe_authentication', | ||
]); | ||
} | ||
|
||
/** | ||
* Test default configuration options for the PCasFactory class. | ||
*/ | ||
public function testDefaultConfiguration(): void { | ||
$pcasfactory = new PCasFactory($this->container->get('session'), $this->container->get('config.factory')); | ||
$pcas = $pcasfactory->getPCas(); | ||
$properties = $pcas->getProperties(); | ||
$this->assertEquals('http://authentication:8001', $properties['base_url']); | ||
$login_protocol = [ | ||
'path' => '/login', | ||
'query' => [], | ||
'allowed_parameters' => ['service', 'renew', 'gateway'], | ||
]; | ||
$this->assertEquals($login_protocol, $properties['protocol']['login']); | ||
} | ||
|
||
/** | ||
* Test custom configuration options for the PCasFactory class. | ||
*/ | ||
public function testCustomConfiguration(): void { | ||
$this->config('oe_authentication.settings') | ||
->set('base_url', 'https://ecas.ec.europa.eu/cas') | ||
->save(TRUE); | ||
$protocols = [ | ||
'login' => [ | ||
'path' => '/login', | ||
'query' => [], | ||
'allowed_parameters' => ['service', 'renew', 'gateway'], | ||
], | ||
]; | ||
$pcasfactory = new PCasFactory($this->container->get('session'), $this->container->get('config.factory'), $protocols); | ||
$pcas = $pcasfactory->getPCas(); | ||
$properties = $pcas->getProperties(); | ||
$this->assertEquals('https://ecas.ec.europa.eu/cas', $properties['base_url']); | ||
$this->assertEquals($protocols, $properties['protocol']); | ||
} | ||
|
||
} |