File: 99-rt80329.t

package info (click to toggle)
libnet-openid-consumer-perl 1.18-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 340 kB
  • sloc: perl: 2,449; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,486 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl

use warnings;
use strict;
use utf8;
use Test::More tests => 1;

use Digest::SHA qw(hmac_sha1_hex);
use Net::OpenID::Consumer;


sub fake_discover_acceptable_endpoints {
    return [{
            uri => 'http://example.com/openid',
            version => 2,
            final_url => 'http://example.com/openid?j.doe',
            sem_info => {},
            mechanism => "HTML",
        }];
}

{
    no warnings 'redefine';
    *Net::OpenID::Consumer::_discover_acceptable_endpoints = \&fake_discover_acceptable_endpoints
}

my $c = Net::OpenID::Consumer->new(
        ua => Fake::UA->new,
        consumer_secret => 'abc',
        args => {
            'oic.time'          => time . '-' . substr(hmac_sha1_hex(time, 'abc'), 0, 20),
            'openid.mode'       => 'id_res',
            'openid.identity'   => 'http://example.com/openid?j.doe',
            'openid.sig'        => 'fake',
            'openid.return_to'  => 'http://example.com/openid',
            'openid.claimed_id' => 'http://example.com/openid?j.doe',
            'openid.something'  => "\x{442}\x{435}\x{441}\x{442}", # this breaks @ uri_escape
            'openid.signed'     => 'mode,identity,return_to,signed,claimed_id,something',
            'openid.assoc_handle' => 'a_handle',
        }
    );

ok(eval { $c->verified_identity() });




package Fake::UA;

sub new {
    return bless {}, "Fake::UA";
}

sub request {
    HTTP::Response->new(200, 'OK', [], "is_valid:true\nlifetime:123");
}