-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathtest_7_custom_ini_scan_dir.php
More file actions
49 lines (35 loc) · 1.34 KB
/
test_7_custom_ini_scan_dir.php
File metadata and controls
49 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php declare(strict_types=1);
require_once __DIR__ . '/utils.php';
function post(string $url, string $params)
{
$ch = curl_init();
$jsonData = json_encode($params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'Content-Length: ' . strlen($jsonData)]);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($ch);
curl_close($ch);
if ($response === false) {
throw new Exception('Curl error: ' . curl_error($ch));
}
return $response;
}
$body = 'list_extensions';
waitForPort('127.0.0.1', 8080);
try {
$response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body);
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
} catch (Throwable $e) {
error($e->getMessage() . PHP_EOL . $e->getTraceAsString());
}
if (! is_array($response)) {
error('The response is not an array');
}
// We changed PHP_INI_SCAN_DIR to `/var/task` to load `test_3_manual_extensions.ini`
// We check one of the extensions was indeed loaded
if (! in_array('intl', $response, true)) {
error('Could not override PHP_INI_SCAN_DIR, test_3_manual_extensions.ini was not loaded');
}
success('[Invoke] Function');