Commit caaa5135 authored by Rick Hawkins's avatar Rick Hawkins
Browse files

Issue #3297063 by rlhawk, Project Update Bot, ameymudras, Jaydev Bhatt,...

Issue #3297063 by rlhawk, Project Update Bot, ameymudras, Jaydev Bhatt, jcnventura: Automated Drupal 10 compatibility fixes
parent eccc6f48
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
name: Encrypt
description: 'Provides an API for two-way encryption.'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8 || ^9 || ^10
package: Encryption
dependencies:
  - key:key
+1 −1
Original line number Diff line number Diff line
name: 'Encrypt Test module'
type: module
description: 'Test module for Encrypt'
core_version_requirement: ^8 || ^9
core_version_requirement: ^8 || ^9 || ^10
package: Testing
dependencies:
  - encrypt:encrypt
+39 −39
Original line number Diff line number Diff line
@@ -18,14 +18,14 @@ class EncryptTest extends EncryptTestBase {

    // Check if the plugin exists.
    // Encryption method option is present.
    $this->assertOption('edit-encryption-method', 'test_encryption_method');
    $this->assertSession()->optionExists('edit-encryption-method', 'test_encryption_method');
    // Encryption method text is present.
    $this->assertText('Test Encryption method');
    $this->assertSession()->pageTextContains('Test Encryption method');

    $edit = [
      'encryption_method' => 'test_encryption_method',
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');

    $edit = [
      'id' => 'test_encryption_profile',
@@ -33,7 +33,7 @@ class EncryptTest extends EncryptTestBase {
      'encryption_method' => 'test_encryption_method',
      'encryption_key' => $this->testKeys['testing_key_128']->id(),
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');

    $encryption_profile = \Drupal::service('entity_type.manager')->getStorage('encryption_profile')->load('test_encryption_profile');
    $this->assertNotEmpty($encryption_profile, 'Encryption profile was successfully saved.');
@@ -57,14 +57,14 @@ class EncryptTest extends EncryptTestBase {

    // Check if the plugin exists.
    // Encryption method option is present.
    $this->assertOption('edit-encryption-method', 'test_encryption_method');
    $this->assertSession()->optionExists('edit-encryption-method', 'test_encryption_method');
    // Encryption method text is present.
    $this->assertText('Test Encryption method');
    $this->assertSession()->pageTextContains('Test Encryption method');

    $edit = [
      'encryption_method' => 'test_encryption_method',
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');

    // Create an encryption profile.
    $edit = [
@@ -73,52 +73,52 @@ class EncryptTest extends EncryptTestBase {
      'encryption_method' => 'test_encryption_method',
      'encryption_key' => $this->testKeys['testing_key_128']->id(),
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');

    // Test the encryption profile edit form.
    $this->drupalGet('admin/config/system/encryption/profiles/manage/test_encryption_profile');
    // The warning about editing an encryption profile is visible.
    $this->assertText('Be extremely careful when editing an encryption profile! It may result in making data encrypted with this profile unreadable. Are you sure you want to edit this profile?');
    $this->assertSession()->pageTextContains('Be extremely careful when editing an encryption profile! It may result in making data encrypted with this profile unreadable. Are you sure you want to edit this profile?');
    // The encryption method field is not visible.
    $this->assertNoFieldByName('encryption_method', NULL);
    $this->assertSession()->fieldNotExists('encryption_method');
    // The encryption key field is not visible.
    $this->assertNoFieldByName('encryption_key', NULL);
    $this->assertSession()->fieldNotExists('encryption_key');

    $this->drupalPostForm(NULL, [], 'Edit');
    $this->submitForm([], 'Edit');

    // The warning about editing an encryption profile is no longer visible.
    $this->assertNoText('Be extremely careful when editing an encryption profile! It may result in making data encrypted with this profile unreadable. Are you sure you want to edit this profile?');
    $this->assertSession()->pageTextNotContains('Be extremely careful when editing an encryption profile! It may result in making data encrypted with this profile unreadable. Are you sure you want to edit this profile?');
    // The encryption method field is now visible.
    $this->assertFieldByName('encryption_method', NULL);
    $this->assertSession()->fieldExists('encryption_method');
    // The encryption key field is now visible.
    $this->assertFieldByName('encryption_key', NULL);
    $this->assertSession()->fieldExists('encryption_key');

    // Check that the 128 bit key exists so display changes don't give false
    // positives on the key deletion assertions below.
    $this->drupalGet('admin/config/system/encryption/profiles');
    $this->assertText('Key 128 bit');
    $this->assertSession()->pageTextContains('Key 128 bit');

    // Now delete the testkey.
    $this->drupalGet('admin/config/system/keys');
    $this->clickLink('Delete');
    // Warning is shown that linked dependency will also be deleted when
    // deleting the key.
    $this->assertText('Encryption Profile');
    $this->assertSession()->pageTextContains('Encryption Profile');
    // The encryption profile linked dependency is listed as the linked
    // dependency.
    $this->assertText('Test encryption profile');
    $this->drupalPostForm(NULL, [], 'Delete');
    $this->assertSession()->pageTextContains('Test encryption profile');
    $this->submitForm([], 'Delete');

    // Check that the 128 bit key no longer exists.
    $this->drupalGet('admin/config/system/encryption/profiles');
    $this->assertNoText('Key 128 bit');
    $this->assertSession()->pageTextNotContains('Key 128 bit');

    // Test "check_profile_status" setting.
    $this->config('encrypt.settings')
      ->set('check_profile_status', FALSE)
      ->save();
    $this->drupalGet('admin/config/system/encryption/profiles');
    $this->assertNoText('The key linked to this encryption profile does not exist.');
    $this->assertSession()->pageTextNotContains('The key linked to this encryption profile does not exist.');
  }

  /**
@@ -130,9 +130,9 @@ class EncryptTest extends EncryptTestBase {

    // Check if the plugin exists.
    // Config encryption method option is present.
    $this->assertOption('edit-encryption-method', 'config_test_encryption_method');
    $this->assertSession()->optionExists('edit-encryption-method', 'config_test_encryption_method');
    // Config encryption method text is present.
    $this->assertText('Config Test Encryption method');
    $this->assertSession()->pageTextContains('Config Test Encryption method');

    // Check encryption method without config.
    $edit = [
@@ -141,13 +141,13 @@ class EncryptTest extends EncryptTestBase {
      'encryption_key' => $this->testKeys['testing_key_128']->id(),
      'encryption_method' => 'test_encryption_method',
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->assertText('Saved the Test encryption profile.');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Saved the Test encryption profile.');
    $this->drupalGet('admin/config/system/encryption/profiles/manage/test_encryption_profile');
    // First, confirm we want to edit the encryption profile.
    $this->drupalPostForm(NULL, [], 'Edit');
    $this->submitForm([], 'Edit');
    // Test encryption method has no config form.
    $this->assertNoFieldByName('encryption_method_configuration[mode]', NULL);
    $this->assertSession()->fieldNotExists('encryption_method_configuration[mode]');

    // Check encryption method with config.
    $this->drupalGet('admin/config/system/encryption/profiles/add');
@@ -157,15 +157,15 @@ class EncryptTest extends EncryptTestBase {
      'encryption_key' => $this->testKeys['testing_key_128']->id(),
      'encryption_method' => 'config_test_encryption_method',
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->assertText('Saved the Test 2 encryption profile.');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Saved the Test 2 encryption profile.');
    $this->drupalGet('admin/config/system/encryption/profiles/manage/test_encryption_profile_2');
    // First, confirm we want to edit the encryption profile.
    $this->drupalPostForm(NULL, [], 'Edit');
    $this->submitForm([], 'Edit');
    // Config test encryption method has config form.
    $this->assertFieldByName('encryption_method_configuration[mode]', NULL);
    $this->assertSession()->fieldExists('encryption_method_configuration[mode]');
    // Config form shows element.
    $this->assertOptionByText('encryption_method_configuration[mode]', 'CBC');
    $this->assertSession()->optionExists('encryption_method_configuration[mode]', 'CBC');

    // Save encryption profile with configured encryption method.
    $this->drupalGet('admin/config/system/encryption/profiles/add');
@@ -175,16 +175,16 @@ class EncryptTest extends EncryptTestBase {
      'encryption_method' => 'config_test_encryption_method',
      'encryption_key' => $this->testKeys['testing_key_128']->id(),
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');

    // Check if encryption method configuration was succesfully saved.
    $this->drupalGet('admin/config/system/encryption/profiles/manage/test_config_encryption_profile');
    // First, confirm we want to edit the encryption profile.
    $this->drupalPostForm(NULL, [], 'Edit');
    $this->submitForm([], 'Edit');
    $edit = [
      'encryption_method_configuration[mode]' => 'CBC',
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');
    /** @var \Drupal\encrypt\EncryptionProfileInterface $encryption_profile */
    $encryption_profile = \Drupal::service('entity_type.manager')->getStorage('encryption_profile')->load('test_config_encryption_profile');
    $this->assertNotEmpty($encryption_profile, 'Encryption profile was successfully saved');
@@ -196,19 +196,19 @@ class EncryptTest extends EncryptTestBase {
    $this->drupalGet('admin/config/system/encryption/profiles/manage/test_config_encryption_profile');

    // First, confirm we want to edit the encryption profile.
    $this->drupalPostForm(NULL, [], 'Edit');
    $this->submitForm([], 'Edit');

    // Select encryption method without config.
    $edit = [
      'encryption_method' => 'test_encryption_method',
      'encryption_key' => $this->testKeys['testing_key_128']->id(),
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');
    $this->drupalGet('admin/config/system/encryption/profiles/manage/test_config_encryption_profile');
    // First, confirm we want to edit the encryption profile.
    $this->drupalPostForm(NULL, [], 'Edit');
    $this->submitForm([], 'Edit');
    // Test encryption method has no config form.
    $this->assertNoFieldByName('encryption_method_configuration[mode]', NULL);
    $this->assertSession()->fieldNotExists('encryption_method_configuration[mode]');
  }

}
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ abstract class EncryptTestBase extends BrowserTestBase {
   *
   * @var string[]
   */
  public static $modules = ['key', 'encrypt', 'encrypt_test'];
  protected static $modules = ['key', 'encrypt', 'encrypt_test'];

  /**
   * An administrator user.
@@ -47,7 +47,7 @@ abstract class EncryptTestBase extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  protected function setUp(): void {
    parent::setUp();

    $this->adminUser = $this->drupalCreateUser([
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class AsymmetricalEncryptionMethod extends KernelTestBase {
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  protected function setUp(): void {
    parent::setUp();

    // Create a 128bit testkey.
Loading