File: error.t

package info (click to toggle)
liboauth-lite2-perl 0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 592 kB
  • sloc: perl: 2,658; makefile: 8
file content (107 lines) | stat: -rw-r--r-- 2,459 bytes parent folder | download | duplicates (2)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use strict;
use warnings;

use Test::More;
use OAuth::Lite2::Server::Error;

sub assert_server_error {
    my $params = shift;
    my $CLASS_NAME = "OAuth::Lite2::Server::Error::$params->{name}";
    my $error = $CLASS_NAME->new;
    ok($error);
    is($error->code, $params->{code}, "code for $CLASS_NAME");
};

my @defined_errors = (
    {
        q{name} => q{InvalidRequest},
        q{code} => 400,
        q{type} => q{invalid_request},
    },
    {
        q{name} => q{InvalidClient},
        q{code} => 401,
        q{type} => q{invalid_client},
    },
    {
        q{name} => q{UnauthorizedClient},
        q{code} => 401,
        q{type} => q{unauthorized_client},
    },
    {
        q{name} => q{RedirectURIMismatch},
        q{code} => 401,
        q{type} => q{redirect_uri_mismatch},
    },
    {
        q{name} => q{AccessDenied},
        q{code} => 401,
        q{type} => q{access_denied},
    },
    {
        q{name} => q{UnsupportedResponseType},
        q{code} => 400,
        q{type} => q{unsupported_response_type},
    },
    {
        q{name} => q{UnsupportedResourceType},
        q{code} => 400,
        q{type} => q{unsupported_resource_type},
    },
    {
        q{name} => q{InvalidGrant},
        q{code} => 401,
        q{type} => q{invalid_grant},
    },
    {
        q{name} => q{UnsupportedGrantType},
        q{code} => 400,
        q{type} => q{unsupported_grant_type},
    },
    {
        q{name} => q{InvalidScope},
        q{code} => 401,
        q{type} => q{invalid_scope},
    },
    {
        q{name} => q{InvalidToken},
        q{code} => 401,
        q{type} => q{invalid_token},
    },
    {
        q{name} => q{ExpiredTokenLegacy},
        q{code} => 401,
        q{type} => q{expired_token},
    },
    {
        q{name} => q{ExpiredToken},
        q{code} => 401,
        q{type} => q{invalid_token},
    },
    {
        q{name} => q{InsufficientScope},
        q{code} => 401,
        q{type} => q{insufficient_scope},
    },
    {
        q{name} => q{InvalidServerState},
        q{code} => 401,
        q{type} => q{invalid_server_state},
    },
    {
        q{name} => q{TemporarilyUnavailable},
        q{code} => 503,
        q{type} => q{temporarily_unavailable},
    },
    {
        q{name} => q{ServerError},
        q{code} => 500,
        q{type} => q{server_error},
    },
);

foreach my $defined_error (@defined_errors) {
    assert_server_error($defined_error);
}

done_testing();