/** * {@inheritdoc} */ public function isValid(AuthorizationChallenge $authorizationChallenge) { $checkUrl = $this->extractor->getCheckUrl($authorizationChallenge); $checkContent = $this->extractor->getCheckContent($authorizationChallenge); try { return $checkContent === trim($this->client->get($checkUrl)->getBody()->getContents()); } catch (ClientException $e) { return false; } }
/** * {@inheritdoc} */ public function solve(AuthorizationChallenge $authorizationChallenge) { $checkUrl = $this->extractor->getCheckUrl($authorizationChallenge); $checkContent = $this->extractor->getCheckContent($authorizationChallenge); $this->output->writeln(sprintf(<<<'EOF' Create a text file accessible on URL %s containing the following content: %s Check in your browser that the URL %s returns the authorization token above. EOF , $checkUrl, $checkContent, $checkContent)); }
public function testGetCheckContent() { $payload = 'randomPayload'; $stubChallenge = $this->prophesize(AuthorizationChallenge::class); $extractor = new HttpDataExtractor(); $stubChallenge->getPayload()->willReturn($payload); $this->assertEquals($payload, $extractor->getCheckContent($stubChallenge->reveal())); }