protected function LdapSsoBrowserTest::setUp in LDAP Single Sign On 8.4
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ LdapSsoBrowserTest.php, line 46
Class
- LdapSsoBrowserTest
- Test redirection behaviour with SSO enabled.
Namespace
Drupal\Tests\ldap_sso\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
]);
// Create a node for front page.
$node_front = $this
->drupalCreateNode();
// Create a node with a random alias.
$this->nodeWithAlias = $this
->drupalCreateNode([
'type' => 'page',
'status' => 1,
'path' => '/' . $this
->randomMachineName(),
]);
// Configure 'node' as front page.
$this
->config('system.site')
->set('page.front', '/node/' . $node_front
->id())
->save();
/** @var \Drupal\Core\Entity\EntityTypeManager $manager */
$manager = $this->container
->get('entity_type.manager');
$server = $manager
->getStorage('ldap_server')
->create([
'id' => 'test',
'timeout' => 30,
'encryption' => 'none',
'address' => 'example',
'port' => 963,
'basedn' => [
'ou=people,dc=hogwarts,dc=edu',
],
'user_attr' => 'cn',
'unique_persistent_attr' => 'uid',
'status' => TRUE,
'mail_attr' => 'mail',
]);
$server
->save();
$this
->config('ldap_authentication.settings')
->set('sids', [
$server
->id(),
])
->set('excludeIfTextInDn', [])
->set('allowOnlyIfTextInDn', [])
->save();
$this
->config('ldap_user.settings')
->set('acctCreation', LdapUserAttributesInterface::ACCOUNT_CREATION_LDAP_BEHAVIOUR)
->set('drupalAcctProvisionServer', $server
->id())
->set('ldapUserSyncMappings', [
'drupal' => [],
'ldap' => [],
])
->set('drupalAcctProvisionTriggers', [
LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_AUTHENTICATION,
LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_ON_MANUAL_CREATION,
LdapUserAttributesInterface::PROVISION_DRUPAL_USER_ON_USER_UPDATE_CREATE,
])
->save();
$this
->config('ldap_sso.settings')
->set('seamlessLogin', TRUE)
->set('ssoExcludedHosts', [])
->set('ssoExcludedPaths', [])
->set('ssoSplitUserRealm', FALSE)
->set('ssoVariable', 'REMOTE_USER')
->save();
$this->container
->get('config.factory')
->reset();
}