Example #1
0
 /**
  * Test to see same usernames with different passwords can authenticate when
  * a flag is set
  * 
  * @group   ZF-7289
  */
 public function testEqualUsernamesDifferentPasswordShouldAuthenticateWhenFlagIsSet()
 {
     $this->_db->insert('users', array (
         'username' => 'my_username',
         'password' => 'my_otherpass',
         'real_name' => 'Test user 2',
     ));
     
     // test if user 1 can authenticate
     $this->_adapter->setIdentity('my_username')
                    ->setCredential('my_password')
                    ->setAmbiguityIdentity(true);
     $result = $this->_adapter->authenticate();
     $this->assertFalse(in_array('More than one record matches the supplied identity.',
         $result->getMessages()));
     $this->assertTrue($result->isValid());
     $this->assertEquals('my_username', $result->getIdentity());
     
     $this->_adapter = null;
     $this->_setupAuthAdapter();
     
     // test if user 2 can authenticate
     $this->_adapter->setIdentity('my_username')
                    ->setCredential('my_otherpass')
                    ->setAmbiguityIdentity(true);
     $result2 = $this->_adapter->authenticate();
     $this->assertFalse(in_array('More than one record matches the supplied identity.',
         $result->getMessages()));
     $this->assertTrue($result->isValid());
     $this->assertEquals('my_username', $result->getIdentity());
 }
Example #2
0
 /**
  * Inserts a table row with specified data.
  *
  * @param mixed $table The table to insert data into.
  * @param array $bind Column-value pairs.
  * @return int The number of affected rows.
  */
 public function insert($table = null, array $bind = null)
 {
     if (is_null($table) && is_null($bind)) {
         return new Harmoni_Db_Insert($this);
     } else {
         return parent::insert($table, $bind);
     }
 }
Example #3
0
 /**
  * Log response information
  *
  * @param Spizer_Response $response
  */
 public function logResponse(Spizer_Response $response)
 {
     $this->_db->insert('responses', array('microtime' => microtime(true), 'request_id' => $this->_currentReqId, 'statuscode' => $response->getStatus(), 'message' => $response->getMessage()));
     $stmt = $this->_db->prepare("INSERT INTO response_headers (request_id, header, value) VALUES ({$this->_currentReqId}, ?, ?)");
     foreach ($response->getAllHeaders() as $k => $v) {
         $stmt->execute(array($k, $v));
     }
 }