diff --git a/modules/entity_share_client/config/schema/remote.schema.yml b/modules/entity_share_client/config/schema/remote.schema.yml index bd4bdb1..f397bdf 100644 --- a/modules/entity_share_client/config/schema/remote.schema.yml +++ b/modules/entity_share_client/config/schema/remote.schema.yml @@ -18,8 +18,8 @@ entity_share_client.remote.*: label: 'Plugin ID' type: string uuid: - label: 'UUID' - type: string + label: 'UUID' + type: string verified: label: 'Verified' type: boolean diff --git a/modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php b/modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php index 21edef8..d19bfce 100644 --- a/modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php +++ b/modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php @@ -174,6 +174,20 @@ abstract class EntityShareClientFunctionalTestBase extends BrowserTestBase { */ protected $entityDefinitions; + /** + * Injected plugin service. + * + * @var \Drupal\entity_share_client\Plugin\ClientAuthorizationManager + */ + protected $authPluginManager; + + /** + * Injected state service. + * + * @var \Drupal\Core\State\StateInterface + */ + protected $state; + /** * {@inheritdoc} */ @@ -195,6 +209,8 @@ abstract class EntityShareClientFunctionalTestBase extends BrowserTestBase { $this->entityDefinitions = $this->entityTypeManager->getDefinitions(); $this->importService = $this->container->get('entity_share_client.import_service'); $this->remoteManager = $this->container->get('entity_share_client.remote_manager'); + $this->authPluginManager = $this->container->get('plugin.manager.entity_share_auth'); + $this->state = $this->container->get('state'); $this->faker = Factory::create(); // Add French phone number. $this->faker->addProvider(new PhoneNumber($this->faker)); @@ -269,13 +285,24 @@ abstract class EntityShareClientFunctionalTestBase extends BrowserTestBase { */ protected function createRemote(UserInterface $user) { $remote_storage = $this->entityTypeManager->getStorage('remote'); + $plugin = $this->authPluginManager->createInstance('basic_auth'); + $configuration = $plugin->getConfiguration(); $remote = $remote_storage->create([ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), 'url' => $this->buildUrl(''), - 'basic_auth_username' => $user->getAccountName(), - 'basic_auth_password' => $user->passRaw, ]); + $credentials = []; + $credentials['username'] = $user->getAccountName(); + $credentials['password'] = $user->passRaw; + $this->state->set($configuration['uuid'], $credentials); + $key = $configuration['uuid']; + $configuration['data'] = [ + 'credential_provider' => 'entity_share', + 'storage_key' => $key, + ]; + $plugin->setConfiguration($configuration); + $remote->mergePluginConfig($plugin); $remote->save(); $this->remote = $remote; }