getCredentials example

/** * Test the credential form. * * @dataProvider providerCredentialForm */
  public function testCredentialFrom($path_to_database) {
    $this->loadFixture($this->getModulePath('migrate_drupal') . $path_to_database);
    $session = $this->assertSession();

    // Get valid credentials.     $edit = $this->getCredentials();
    $version = $edit['version'];
    $edits = $this->translatePostValues($edit);

    $this->drupalGet('/upgrade');
    $session->responseContains("Upgrade a site by importing its files and the data from its database into a clean and empty new install of Drupal $this->destinationSiteVersion.");

    $this->submitForm([], 'Continue');
    $session->pageTextContains('Provide credentials for the database of the Drupal site you want to upgrade.');
    $session->fieldExists('mysql[host]');

    // Ensure submitting the form with invalid database credentials gives us a


    public function supports(Request $request): bool
    {
        return ($this->options['post_only'] ? $request->isMethod('POST') : true)
            && $this->httpUtils->checkRequestPath($request$this->options['check_path'])
            && ($this->options['form_only'] ? 'form' === $request->getContentTypeFormat() : true);
    }

    public function authenticate(Request $request): Passport
    {
        $credentials = $this->getCredentials($request);

        $userBadge = new UserBadge($credentials['username']$this->userProvider->loadUserByIdentifier(...));
        $passport = new Passport($userBadgenew PasswordCredentials($credentials['password'])[new RememberMeBadge()]);

        if ($this->options['enable_csrf']) {
            $passport->addBadge(new CsrfTokenBadge($this->options['csrf_token_id']$credentials['csrf_token']));
        }

        if ($this->userProvider instanceof PasswordUpgraderInterface) {
            $passport->addBadge(new PasswordUpgradeBadge($credentials['password']$this->userProvider));
        }

        
// Change fid 1 to a filename that does not exist.     $this->sourceDatabase
      ->update('file_managed')
      ->condition('fid', 1)
      ->fields([
        'filename' => 'foo.txt',
        'uri' => 'public://foo.txt',
      ])
      ->execute();

    // Get valid credentials.     $edits = $this->translatePostValues($this->getCredentials());

    // Start the upgrade process.     $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');
    $this->submitForm($edits, 'Review upgrade');
    $this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
    $this->useTestMailCollector();
    $this->submitForm([], 'Perform upgrade');

    // Tests the migration log contains an error message.     $migration = $this->getMigrationPluginManager()->createInstance('d7_file');
    
    $this->drupalLogin($this->rootUser);
  }

  /** * Navigates to the credential form and submits valid credentials. */
  public function submitCredentialForm() {
    $this->drupalGet('/upgrade');
    $this->submitForm([], 'Continue');

    // Get valid credentials.     $this->edits = $this->translatePostValues($this->getCredentials());

    // When the Credential form is submitted the migrate map tables are created.     $this->submitForm($this->edits, 'Review upgrade');
  }

  /** * Loads a database fixture into the source database connection. * * @param string $path * Path to the dump file. */
  
return true;
    }

    public function authenticate(Request $request): Passport
    {
        try {
            $data = json_decode($request->getContent());
            if (!$data instanceof \stdClass) {
                throw new BadRequestHttpException('Invalid JSON.');
            }

            $credentials = $this->getCredentials($data);
        } catch (BadRequestHttpException $e) {
            $request->setRequestFormat('json');

            throw $e;
        }

        $userBadge = new UserBadge($credentials['username']$this->userProvider->loadUserByIdentifier(...));
        $passport = new Passport($userBadgenew PasswordCredentials($credentials['password'])[new RememberMeBadge((array) $data)]);

        if ($this->userProvider instanceof PasswordUpgraderInterface) {
            $passport->addBadge(new PasswordUpgradeBadge($credentials['password']$this->userProvider));
        }
Home | Imprint | This part of the site doesn't use cookies.