Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 175 lines (132 sloc) 2.708 kb
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
# vi:filetype=

use Test::Nginx::Socket;

repeat_each(3);

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

no_long_string();

run_tests();

#no_diff();

__DATA__

=== TEST 1: base32 (5 bytes)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a 'abcde';
        set_encode_base32 $a;
        set $b $a;
        set_decode_base32 $b;

        echo $a;
        echo $b;
    }
--- request
    GET /bar
--- response_body
c5h66p35
abcde



=== TEST 2: base32 (1 byte)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '!';
        set_encode_base32 $a;
        set $b $a;
        set_decode_base32 $b;

        echo $a;
        echo $b;
    }
--- request
    GET /bar
--- response_body
44
!



=== TEST 3: base32 (1 byte) - not in-place editing
--- config
    location /bar {
        set_misc_base32_padding off;
        set $a '!';
        set_encode_base32 $a $a;
        set_decode_base32 $b $a;

        echo $a;
        echo $b;
    }
--- request
    GET /bar
--- response_body
44
!



=== TEST 4: base32 (hello world)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '"hello, world!\nhiya"';
        set_encode_base32 $a;
        set $b $a;
        set_decode_base32 $b;

        echo $a;
        echo $b;
    }
--- request
    GET /bar
--- response_body
49k6ar3cdsm20trfe9m6888ad1knio92
"hello, world!
hiya"



=== TEST 5: base32 (0 bytes left)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '"hello, world!"';
        set_encode_base32 $a;

        echo $a;
    }
--- request
    GET /bar
--- response_body
49k6ar3cdsm20trfe9m68892



=== TEST 6: base32 (6 bytes padded)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '"hello, world!"a';
        set_encode_base32 $a;

        echo $a;
    }
--- request
    GET /bar
--- response_body
49k6ar3cdsm20trfe9m68892c4



=== TEST 7: base32 (4 bytes left)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '"hello, world!"ab';
        set_encode_base32 $a;

        echo $a;
    }
--- request
    GET /bar
--- response_body
49k6ar3cdsm20trfe9m68892c5h0



=== TEST 8: base32 (3 bytes left)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '"hello, world!"abc';
        set_encode_base32 $a;

        echo $a;
    }
--- request
    GET /bar
--- response_body
49k6ar3cdsm20trfe9m68892c5h66



=== TEST 9: base32 (1 bytes left)
--- config
    set_misc_base32_padding off;
    location /bar {
        set $a '"hello, world!"abcd';
        set_encode_base32 $a;

        echo $a;
    }
--- request
    GET /bar
--- response_body
49k6ar3cdsm20trfe9m68892c5h66p0

Something went wrong with that request. Please try again.