1
|
|
|
<?php |
2
|
|
|
namespace LE_ACME2Tests\Response\Order; |
3
|
|
|
|
4
|
|
|
use LE_ACME2; |
5
|
|
|
use LE_ACME2Tests\Connector; |
6
|
|
|
use LE_ACME2Tests\EnhancedTestCase; |
7
|
|
|
|
8
|
|
|
class GetTest extends EnhancedTestCase { |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \LE_ACME2\Exception\OrderStatusInvalid |
12
|
|
|
* @covers \LE_ACME2\Response\AbstractResponse::_isValid |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
public function testGetChallengeError() { |
16
|
|
|
|
17
|
|
|
$rawResponse = Connector\RawResponse::createDummyFrom( |
18
|
|
|
Connector\RawResponse::HEADER_200, |
19
|
|
|
file_get_contents(dirname(__FILE__, 2) . DIRECTORY_SEPARATOR . '_JSONSamples' . DIRECTORY_SEPARATOR . 'OrderStatusInvalid.json') |
20
|
|
|
); |
21
|
|
|
|
22
|
|
|
$this->catchExpectedException( |
23
|
|
|
LE_ACME2\Exception\OrderStatusInvalid::class, |
24
|
|
|
function() use($rawResponse) { |
25
|
|
|
new LE_ACME2\Response\Order\Get($rawResponse, 'http://dummy.org'); |
26
|
|
|
} |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
try { |
30
|
|
|
new LE_ACME2\Response\Order\Get($rawResponse, 'http://dummy.org'); |
31
|
|
|
|
32
|
|
|
throw new \RuntimeException('Exception not thrown'); |
33
|
|
|
|
34
|
|
|
} catch (LE_ACME2\Exception\OrderStatusInvalid $e) { |
35
|
|
|
$this->assertNull($e->response->getError()); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testOrderInvalid() { |
40
|
|
|
|
41
|
|
|
$rawResponse = Connector\RawResponse::createDummyFrom( |
42
|
|
|
Connector\RawResponse::HEADER_200, |
43
|
|
|
file_get_contents(dirname(__FILE__, 2) . DIRECTORY_SEPARATOR . '_JSONSamples' . DIRECTORY_SEPARATOR . 'OrderStatusInvalidHavingError.json') |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
try { |
47
|
|
|
new LE_ACME2\Response\Order\Get($rawResponse, 'http://dummy.org'); |
48
|
|
|
|
49
|
|
|
throw new \RuntimeException('Exception not thrown'); |
50
|
|
|
|
51
|
|
|
} catch (LE_ACME2\Exception\OrderStatusInvalid $e) { |
52
|
|
|
|
53
|
|
|
$error = $e->response->getError(); |
54
|
|
|
|
55
|
|
|
$this->assertNotNull($error); |
56
|
|
|
|
57
|
|
|
$this->assertTrue($e->response->getError()->hasStatusServerError()); |
58
|
|
|
|
59
|
|
|
$this->assertEquals(500, $e->response->getError()->status); |
60
|
|
|
$this->assertEquals('urn:ietf:params:acme:error:serverInternal', $e->response->getError()->type); |
61
|
|
|
$this->assertEquals('Error finalizing order :: Unable to meet CA SCT embedding requirements', $e->response->getError()->detail); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |