File: 02-canonical.t

package info (click to toggle)
libnet-openid-consumer-perl 1.13-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 312 kB
  • sloc: perl: 2,397; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 985 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
use strict;
use warnings;
no warnings 'redefine';
use Net::OpenID::Consumer;
use Test::More;

my @tests = qw(
  example.com  http://example.com/
  http://example.com  http://example.com/
  https://example.com  https://example.com/
  https://example.com/  https://example.com/
  http://example.com/user  http://example.com/user
  http://example.com/user/  http://example.com/user/
  http://example.com/  http://example.com/
);

{
    use integer;
    plan tests => (@tests / 2);
}

# stop Consumer to fetch HTML content from the URL
local *Net::OpenID::Consumer::_find_semantic_info = sub {
    my($self, $url, $final_url_ref) = @_;
    $$final_url_ref = $url;
    return { "openid.server" => "http://example.com/op" };
};
local *Net::OpenID::Yadis::discover = sub {};

while (my($url, $normalized) = splice(@tests, 0, 2)) {
    my $csr = Net::OpenID::Consumer->new;
    my $identity = $csr->claimed_identity($url);
    is $identity->claimed_url, $normalized, "$url -> $normalized";
}