public function testDigestHeader() { $username = '******'; $password = '******'; $nc = '00000001'; $cnonce = md5(time()); $user = md5("gwoo:app:li3"); $nonce = "4bca0fbca7bd0:{$nc}:{$cnonce}:auth"; $req = md5("GET:/http_auth"); $hash = md5("{$user}:{$nonce}:{$req}"); $data = array('realm' => 'app', 'method' => 'GET', 'uri' => '/http_auth', 'qop' => 'auth', 'nonce' => '4bca0fbca7bd0', 'opaque' => 'd3fb67a7aa4d887ec4bf83040a820a46'); $data = Auth::encode($username, $password, $data); $header = Auth::header($data); $this->assertPattern('/Digest/', $header); preg_match('/response="(.*?)"/', $header, $matches); list($match, $response) = $matches; $expected = $hash; $result = $response; $this->assertEqual($expected, $result); }