all contrib module security updates done

This commit is contained in:
2020-09-24 22:47:32 +02:00
parent 7d87153100
commit 0fbb9c4610
1612 changed files with 116663 additions and 32269 deletions
@@ -21,7 +21,7 @@ class EntityReferenceAdminTestCase extends DrupalWebTestCase {
parent::setUp(array('field_ui', 'entity', 'ctools', 'entityreference'));
// Create test user.
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer content types'));
$this->admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer fields'));
$this->drupalLogin($this->admin_user);
// Create content type, with underscores.
@@ -0,0 +1,241 @@
<?php
/**
* @file
* Test case for simple CCK field mapper mappers/content.inc.
*/
/**
* Class for testing Feeds field mapper.
*/
class FeedsMapperFieldTestCase extends DrupalWebTestCase{
/**
* Test info function.
*/
public static function getInfo() {
return array(
'name' => 'Feeds integration (field mapper)',
'description' => 'Test Feeds Mapper support for fields.',
'group' => 'Entity Reference',
'dependencies' => array('feeds'),
);
}
/**
* Set-up function.
*/
public function setUp() {
parent::setUp();
module_enable(array('entityreference_feeds_test'), TRUE);
$this->resetAll();
$permissions[] = 'access content';
$permissions[] = 'administer site configuration';
$permissions[] = 'administer content types';
$permissions[] = 'administer nodes';
$permissions[] = 'bypass node access';
$permissions[] = 'administer taxonomy';
$permissions[] = 'administer users';
$permissions[] = 'administer feeds';
// Create an admin user and log in.
$this->admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->admin_user);
}
/**
* Check if mapping exists.
*
* @param string $id
* ID of the importer.
* @param integer $i
* The key of the mapping.
* @param string $source
* The source field.
* @param string $target
* The target field.
*
* @return integer
* -1 if the mapping doesn't exist, the key of the mapping otherwise.
*/
public function mappingExists($id, $i, $source, $target) {
$current_mappings = $this->getCurrentMappings($id);
if ($current_mappings) {
foreach ($current_mappings as $key => $mapping) {
if ($mapping['source'] == $source && $mapping['target'] == $target && $key == $i) {
return $key;
}
}
}
return -1;
}
/**
* Adds mappings to a given configuration.
*
* @param string $id
* ID of the importer.
* @param array $mappings
* An array of mapping arrays. Each mapping array must have a source and
* an target key and can have a unique key.
* @param bool $test_mappings
* (optional) TRUE to automatically test mapping configs. Defaults to TRUE.
*/
public function addMappings($id, $mappings, $test_mappings = TRUE) {
$path = "admin/structure/feeds/$id/mapping";
// Iterate through all mappings and add the mapping via the form.
foreach ($mappings as $i => $mapping) {
if ($test_mappings) {
$current_mapping_key = $this->mappingExists($id, $i, $mapping['source'], $mapping['target']);
$this->assertEqual($current_mapping_key, -1, 'Mapping does not exist before addition.');
}
// Get unique flag and unset it. Otherwise, drupalPost will complain that
// Split up config and mapping.
$config = $mapping;
unset($config['source'], $config['target']);
$mapping = array('source' => $mapping['source'], 'target' => $mapping['target']);
// Add mapping.
$this->drupalPost($path, $mapping, t('Add'));
// If there are other configuration options, set them.
if ($config) {
$this->drupalPostAJAX(NULL, array(), 'mapping_settings_edit_' . $i);
// Set some settings.
$edit = array();
foreach ($config as $key => $value) {
$edit["config[$i][settings][$key]"] = $value;
}
$this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_' . $i);
$this->drupalPost(NULL, array(), t('Save'));
}
if ($test_mappings) {
$current_mapping_key = $this->mappingExists($id, $i, $mapping['source'], $mapping['target']);
$this->assertTrue($current_mapping_key >= 0, 'Mapping exists after addition.');
}
}
}
/**
* Gets an array of current mappings from the feeds_importer config.
*
* @param string $id
* ID of the importer.
*
* @return bool|array
* FALSE if the importer has no mappings, or an an array of mappings.
*/
public function getCurrentMappings($id) {
$config = db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => $id))->fetchField();
$config = unserialize($config);
// We are very specific here. 'mappings' can either be an array or not
// exist.
if (array_key_exists('mappings', $config['processor']['config'])) {
$this->assertTrue(is_array($config['processor']['config']['mappings']), 'Mappings is an array.');
return $config['processor']['config']['mappings'];
}
return FALSE;
}
/**
* Basic test loading a double entry CSV file.
*/
public function test() {
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/structure/types/manage/article/fields');
$this->assertText('Ref - entity ID', t('Found Entity reference field %field.', array('%field' => 'field_er_id')));
$this->assertText('Ref - entity label', t('Found Entity reference field %field.', array('%field' => 'field_er_label')));
$this->assertText('Ref - feeds GUID', t('Found Entity reference field %field.', array('%field' => 'field_er_guid')));
$this->assertText('Ref - feeds URL', t('Found Entity reference field %field.', array('%field' => 'field_er_url')));
// Add feeds importer
$this->drupalGet('admin/structure/feeds');
$this->clickLink('Add importer');
$this->drupalPost('admin/structure/feeds/create', array('name' => 'Nodes', 'id' => 'nodes'), 'Create');
$this->assertText('Your configuration has been created with default settings.');
$this->drupalPost('admin/structure/feeds/nodes/settings/', array('content_type' => '', 'import_period' => -1), 'Save');
$this->assertText('Your changes have been saved.');
$this->drupalPost("admin/structure/feeds/nodes/fetcher", array('plugin_key' => 'FeedsFileFetcher'), 'Save');
$config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => 'nodes'))->fetchField());
$this->assertEqual($config['fetcher']['plugin_key'], 'FeedsFileFetcher', 'Verified correct fetcher (FeedsFileFetcher).');
$this->drupalPost("admin/structure/feeds/nodes/parser", array('plugin_key' => 'FeedsCSVParser'), 'Save');
$config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id = :id", array(':id' => 'nodes'))->fetchField());
$this->assertEqual($config['parser']['plugin_key'], 'FeedsCSVParser', 'Verified correct parser (FeedsCSVParser).');
$this->drupalPost('admin/structure/feeds/nodes/settings/FeedsNodeProcessor', array('content_type' => 'article'), 'Save');
$this->assertText('Your changes have been saved.');
$this->addMappings('nodes', array(
0 => array(
'source' => 'title',
'target' => 'title',
),
1 => array(
'source' => 'nid',
'target' => 'nid',
'unique' => TRUE,
),
2 => array(
'source' => 'permalink',
'target' => 'url',
'unique' => TRUE,
),
3 => array(
'source' => 'nid',
'target' => 'guid',
'unique' => TRUE,
),
4 => array(
'source' => 'parent_nid',
'target' => 'field_er_id:etid',
),
5 => array(
'source' => 'parent_title',
'target' => 'field_er_label:label',
),
6 => array(
'source' => 'parent_url',
'target' => 'field_er_url:url',
),
7 => array(
'source' => 'parent_guid',
'target' => 'field_er_guid',
),
)
);
$file = realpath(getcwd()) . '/' . drupal_get_path('module', 'entityreference') . '/tests/feeds_test.csv';
$this->assertTrue(file_exists($file), 'Source file exists');
$this->drupalPost('import/nodes', array('files[feeds]' => $file), 'Import');
$this->assertText('Created 2 nodes');
$parent = node_load(1);
$this->assertTrue(empty($parent->field_er_id['und'][0]['target_id']), t('Parent node: Import by entity ID OK.'));
$this->assertTrue(empty($parent->field_er_label['und'][0]['target_id']), t('Parent node: Import by entity label OK.'));
$this->assertTrue(empty($parent->field_er_guid['und'][0]['target_id']), t('Parent node: Import by feeds GUID OK.'));
$this->assertTrue(empty($parent->field_er_url['und'][0]['target_id']), t('Parent node: Import by feeds URL OK.'));
$child = node_load(2);
$this->assertTrue($child->field_er_id['und'][0]['target_id'] == 1, t('Child node: Import by entity ID OK.'));
$this->assertTrue($child->field_er_label['und'][0]['target_id'] == 1, t('Child node: Import by entity label OK.'));
$this->assertTrue($child->field_er_guid['und'][0]['target_id'] == 1, t('Child node: Import by feeds GUID OK.'));
$this->assertTrue($child->field_er_url['und'][0]['target_id'] == 1, t('Child node: Import by feeds URL OK.'));
}
}
@@ -84,6 +84,14 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
'title' => 'Node unpublished (<&>)',
'uid' => 1,
),
// Title purposefully starts with same characters as published1 and
// published2 above but contains a slash.
'published_withslash' => (object) array(
'type' => 'article',
'status' => 1,
'title' => 'Node pub/lished1',
'uid' => 1,
),
);
$node_labels = array();
@@ -104,6 +112,7 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
'article' => array(
$nodes['published1']->nid => $node_labels['published1'],
$nodes['published2']->nid => $node_labels['published2'],
$nodes['published_withslash']->nid => $node_labels['published_withslash'],
),
),
),
@@ -141,6 +150,18 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
),
'result' => array(),
),
// Searching for "Node pub/" should return only the published_withslash node
// and not published1 and published2 from above.
array(
'arguments' => array(
array('Node pub/', 'CONTAINS'),
),
'result' => array(
'article' => array(
$nodes['published_withslash']->nid => $node_labels['published_withslash'],
),
),
),
);
$this->assertReferencable($field, $referencable_tests, 'Node handler');
@@ -156,6 +177,7 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
'article' => array(
$nodes['published1']->nid => $node_labels['published1'],
$nodes['published2']->nid => $node_labels['published2'],
$nodes['published_withslash']->nid => $node_labels['published_withslash'],
$nodes['unpublished']->nid => $node_labels['unpublished'],
),
),
@@ -172,6 +194,21 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
),
);
$this->assertReferencable($field, $referencable_tests, 'Node handler (admin)');
// Verify autocomplete input validation.
$handler = entityreference_get_selection_handler($field);
$element = array(
'#parents' => array('element_name'),
);
$form_state = array();
$form = array();
$value = $handler->validateAutocompleteInput($nodes['published1']->title, $element, $form_state, $form);
$this->assertEqual($value, $nodes['published1']->nid);
$invalid_input = $this->randomName();
$value = $handler->validateAutocompleteInput($invalid_input, $element, $form_state, $form);
$this->assertNull($value);
$this->assertEqual(form_get_error($element), t('There are no entities matching "%value"', array('%value' => $invalid_input)));
}
/**
@@ -234,7 +271,7 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
),
'result' => array(
'user' => array(
$users['admin']->uid => $user_labels['admin'],
$users['admin']->uid => ENTITYREFERENCE_DENIED,
$users['non_admin']->uid => $user_labels['non_admin'],
),
),
@@ -112,4 +112,52 @@ class EntityReferenceTaxonomyTestCase extends DrupalWebTestCase {
$this->assertFalse(taxonomy_select_nodes(1));
}
/**
* Add a second ER field from node/article to taxonomy.
*
* This should not cause {taxonomy_index} to receive duplicate entries.
*/
protected function setupForIndexDuplicates() {
// Create an entity reference field.
$field = array(
'entity_types' => array('node'),
'settings' => array(
'handler' => 'base',
'target_type' => 'taxonomy_term',
'handler_settings' => array(
'target_bundles' => array(),
),
),
'field_name' => 'field_entityreference_term2',
'type' => 'entityreference',
);
$field = field_create_field($field);
$instance = array(
'field_name' => 'field_entityreference_term2',
'bundle' => 'article',
'entity_type' => 'node',
);
// Enable the taxonomy-index behavior.
$instance['settings']['behaviors']['taxonomy-index']['status'] = TRUE;
field_create_instance($instance);
}
/**
* Make sure the index only contains one entry for a given node->term
* reference, even when multiple ER fields link from the node bundle to terms.
*/
public function testIndexDuplicates() {
// Extra setup for this test: add another ER field on this content type.
$this->setupForIndexDuplicates();
// Assert node insert with reference to term in first field.
$tid = 1;
$settings = array();
$settings['type'] = 'article';
$settings['field_entityreference_term'][LANGUAGE_NONE][0]['target_id'] = $tid;
$node = $this->drupalCreateNode($settings);
$this->assertEqual(taxonomy_select_nodes($tid), array($node->nid));
}
}
@@ -0,0 +1,3 @@
"nid","title","permalink","parent_nid","parent_title","parent_url","parent_guid"
"1","Views","http://drupal.org/project/views","","","",""
"2","Views bulk operations","http://drupal.org/project/views_bulk_operations","1","Views","http://drupal.org/project/views","1"
1 nid title permalink parent_nid parent_title parent_url parent_guid
2 1 Views http://drupal.org/project/views
3 2 Views bulk operations http://drupal.org/project/views_bulk_operations 1 Views http://drupal.org/project/views 1
@@ -0,0 +1,16 @@
name = "Entityreference - Feeds integration tests"
description = "Support module for the Entityreference - Feeds integration tests."
package = Testing
core = 7.x
hidden = TRUE
dependencies[] = feeds
dependencies[] = feeds_ui
dependencies[] = entityreference
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-1.5"
core = "7.x"
project = "entityreference"
datestamp = "1502895850"
@@ -0,0 +1,104 @@
<?php
/**
* @file
* Support module for Entity reference - Feeds integration.
*/
/**
* Implements hook_install().
*/
function entityreference_feeds_test_install() {
field_info_cache_clear();
// Entity reference field - mapped by ID.
$field = array(
'field_name' => 'field_er_id',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'node',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array('article' => 'article'),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_er_id',
'entity_type' => 'node',
'label' => 'Ref - entity ID',
'bundle' => 'article',
);
field_create_instance($instance);
// Entity reference field - mapped by Feeds GUID.
$field = array(
'field_name' => 'field_er_guid',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'node',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array('article' => 'article'),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_er_guid',
'entity_type' => 'node',
'label' => 'Ref - feeds GUID',
'bundle' => 'article',
);
field_create_instance($instance);
// Entity reference field - mapped by Feeds URL.
$field = array(
'field_name' => 'field_er_url',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'node',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array('article' => 'article'),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_er_url',
'entity_type' => 'node',
'label' => 'Ref - feeds URL',
'bundle' => 'article',
);
field_create_instance($instance);
// Entity reference field - mapped by Label.
$field = array(
'field_name' => 'field_er_label',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'node',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array('article' => 'article'),
),
),
);
field_create_field($field);
$instance = array(
'field_name' => 'field_er_label',
'entity_type' => 'node',
'label' => 'Ref - entity label',
'bundle' => 'article',
);
field_create_instance($instance);
}