security updates of unpatched modules
This commit is contained in:
@@ -6,6 +6,13 @@
|
||||
*/
|
||||
class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* User without permissions to edit snippets.
|
||||
*
|
||||
* @var \StdClass
|
||||
*/
|
||||
protected $noSnippetUser;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Google Analytics basic tests',
|
||||
@@ -25,6 +32,8 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
);
|
||||
|
||||
// User to set up google_analytics.
|
||||
$this->noSnippetUser = $this->drupalCreateUser($permissions);
|
||||
$permissions[] = 'add JS snippets for google analytics';
|
||||
$this->admin_user = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($this->admin_user);
|
||||
}
|
||||
@@ -48,6 +57,26 @@ class GoogleAnalyticsBasicTest extends DrupalWebTestCase {
|
||||
$edit['googleanalytics_account'] = $this->randomName(2);
|
||||
$this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
|
||||
$this->assertRaw(t('A valid Google Analytics Web Property ID is case sensitive and formatted like UA-xxxxxxx-yy.'), '[testGoogleAnalyticsConfiguration]: Invalid Web Property ID number validated.');
|
||||
|
||||
// User should have access to code snippets.
|
||||
$this->assertFieldByName('googleanalytics_codesnippet_create');
|
||||
$this->assertFieldByName('googleanalytics_codesnippet_before');
|
||||
$this->assertFieldByName('googleanalytics_codesnippet_after');
|
||||
$this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_create' and @disabled='disabled']", NULL, '"Create only fields" is enabled.');
|
||||
$this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.');
|
||||
$this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.');
|
||||
|
||||
// Login as user without JS permissions.
|
||||
$this->drupalLogin($this->noSnippetUser);
|
||||
$this->drupalGet('admin/config/system/googleanalytics');
|
||||
|
||||
// User should *not* have access to snippets, but create fields.
|
||||
$this->assertFieldByName('googleanalytics_codesnippet_create');
|
||||
$this->assertFieldByName('googleanalytics_codesnippet_before');
|
||||
$this->assertFieldByName('googleanalytics_codesnippet_after');
|
||||
$this->assertNoFieldByXPath("//textarea[@name='googleanalytics_codesnippet_create' and @disabled='disabled']", NULL, '"Create only fields" is enabled.');
|
||||
$this->assertFieldByXPath("//textarea[@name='googleanalytics_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.');
|
||||
$this->assertFieldByXPath("//textarea[@name='googleanalytics_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.');
|
||||
}
|
||||
|
||||
function testGoogleAnalyticsPageVisibility() {
|
||||
@@ -284,6 +313,7 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
|
||||
|
||||
// User to set up google_analytics.
|
||||
$this->admin_user = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($this->admin_user);
|
||||
}
|
||||
|
||||
function testGoogleAnalyticsCustomDimensions() {
|
||||
@@ -362,34 +392,30 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
|
||||
1 => array(
|
||||
'index' => 1,
|
||||
'value' => '6',
|
||||
'value_expected' => 6,
|
||||
),
|
||||
2 => array(
|
||||
'index' => 2,
|
||||
'value' => '8000',
|
||||
'value_expected' => 8000,
|
||||
),
|
||||
3 => array(
|
||||
'index' => 3,
|
||||
'value' => '7.8654',
|
||||
'value_expected' => 7.8654,
|
||||
),
|
||||
4 => array(
|
||||
'index' => 4,
|
||||
'value' => '1123.4',
|
||||
'value_expected' => 1123.4,
|
||||
),
|
||||
5 => array(
|
||||
'index' => 5,
|
||||
'value' => '5,67',
|
||||
'value_expected' => 5,
|
||||
),
|
||||
);
|
||||
|
||||
variable_set('googleanalytics_custom_metric', $googleanalytics_custom_metric);
|
||||
$this->drupalGet('');
|
||||
|
||||
foreach ($googleanalytics_custom_metric as $metric) {
|
||||
$this->assertRaw('ga("set", ' . drupal_json_encode('metric' . $metric['index']) . ', ' . drupal_json_encode($metric['value_expected']) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Metric #' . $metric['index'] . ' is shown.');
|
||||
$this->assertRaw('ga("set", ' . drupal_json_encode('metric' . $metric['index']) . ', ' . drupal_json_encode((float) $metric['value']) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Metric #' . $metric['index'] . ' is shown.');
|
||||
}
|
||||
|
||||
// Test whether tokens are replaced in custom metric values.
|
||||
@@ -421,6 +447,30 @@ class GoogleAnalyticsCustomDimensionsAndMetricsTest extends DrupalWebTestCase {
|
||||
$this->assertNoRaw('ga("set", ' . drupal_json_encode('metric3') . ', ' . drupal_json_encode('') . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Empty value is not shown.');
|
||||
$this->assertRaw('ga("set", ' . drupal_json_encode('metric4') . ', ' . drupal_json_encode(0) . ');', '[testGoogleAnalyticsCustomDimensionsAndMetrics]: Value 0 is shown.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if Custom Dimensions token form validation works.
|
||||
*/
|
||||
public function testGoogleAnalyticsCustomDimensionsTokenFormValidation() {
|
||||
$ua_code = 'UA-123456-1';
|
||||
|
||||
// Check form validation.
|
||||
$edit['googleanalytics_account'] = $ua_code;
|
||||
$edit['googleanalytics_custom_dimension[indexes][1][value]'] = '[current-user:name]';
|
||||
$edit['googleanalytics_custom_dimension[indexes][2][value]'] = '[current-user:edit-url]';
|
||||
$edit['googleanalytics_custom_dimension[indexes][3][value]'] = '[user:name]';
|
||||
$edit['googleanalytics_custom_dimension[indexes][4][value]'] = '[term:name]';
|
||||
$edit['googleanalytics_custom_dimension[indexes][5][value]'] = '[term:tid]';
|
||||
|
||||
$this->drupalPost('admin/config/system/googleanalytics', $edit, t('Save configuration'));
|
||||
|
||||
$this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 1)), '@invalid-tokens' => implode(', ', array('[current-user:name]')))));
|
||||
$this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 2)), '@invalid-tokens' => implode(', ', array('[current-user:edit-url]')))));
|
||||
$this->assertRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 3)), '@invalid-tokens' => implode(', ', array('[user:name]')))));
|
||||
// BUG #2037595
|
||||
//$this->assertNoRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 4)), '@invalid-tokens' => implode(', ', array('[term:name]')))));
|
||||
//$this->assertNoRaw(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', array('%element-title' => t('Custom dimension value #@index', array('@index' => 5)), '@invalid-tokens' => implode(', ', array('[term:tid]')))));
|
||||
}
|
||||
}
|
||||
|
||||
class GoogleAnalyticsStatusMessagesTest extends DrupalWebTestCase {
|
||||
|
Reference in New Issue
Block a user