aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2014-12-20 15:27:51 +0000
committerdakkar <dakkar@thenautilus.net>2014-12-20 15:27:51 +0000
commitd40015505a6b61001d8e175b6d099ab32a9d3ed1 (patch)
tree85ff5f2c690ac1086274d763cf34d51b695807c3
parentfirst client tests passing (diff)
downloadnet-hawk-d40015505a6b61001d8e175b6d099ab32a9d3ed1.tar.gz
net-hawk-d40015505a6b61001d8e175b6d099ab32a9d3ed1.tar.bz2
net-hawk-d40015505a6b61001d8e175b6d099ab32a9d3ed1.zip
more crypto tests
-rw-r--r--t/tests/Net/Hawk/Crypto.t48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/tests/Net/Hawk/Crypto.t b/t/tests/Net/Hawk/Crypto.t
index eb1a52f..58e263f 100644
--- a/t/tests/Net/Hawk/Crypto.t
+++ b/t/tests/Net/Hawk/Crypto.t
@@ -70,4 +70,52 @@ subtest POST => sub {
);
};
+subtest normalized_string => sub {
+ my %args = (
+ credentials => {
+ key => 'dasdfasdf',
+ algorithm => 'sha256',
+ },
+ ts => 1357747017,
+ nonce => 'k3k4j5',
+ method => 'GET',
+ resource => '/resource/something',
+ host => 'example.com',
+ port =>8080
+ );
+ my $string = $c->generate_normalized_string(
+ header => \%args,
+ );
+ is(
+ $string,
+ "hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\n\n",
+ 'valid normalized string',
+ );
+
+ $string = $c->generate_normalized_string(
+ header => {
+ %args,
+ ext => 'this is some app data',
+ },
+ );
+ is(
+ $string,
+ "hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\nthis is some app data\n",
+ 'valid normalized string (ext)',
+ );
+
+ $string = $c->generate_normalized_string(
+ header => {
+ %args,
+ ext => 'this is some app data',
+ hash => 'U4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=',
+ },
+ );
+ is(
+ $string,
+ "hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\nU4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=\nthis is some app data\n",
+ 'valid normalized string (payload + ext)',
+ );
+};
+
done_testing;