Exemplo n.º 1
0
 public function getCrumb()
 {
     $request = $this->jenkinsUrl . "/crumbIssuer/api/json";
     $curl = curl_init($request);
     curl_setopt($curl, CURLOPT_HEADER, 1);
     curl_setopt($curl, CURLOPT_USERPWD, "{$this->jenkinsUser}:{$this->accessToken}");
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     $resp = curl_exec($curl);
     curl_close($curl);
     $resp = new HttpResponse($resp, $request);
     $crumbData = json_decode($resp->getBody(), TRUE);
     if (!isset($crumbData['crumb']) || !isset($crumbData['crumbRequestField'])) {
         throw new JenkinsConnectionException("Unrecognized format of crumb data");
     }
     return $crumbData;
 }
Exemplo n.º 2
0
 public function testGetHeader()
 {
     $resp = new HttpResponse("HTTP/1.1 200 OK\r\nHeader1: hi!\r\nHeader2: bye!\r\n\r\n", "/");
     $this->assertEquals("hi!", $resp->getHeader("Header1"));
     $this->assertEquals("hi!", $resp->getHeader("header1"));
     $this->assertEquals("bye!", $resp->getHeader("Header2"));
     $this->assertEquals("bye!", $resp->getHeader("header2"));
     $this->assertEquals("", $resp->getHeader("Header3"));
     $this->assertEquals("", $resp->getHeader("header3"));
 }