From c27a0e7a41f2d5bc8018d06294d5647c558f12a1 Mon Sep 17 00:00:00 2001 From: Marco Villegas Date: Wed, 8 Dec 2010 13:16:59 -0500 Subject: [PATCH] several fixes - Actually use mapped account plugin at repo creation on the mapped account auth plugin test. - Unify schema for {versioncontrol_auth_account} - minor: Add auth_handler as one possible plugin. - Do not use array_merge_reursive for repo plugins data member. If we do so, we end up with two plugins for a given plugin_slot instead of one plugin.(recursive join both arrays instead of set one of them) - Force returning an array(not object which is the default) for VersioncontrolAuthHandlerMappedAccounts::userData, which is what we are assuming. --- includes/VersioncontrolRepository.php | 1 + ...rsioncontrolAuthHandlerMappedAccounts.class.php | 2 +- tests/VersioncontrolAccountAuthPlugin.test | 10 ++++++++-- tests/VersioncontrolTestCase.test | 12 +++++++++--- versioncontrol.install | 12 ++++++------ 5 files changed, 25 insertions(+), 12 deletions(-) diff --git includes/VersioncontrolRepository.php includes/VersioncontrolRepository.php index bbf2299..18c1b8d 100644 --- includes/VersioncontrolRepository.php +++ includes/VersioncontrolRepository.php @@ -99,6 +99,7 @@ abstract class VersioncontrolRepository implements VersioncontrolEntityInterface * The current plugin types(array keys) are: * - author_mapper * - committer_mapper + * - auth_handler * * @var array */ diff --git includes/plugins/vcs_auth/VersioncontrolAuthHandlerMappedAccounts.class.php includes/plugins/vcs_auth/VersioncontrolAuthHandlerMappedAccounts.class.php index 3e1ad52..42479b6 100644 --- includes/plugins/vcs_auth/VersioncontrolAuthHandlerMappedAccounts.class.php +++ includes/plugins/vcs_auth/VersioncontrolAuthHandlerMappedAccounts.class.php @@ -66,7 +66,7 @@ class VersioncontrolAuthHandlerMappedAccounts implements VersioncontrolAuthHandl ->fields('base') ->condition('repo_id', $this->repository->repo_id) ->execute() - ->fetchAllAssoc('uid'); + ->fetchAllAssoc('uid', PDO::FETCH_ASSOC); foreach ($this->userData as &$data) { $data['per-label-auth'] = array(); diff --git tests/VersioncontrolAccountAuthPlugin.test tests/VersioncontrolAccountAuthPlugin.test index 952e2b8..5dbf80a 100644 --- tests/VersioncontrolAccountAuthPlugin.test +++ tests/VersioncontrolAccountAuthPlugin.test @@ -33,12 +33,18 @@ class VersioncontrolAccountAuthPlugin extends VersioncontrolTestCase { $admin_user = $this->drupalCreateUser(array('administer version control systems')); $this->drupalLogin($admin_user); + $repo_data = array( + 'plugins' => array( + 'auth_handler' => 'account' + ), + ); + foreach ($this->backends as $type => $backend) { - $this->repos[$type] = $this->versioncontrolCreateRepository($type); + $this->repos[$type] = $this->versioncontrolCreateRepository($type, $repo_data); } } - public function testAuthPluginCrud() { + public function testMappedAccountsAuthPluginCrud() { //FIXME do this for each repo? $repo = reset($this->repos); // Manually instantiate the plugin for the create portion diff --git tests/VersioncontrolTestCase.test tests/VersioncontrolTestCase.test index 51e77ae..3861fcc 100644 --- tests/VersioncontrolTestCase.test +++ tests/VersioncontrolTestCase.test @@ -141,12 +141,18 @@ abstract class VersioncontrolTestCase extends DrupalWebTestCase { 'updated' => 0, 'locked' => 0, 'data' => array(), - 'plugins' => array( - 'auth_handler' => 'ffa', - ), + 'plugins' => array(), + ); + $default_plugins = array( + 'auth_handler' => 'ffa', ); $data = array_merge_recursive($default_data, $data); + foreach ($default_plugins as $plugin_slot => $default_plugin) { + if (empty($data['plugins'][$plugin_slot])) { + $data['plugins'][$plugin_slot] = $default_plugin; + } + } $backend = $this->backends[$backend]; $repo = $backend->buildEntity('repo', $data); $repo->insert(); diff --git versioncontrol.install versioncontrol.install index c40aa06..0eed54a 100644 --- versioncontrol.install +++ versioncontrol.install @@ -431,14 +431,14 @@ function versioncontrol_schema() { 'not null' => TRUE, 'default' => 0, ), - 'update_any_branch' => array( + 'branch_update' => array( 'type' => 'int', 'description' => 'Grant user access to update/write to any branch in the repository. 1 is global access, 0 defers to individual branch perms.', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ), - 'delete_any_branch' => array( + 'branch_delete' => array( 'type' => 'int', 'description' => 'Grant user access to delete any branch in the repository. 1 is global access, 0 defers to individual branch perms.', 'size' => 'tiny', @@ -452,16 +452,16 @@ function versioncontrol_schema() { 'not null' => TRUE, 'default' => 0, ), - 'update_any_tag' => array( + 'tag_update' => array( 'type' => 'int', 'description' => 'Grant user access to update/modify any tag in the repository. 1 is global access, 0 defers to individual tag perms.', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, ), - 'delete_any_tag' => array( + 'tag_delete' => array( 'type' => 'int', - 'description' => 'Grant user access to delete any tag in the repository. 1 is global access, 0 defers to individual tag perms.', + 'description' => 'Grant user access to delete tags in the repository. 0 is no access, 1 is some access, 2 can delete all tags.', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, @@ -1090,4 +1090,4 @@ function versioncontrol_update_6309() { db_create_table($ret, 'versioncontrol_auth_account_label', $auth_label_table); return $ret; -} \ No newline at end of file +} -- 1.7.2.3