Commit 56a7c639 authored by catch's avatar catch
Browse files

Issue #817118 by Sylvain Lecoy, bfroehle, Stevel: Tests for remove {authmap}...

Issue #817118 by Sylvain Lecoy, bfroehle, Stevel: Tests for remove {authmap} and migrate OpenID entries to their own table.
parent 91788849
<?php
/**
* @file
* Definition of Drupal\openid\Tests\Upgrade\OpenIDUpgradePathTest.
*/
namespace Drupal\openid\Tests\Upgrade;
use Drupal\system\Tests\Upgrade\UpgradePathTestBase;
/**
* Performs major version release upgrade tests on a populated database.
*
* Loads an installation of Drupal 7.x and runs the upgrade process on it.
*
* The install contains the minimal profile (plus openid module) modules
* with generated users in authmap so that the upgrade path can be tested.
*/
class OpenIDAuthmapUpgradePathTest extends UpgradePathTestBase {
public static function getInfo() {
return array(
'name' => 'OpenID upgrade path',
'description' => 'Identities migration from the authmap upgrade tests.',
'group' => 'OpenID',
);
}
public function setUp() {
// Path to the database dump files.
$this->databaseDumpFiles = array(
drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.minimal.database.php.gz',
drupal_get_path('module', 'openid') . '/tests/upgrade/drupal-7.openid.database.php',
drupal_get_path('module', 'openid') . '/tests/upgrade/drupal-7.openid.authmap.database.php',
);
parent::setUp();
}
/**
* Tests expected openid identities conversion after a successful upgrade.
*/
public function testIdentitiesUpgrade() {
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
// Verify that user identities was properly upgraded.
$expected_identities = array(
1 => (object) array(
'aid' => 1,
'uid' => 1,
'identifier' => 'userA@providerA',
),
2 => (object) array(
'aid' => 2,
'uid' => 1,
'identifier' => 'userB@providerA',
));
$db_identities = db_select('openid_identities', 'oi')
->fields('oi')
->execute()
->fetchAllAssoc('aid');
foreach ($expected_identities as $aid => $expected_identity) {
$this->assertEqual($expected_identity, $db_identities[$aid]);
}
$this->assertEqual(count($expected_identities), count($db_identities));
}
}
<?php
/**
* @file
* Database additions for authmap tests. Used in
* \Drupal\openid\Tests\Upgrade\OpenIDAuthmapUpgradePathTest.
*
* This dump only contains data and schema components relevant for user authmap
* upgrade tests.
*/
db_insert('authmap')->fields(array(
'aid',
'uid',
'authname',
'module',
))
->values(array(
'aid' => 1,
'uid' => 1,
'authname' => 'userA@providerA',
'module' => 'openid',
))
->values(array(
'aid' => 2,
'uid' => 1,
'authname' => 'userB@providerA',
'module' => 'openid',
))
->values(array(
'aid' => 3,
'uid' => 1,
'authname' => 'userA@providerB',
'module' => 'fancy',
))
->execute();
<?php
/**
* @file
* Database additions for openid tests.
*
* This dump enables openid module, the drupal-7.bare.minimal.database.php.gz
* file is imported before this dump, so the two form the database structure
* expected in tests altogether.
*/
db_create_table('openid_association', array(
'fields' => array(
'idp_endpoint_uri' => array(
'type' => 'varchar',
'length' => 255,
),
'assoc_handle' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'assoc_type' => array(
'type' => 'varchar',
'length' => 32,
),
'session_type' => array(
'type' => 'varchar',
'length' => 32,
),
'mac_key' => array(
'type' => 'varchar',
'length' => 255,
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'expires_in' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'assoc_handle',
),
'module' => 'openid',
'name' => 'openid_association',
));
db_create_table('openid_nonce', array(
'fields' => array(
'idp_endpoint_uri' => array(
'type' => 'varchar',
'length' => 255,
),
'nonce' => array(
'type' => 'varchar',
'length' => 255,
),
'expires' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'nonce' => array(
'nonce',
),
'expires' => array(
'expires',
),
),
'module' => 'openid',
'name' => 'openid_nonce',
));
db_update('system')
->fields(array(
'filename' => 'modules/openid/openid.module',
'name' => 'openid',
'type' => 'module',
'owner' => '',
'status' => '1',
'bootstrap' => '0',
'schema_version' => '6000',
'weight' => '0',
'info' => 'a:11:{s:4:"name";s:6:"OpenID";s:11:"description";s:48:"Allows users to log into your site using OpenID.";s:7:"version";s:11:"7.14+29-dev";s:7:"package";s:4:"Core";s:4:"core";s:3:"7.x";s:5:"files";a:1:{i:0;s:11:"openid.test";}s:7:"project";s:6:"drupal";s:9:"datestamp";s:10:"1338768537";s:12:"dependencies";a:0:{}s:3:"php";s:5:"5.2.4";s:9:"bootstrap";i:0;}',
))
->condition('filename', 'modules/openid/openid.module')
->execute();
......@@ -148,49 +148,6 @@ function user_schema() {
),
);
$schema['authmap'] = array(
'description' => 'Stores distributed authentication mapping. The authmap is deprecated since Drupal 8 and is kept only in a migration data process in mind. Modules that uses the authmap should move their data in custom tables as it will removed in Drupal 9.',
'fields' => array(
'aid' => array(
'description' => 'Primary Key: Unique authmap ID.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "User's {users}.uid.",
),
'authname' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Unique authentication name.',
),
'module' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Module which is controlling the authentication.',
),
),
'unique keys' => array(
'authname' => array('authname'),
),
'primary key' => array('aid'),
'foreign keys' => array(
'user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
$schema['role'] = array(
'description' => 'Stores user roles.',
'fields' => array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment