/** * Sets the array of allowed hosts. * * @codeCoverageIgnore * * @param array $value string-array of allowed hosts, i.e. IP addresses. */ static function set_allowed_host($value) { self::$allowed_host = $value; }
/** * Test a valid proxy post request to a restful service. */ function testDoRequest_PostRequest() { // set proxy configuration Proxy_Controller::set_allowed_host(array('localhost', 'qa.silverstripe.com')); // generate request $url = Director::absoluteBaseURL() . 'ReflectionProxy_Controller'; $u = $url . '/doprocess?param=proxyTest_Post'; $response = $this->post('Proxy/dorequest?', array('u' => $u, 'no_header' => '1')); // convert response into array $obj = json_decode($response->getBody(), 1); // get project-path from the absolute URL $baseUrl = array_slice(explode('/', Director::absoluteBaseURL()), 3); $projectPath = implode("/", $baseUrl); // verify/assert response $this->assertEquals($obj['url'], "/" . $projectPath . "ReflectionProxy_Controller/doprocess"); $this->assertEquals($obj['param'], "proxyTest_Post"); $this->assertEquals($obj['isget'], false); }