Skip to content

Commit

Permalink
Adds inspect method to Macaroon
Browse files Browse the repository at this point in the history
  • Loading branch information
cmckni3 committed Apr 29, 2015
1 parent c3fa32e commit a7f2e7a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
28 changes: 28 additions & 0 deletions lib/Macaroons/Macaroon.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ public function bindSignature($signature)
return Utils::hmac($key, $currentSignatureHash . $newSignatureHash);
}

public function inspect()
{
$str = "location {$this->location}\n";
$str .= "identifier {$this->identifier}\n";
foreach ($this->caveats as $caveat)
{
$caveatKeys = array(
'cid' => $caveat->getCaveatId()
);
if ($caveat->getVerificationId() && $caveat->getCaveatLocation())
{
$caveatKeys = array_merge(
$caveatKeys,
array(
'vid' => $caveat->getVerificationId(),
'cl' => $caveat->getCaveatLocation()
)
);
}
$caveatKeys = array_map(function($key, $value){
return "$key $value";
}, array_keys($caveatKeys), $caveatKeys);
$str .= join("\n", $caveatKeys) . "\n";
}
$str .= "signature {$this->getSignature()}";
return $str;
}

private function initialSignature($key, $identifier)
{
return Utils::hmac( Utils::generateDerivedKey($key), $identifier);
Expand Down
6 changes: 0 additions & 6 deletions tests/PacketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,4 @@ public function testPacketDecoding()
$this->assertEquals('a', $packet->getKey());
$this->assertEquals('b', $packet->getData());
}

public function testDerserialize()
{
// $m = Macaroon::deserialize(Utils::base64_url_encode("0007a \n0008a b\n"));
$this->markTestSkipped('TODO');
}
}

0 comments on commit a7f2e7a

Please sign in to comment.