File: secure-random.t

package info (click to toggle)
libnginx-mod-http-set-misc 0.33-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 408 kB
  • sloc: ansic: 2,205; sh: 106; makefile: 3
file content (107 lines) | stat: -rw-r--r-- 1,774 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
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
# vi:filetype=

use Test::Nginx::Socket;

repeat_each(2);

plan tests => repeat_each() * 2 * blocks();

no_long_string();

run_tests();

#no_diff();

__DATA__

=== TEST 1: a 32-character alphanum
--- config
    location /alphanum {
        set_secure_random_alphanum $res 32;

        echo $res;
    }
--- request
    GET /alphanum
--- response_body_like: ^[a-zA-Z0-9]{32}$



=== TEST 2: a 16-character alphanum
--- config
    location /alphanum {
        set_secure_random_alphanum $res 16;

        echo $res;
    }
--- request
    GET /alphanum
--- response_body_like: ^[a-zA-Z0-9]{16}$



=== TEST 3: a 1-character alphanum
--- config
    location /alphanum {
        set_secure_random_alphanum $res 1;

        echo $res;
    }
--- request
    GET /alphanum
--- response_body_like: ^[a-zA-Z0-9]{1}$



=== TEST 4: length less than <= 0 should fail
--- config
    location /alphanum {
        set_secure_random_alphanum $res 0;

        echo $res;
    }
--- request
    GET /alphanum
--- response_body_like: 500 Internal Server Error
--- error_code: 500



=== TEST 5: length less than <= 0 should fail
--- config
    location /alphanum {
        set_secure_random_alphanum $res -4;

        echo $res;
    }
--- request
    GET /alphanum
--- response_body_like: 500 Internal Server Error
--- error_code: 500



=== TEST 6: non-numeric length should fail
--- config
    location /alphanum {
        set_secure_random_alphanum $res bob;

        echo $res;
    }
--- request
    GET /alphanum
--- response_body_like: 500 Internal Server Error
--- error_code: 500



=== TEST 7: a 16-character lcalpha
--- config
    location /lcalpha {
        set_secure_random_lcalpha $res 16;

        echo $res;
    }
--- request
    GET /lcalpha
--- response_body_like: ^[a-z]{16}$