File: 13-hmac-sha256.t

package info (click to toggle)
libnet-oauth-perl 0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 308 kB
  • sloc: perl: 1,484; makefile: 8
file content (35 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!perl

use strict;
use warnings;
use Test::More tests => 3;

use Net::OAuth::ProtectedResourceRequest;

SKIP: {

    skip "Digest::SHA not installed", 3 unless eval 'require Digest::SHA; 1';

    my $request = Net::OAuth::ProtectedResourceRequest->new(
            consumer_key => 'dpf43f3p2l4k3l03',
            consumer_secret => 'kd94hf93k423kf44',
            request_url => 'http://photos.example.net/photos',
            request_method => 'GET',
            signature_method => 'HMAC-SHA256',
            timestamp => '1191242096',
            nonce => 'kllo9940pd9333jh',
            token => 'nnch734d00sl2jdk',
            token_secret => 'pfkkdhi9sl3r4s00',
            extra_params => {
                file => 'vacation.jpg',
                size => 'original',
            },
    );

    $request->sign;

    is(length($request->signature), 44);
    is($request->signature, "WVPzl1j6ZsnkIjWr7e3OZ3jkenL57KwaLFhYsroX1hg=");
    ok($request->verify());

}