Пример #1
0
 public function testCleanup()
 {
     $checkUrl = 'http://foo.bar/.challenge';
     $checkContent = 'randomPayload';
     $mockExtractor = $this->prophesize(HttpDataExtractor::class);
     $mockOutput = $this->prophesize(OutputInterface::class);
     $stubChallenge = $this->prophesize(AuthorizationChallenge::class);
     $solver = new SimpleHttpSolver($mockExtractor->reveal(), $mockOutput->reveal());
     $mockExtractor->getCheckUrl($stubChallenge->reveal())->willReturn($checkUrl);
     $mockExtractor->getCheckContent($stubChallenge->reveal())->willReturn($checkContent);
     $mockOutput->writeln(Argument::any())->shouldBeCalled();
     $solver->cleanup($stubChallenge->reveal());
 }
Пример #2
0
 public function testFullProcess()
 {
     /*
      * Register account
      */
     $data = $this->client->registerAccount('http://boulder:4000/terms/v1');
     $this->assertInternalType('array', $data);
     $this->assertArrayHasKey('id', $data);
     $this->assertArrayHasKey('key', $data);
     $this->assertArrayHasKey('initialIp', $data);
     $this->assertArrayHasKey('createdAt', $data);
     $solver = new SimpleHttpSolver();
     /*
      * Ask for domain challenge
      */
     $challenges = $this->client->requestAuthorization('acmephp.com');
     foreach ($challenges as $challenge) {
         if ('http-01' === $challenge->getType()) {
             break;
         }
     }
     $this->assertInstanceOf(AuthorizationChallenge::class, $challenge);
     $this->assertEquals('acmephp.com', $challenge->getDomain());
     $this->assertContains('http://127.0.0.1:4000/acme/challenge', $challenge->getUrl());
     $solver->solve($challenge);
     /*
      * Challenge check
      */
     $process = $this->createServerProcess($challenge);
     $process->start();
     $this->assertTrue($process->isRunning());
     try {
         $check = $this->client->challengeAuthorization($challenge);
         $this->assertEquals('valid', $check['status']);
     } finally {
         $process->stop();
     }
     /*
      * Request certificate
      */
     $csr = new CertificateRequest(new DistinguishedName('acmephp.com'), (new KeyPairGenerator())->generateKeyPair());
     $response = $this->client->requestCertificate('acmephp.com', $csr);
     $this->assertInstanceOf(CertificateResponse::class, $response);
     $this->assertEquals($csr, $response->getCertificateRequest());
     $this->assertInstanceOf(Certificate::class, $response->getCertificate());
     $this->assertInstanceOf(Certificate::class, $response->getCertificate()->getIssuerCertificate());
 }