aboutsummaryrefslogtreecommitdiff
path: root/t/tests/Net/Hawk/Client.t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2014-12-20 15:22:39 +0000
committerdakkar <dakkar@thenautilus.net>2014-12-20 15:22:39 +0000
commitfcbd04d14f7e1c54118984eb6cb09bce9b0102f0 (patch)
treea2191dea055cb08b0f22e7bd481c80bced2c5451 /t/tests/Net/Hawk/Client.t
parentfirst tests passing (diff)
downloadnet-hawk-fcbd04d14f7e1c54118984eb6cb09bce9b0102f0.tar.gz
net-hawk-fcbd04d14f7e1c54118984eb6cb09bce9b0102f0.tar.bz2
net-hawk-fcbd04d14f7e1c54118984eb6cb09bce9b0102f0.zip
first client tests passing
Diffstat (limited to 't/tests/Net/Hawk/Client.t')
-rw-r--r--t/tests/Net/Hawk/Client.t52
1 files changed, 52 insertions, 0 deletions
diff --git a/t/tests/Net/Hawk/Client.t b/t/tests/Net/Hawk/Client.t
new file mode 100644
index 0000000..77f63a0
--- /dev/null
+++ b/t/tests/Net/Hawk/Client.t
@@ -0,0 +1,52 @@
+#!perl
+use strict;
+use warnings;
+use Test::More;
+use Net::Hawk::Client;
+
+my $c = Net::Hawk::Client->new();
+
+my %credentials = (
+ id => 'dh37fgj492je',
+ key => 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
+ algorithm => 'sha256',
+);
+my %options = (
+ credentials => \%credentials,
+ timestamp => 1353832234,
+ nonce => 'j4h3g2',
+ ext => 'some-app-ext-data'
+);
+
+subtest GET => sub {
+ my $field = $c->header(
+ 'http://example.com:8000/resource/1?b=1&a=2',
+ 'GET',
+ \%options,
+ )->{field};
+
+ is(
+ $field,
+ 'Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", ext="some-app-ext-data", mac="6R4rV5iE+NPoym+WwjeHzjAGXUtLNIxmo1vpMofpLAE="',
+ 'Hawk header generated ok',
+ );
+};
+
+subtest POST => sub {
+ $options{payload} = 'Thank you for flying Hawk';
+ $options{content_type} = 'text/plain';
+
+ my $field = $c->header(
+ 'http://example.com:8000/resource/1?b=1&a=2',
+ 'POST',
+ \%options,
+ )->{field};
+
+ is(
+ $field,
+ 'Hawk id="dh37fgj492je", ts="1353832234", nonce="j4h3g2", hash="Yi9LfIIFRtBEPt74PVmbTF/xVAwPn7ub15ePICfgnuY=", ext="some-app-ext-data", mac="aSe1DERmZuRl3pI36/9BdZmnErTw3sNzOOAUlfeKjVw="',
+ 'Hawk header generated ok',
+ );
+};
+
+done_testing();