Пример #1
0
 /**
  * @covers \Cougar\RestService\RestService::negotiateResponseType
  */
 public function testNegotiateResponseType()
 {
     $this->assertEquals(array("application/json"), $this->object->negotiateResponseType(array("application/json")));
     $this->assertEquals(array("application/json", "application/xml"), $this->object->negotiateResponseType(array("application/xml", "application/json")));
     $this->assertEquals(array("application/json;version=2"), $this->object->negotiateResponseType(array("application/json;version=2")));
     # Set up a new header
     # TODO: Add more test cases
 }
 /**
  * @covers \Cougar\Security\HttpBasicAuthenticationProvider::__construct
  * @covers \Cougar\Security\HttpBasicAuthenticationProvider::authenticate
  * @expectedException \Cougar\Exceptions\Exception
  */
 public function testAuthenticateBadReplyFromValidator()
 {
     $auth_header = array("raw_header" => "Basic " . base64_encode("Aladdin:bad password"), "scheme" => "Basic", "parameter" => base64_encode("Aladdin:bad password"), "username" => "Aladdin", "password" => "bad password");
     $bad_reply = array("id" => "Aladdin");
     $this->restService->expects($this->once())->method("authorizationHeader")->with()->will($this->returnValue($auth_header));
     $this->basicCredentialValidator->expects($this->once())->method("validate")->with("Aladdin", "bad password")->will($this->returnValue($bad_reply));
     $this->object->authenticate();
 }
Пример #3
0
 /**
  * Stores the Security object and initializes the REST request
  *
  * @history
  * 2013.09.30:
  *   (AT)  Initial release
  *
  * @version 2013.09.30
  * @author (AT) Alberto Trevino, Brigham Young Univ. <*****@*****.**>
  * 
  * @todo Make sure the code works in CGI and Windows environments
  * 
  * @param iSecurity $security Reference to Security context
  */
 public function __construct(iSecurity $security)
 {
     # Call the parent constructor
     parent::__construct();
     # Store the security object
     $this->security = $security;
     # Create a new local cache
     $this->localCache = CacheFactory::getLocalCache();
 }
Пример #4
0
 /**
  * @covers \Cougar\RestService\RestService::rawRequest
  */
 public function testRawRequest()
 {
     $raw_request = $this->object->rawRequest();
     $this->assertNotEmpty($raw_request);
 }