Ejemplo n.º 1
0
 function testSend()
 {
     $client = new DemocracyInAction_Client();
     list($status, $data) = $client->send(authentication_url(), array('email' => test_user(), 'password' => test_pass()), 'post');
     $this->assertWantedPattern('/Successful Login/', $data);
     $url = 'https://' . test_node() . '/api/getObjects.sjs';
     list($status, $data) = $client->send($url, array('object' => 'supporter', 'limit' => 1));
     $this->assertWantedPattern('/organization_KEY="1"/', $data);
 }
Ejemplo n.º 2
0
 function testValidCredentials()
 {
     list($status, $data) = post(authentication_url(), array('email' => test_user(), 'password' => test_pass()));
     #has an interesting status code
     $this->assertEqual($status, 200);
     #has interesting success message
     $this->assertWantedPattern('/Successful Login/', $data);
     #looks like we expect
     $expected = file_get_contents(dirname(__FILE__) . '/../fixtures/auth/valid.xml');
     $this->assertEqual($data, $expected);
 }
Ejemplo n.º 3
0
function authenticated_curl_handle()
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
    $temp_file = tempnam(sys_get_temp_dir(), 'DIA');
    curl_setopt($ch, CURLOPT_COOKIEFILE, $temp_file);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $temp_file);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, authentication_url());
    curl_setopt($ch, CURLOPT_POSTFIELDS, "email=" . test_user() . "&password=" . test_pass());
    $data = curl_exec($ch);
    return $ch;
}