Skip to content
Snippets Groups Projects
Commit c658b550 authored by unknown's avatar unknown
Browse files

fixes for simpletests related to og

parent e1f7ac1d
No related branches found
Tags 7.x-2.0-beta4
No related merge requests found
......@@ -50,6 +50,9 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
}
public function og1ConsumerIdParts($consumer_id) {
if (!is_scalar($consumer_id)) {
return array(NULL, NULL);
}
$parts = explode('-', $consumer_id);
return (count($parts) != 2) ? array(NULL, NULL) : $parts;
}
......@@ -517,7 +520,6 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
*/
//dpm("og_actions"); dpm($og_actions); dpm("user_auth_data"); dpm($user_auth_data);
$group_audience = $user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE];
// grants
foreach ($og_actions['grants'] as $gid => $rids) {
$existing_roles = og_get_user_roles($gid, $user->uid);
......@@ -543,16 +545,15 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
}
// revokes
$group_audience_gids = empty($user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE]['gid']) ? array() : $user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE]['gid'];
foreach ($og_actions['revokes'] as $gid => $rids) {
$existing_roles = og_get_user_roles($gid, $user->uid);
if (in_array($this->defaultMembershipRid, array_values($existing_roles))) {
// ungroup and set audience
if (!empty($group_audience['gid'])) {
foreach ($group_audience['gid'] as $i => $_audience_gid) {
if ($_audience_gid == $gid) {
unset($user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][$i]);
}
}
foreach ($group_audience_gids as $i => $_audience_gid) {
if ($_audience_gid == $gid) {
unset($user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][$i]);
}
}
og_entity_presave($user, 'user');
$user = og_ungroup($gid, 'user', $user, TRUE);
......
......@@ -46,7 +46,7 @@ class LdapAuthorizationOg1Tests extends LdapTestCase {
//}
function setUp($addl_modules = array()) {
parent::setUp(array('ldap_authentication', 'ldap_authorization', 'ldap_authorization_drupal_role', 'ldap_authorization_og', 'ldap_test', 'og_ui'));
parent::setUp(array('entity', 'ctools', 'og', 'ldap_authentication', 'ldap_authorization', 'ldap_authorization_drupal_role', 'ldap_authorization_og', 'ldap_test', 'og_ui'));
variable_set('ldap_simpletest', 2);
if (ldap_authorization_og_og_version() != 1) {
......
......@@ -328,13 +328,27 @@ function testFlags() {
'LDAP_authorz.Flags.status.0'
);
list($og_gryffindor_node, $group_entity_id) = ldap_authorization_og2_get_group_from_name($this->groupEntityType, 'gryffindor');
list($og_students_node, $group_entity_id) = ldap_authorization_og2_get_group_from_name($this->groupEntityType, 'students');
list($og_faculty_node, $group_entity_id) = ldap_authorization_og2_get_group_from_name($this->groupEntityType, 'faculty');
$anonymous_rid = ldap_authorization_og2_rid_from_role_name($this->groupEntityType, $this->groupBundle, $og_gryffindor_node->nid, OG_ANONYMOUS_ROLE);
$member_rid = ldap_authorization_og2_rid_from_role_name($this->groupEntityType, $this->groupBundle, $og_students_node->nid, OG_AUTHENTICATED_ROLE);
$admin_rid = ldap_authorization_og2_rid_from_role_name($this->groupEntityType, $this->groupBundle, $og_faculty_node->nid, OG_ADMINISTRATOR_ROLE);
$dungeon_master_rid = ldap_authorization_og2_rid_from_role_name($this->groupEntityType, $this->groupBundle, $og_faculty_node->nid, 'dungeon-master');
$time_keeper = ldap_authorization_og2_rid_from_role_name($this->groupEntityType, $this->groupBundle, $og_faculty_node->nid, 'time-keeper');
$faculty_member_consumer_id = ldap_authorization_og_authorization_id($og_faculty_node->nid, $member_rid, 'node');
$faculty_dungeon_master_consumer_id = ldap_authorization_og_authorization_id($og_faculty_node->nid, $dungeon_master_rid, 'node');
$students_member_consumer_id = ldap_authorization_og_authorization_id($og_students_node->nid, $member_rid, 'node');
$gryffindor_member_consumer_id = ldap_authorization_og_authorization_id($og_gryffindor_node->nid, $member_rid, 'node');
$this->consumerAdminConf['og_group']->status = 1;
$this->consumerAdminConf['og_group']->save();
list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query', 'og_group'); // just see if the correct ones are derived.
//debug('ldap_authorizations_user_authorizations enabled: '); debug($new_authorizations); debug($notifications);
$correct_groups = !empty($new_authorizations['og_group']['node:students:member']) && !empty($new_authorizations['og_group']['node:gryffindor:member']);
$correct_groups = !empty($new_authorizations['og_group'][$students_member_consumer_id]) &&
!empty($new_authorizations['og_group'][$gryffindor_member_consumer_id]);
$this->assertTrue($correct_groups, 'enabled consumer configuration allows authorizations.', 'LDAP_authorz.Flags.status.1');
if (!$correct_groups) {
debug('LDAP_authorz.Flags.enable.1 roles with enabled'); debug($new_authorizations);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment