View | Details | Raw Unified | Return to bug 57300
Collapse All | Expand All

(-)t/modules/session.t (-17 / +53 lines)
Lines 13-30 Link Here
13
my $checks_per_test = 5;
13
my $checks_per_test = 5;
14
14
15
# Session, API, Encoding, SessionEnv, SessionHeader, SessionMaxAge,
15
# Session, API, Encoding, SessionEnv, SessionHeader, SessionMaxAge,
16
# SessionInclude/Exclude.
16
# SessionExpiryUpdateInterval, SessionInclude/Exclude.
17
my $num_tests = 2 + 4 + 5 + 2 + 1 + 4 + 3;
17
my $num_tests = 2 + 4 + 5 + 2 + 1 + 4 + 7 + 3;
18
18
19
my @todo = [
19
my @todo = (
20
    # Session writable after decode failure - PR 58171
20
    # Session writable after decode failure - PR 58171
21
    53, 54,
21
    53, 54,
22
    # Session writable after expired - PR 56052
22
    # Session writable after expired - PR 56052
23
    88, 89
23
    88, 89
24
];
24
);
25
25
26
# Until the fix for PR 57300 is backported, sessions are always saved.
27
if (!have_min_apache_version('2.5')) {
28
    my @todo_backport = ( 8, 18, 38, 43, 48, 58, 63, 133 );
29
    push(@todo, @todo_backport);
30
}
31
26
plan tests => $num_tests * $checks_per_test,
32
plan tests => $num_tests * $checks_per_test,
27
              todo => @todo,
33
              todo => \@todo,
28
              need need_module('session'),
34
              need need_module('session'),
29
              need_min_apache_version('2.3.0');
35
              need_min_apache_version('2.3.0');
30
36
Lines 107-119 Link Here
107
my $read_session = 'action=get&name=test';
113
my $read_session = 'action=get&name=test';
108
114
109
# Session directive
115
# Session directive
110
check_get 'Session Off', '/';
116
check_post 'Cannot write session when off', '/', $create_session;
111
check_get 'Session On', '/on', '';
117
check_get 'New empty session is not saved', '/on';
112
118
113
# API optional functions
119
# API optional functions
114
check_post 'Set session', '/on', $create_session, $session, 1;
120
check_post 'Set session', '/on', $create_session, $session, 1;
115
check_post 'Get session', "/on?$session", $read_session,
121
check_post 'Get session', "/on?$session", $read_session,
116
    $session, 0, 0, 'value';
122
    undef, 0, 0, 'value';
117
check_post 'Delete session', "/on?$session", 'action=set&name=test', '', 1;
123
check_post 'Delete session', "/on?$session", 'action=set&name=test', '', 1;
118
check_post 'Edit session', "/on?$session", 'action=set&name=test&value=',
124
check_post 'Edit session', "/on?$session", 'action=set&name=test&value=',
119
    'test=', 1;
125
    'test=', 1;
Lines 122-139 Link Here
122
check_post 'Encode session', '/on/encode', $create_session,
128
check_post 'Encode session', '/on/encode', $create_session,
123
    $encoded_session, 1;
129
    $encoded_session, 1;
124
check_post 'Decode session', "/on/encode?$encoded_session", $read_session,
130
check_post 'Decode session', "/on/encode?$encoded_session", $read_session,
125
    $encoded_session, 0, 0, 'value';
131
    undef, 0, 0, 'value';
126
check_get 'Custom decoder failure', "/on/encode?$session", $encoded_prefix;
132
check_get 'Custom decoder failure', "/on/encode?$session";
127
check_get 'Identity decoder failure', "/on?&=test", '';
133
check_get 'Identity decoder failure', "/on?&=test";
128
check_post 'Session writable after decode failure', "/on/encode?$session",
134
check_post 'Session writable after decode failure', "/on/encode?$session",
129
    $create_session, $encoded_session, 1;
135
    $create_session, $encoded_session, 1;
130
136
131
# SessionEnv directive - requires mod_include
137
# SessionEnv directive - requires mod_include
132
if (have_module('include')) {
138
if (have_module('include')) {
133
    check_custom 'SessionEnv Off', GET("/modules/session/env.shtml?$session"),
139
    check_custom 'SessionEnv Off', GET("/modules/session/env.shtml?$session"),
134
        $session, 0, 0, '(none)';
140
        undef, 0, 0, '(none)';
135
    check_get 'SessionEnv On', "/on/env/on/env.shtml?$session",
141
    check_get 'SessionEnv On', "/on/env/on/env.shtml?$session",
136
        $session, 0, 0, $session;
142
        undef, 0, 0, $session;
137
}
143
}
138
else {
144
else {
139
    for (1 .. 2 * $checks_per_test) {
145
    for (1 .. 2 * $checks_per_test) {
Lines 147-153 Link Here
147
    "$session&another=5&last=7", 1;
153
    "$session&another=5&last=7", 1;
148
154
149
# SessionMaxAge directive
155
# SessionMaxAge directive
150
my $future_expiry = (time() + 100) * APR_TIME_PER_SEC;
156
my $future_expiry = (time() + 200) * APR_TIME_PER_SEC;
151
157
152
check_get 'SessionMaxAge adds expiry', "/on/expire?$session", $session, 0, 1;
158
check_get 'SessionMaxAge adds expiry', "/on/expire?$session", $session, 0, 1;
153
check_get 'Discard expired session', "/on/expire?$session&expiry=1", '', 0, 1;
159
check_get 'Discard expired session', "/on/expire?$session&expiry=1", '', 0, 1;
Lines 156-162 Link Here
156
check_post 'Session writable after expired', '/on/expire?expiry=1',
162
check_post 'Session writable after expired', '/on/expire?expiry=1',
157
    $create_session, $session, 1, 1;
163
    $create_session, $session, 1, 1;
158
164
165
# SessionExpiryUpdateInterval directive - new in 2.5
166
if (have_module('version') && have_min_apache_version('2.5')) {
167
    my $max_expiry = (time() + 100) * APR_TIME_PER_SEC;
168
    my $threshold_expiry = (time() + 40) * APR_TIME_PER_SEC;
169
170
    check_get 'SessionExpiryUpdateInterval off by default',
171
        "/on/expire?$session&expiry=$max_expiry", $session, 0, 1;
172
    check_get 'SessionExpiryUpdateInterval skips save',
173
        "/on/expire/cache?$session&expiry=$max_expiry";
174
    check_post 'Session readable when save skipped',
175
        "/on/expire/cache?$session&expiry=$max_expiry", $read_session,
176
        undef, 0, 0, 'value';
177
    check_post 'Dirty overrides SessionExpiryUpdateInterval',
178
        "/on/expire/cache?$session&expiry=$max_expiry", $create_session,
179
        $session, 1, 1;
180
    check_get 'Old session always updates expiry',
181
        "/on/expire/cache?$session&expiry=$threshold_expiry", $session, 0, 1;
182
    check_get 'New empty session with expiry not saved', "/on/expire/cache";
183
    check_post 'Can create session with SessionExpiryUpdateInterval',
184
        "/on/expire/cache", $create_session, $session, 1, 1;
185
}
186
else {
187
    for (1 .. 7 * $checks_per_test) {
188
        skip "SessionExpiryUpdateInterval tests require backporting";
189
    }
190
}
191
159
# SessionInclude/Exclude directives
192
# SessionInclude/Exclude directives
160
check_get 'Not in SessionInclude', "/on/include?$session";
193
check_post 'Cannot write session when not included',
161
check_get 'SessionInclude', "/on/include/yes?$session", $session;
194
    "/on/include?$session", $create_session;
162
check_get 'SessionExclude', "/on/include/yes/no?$session";
195
check_post 'Can read session when included',
196
    "/on/include/yes?$session", $read_session, undef, 0, 0, 'value';
197
check_post 'SessionExclude overrides SessionInclude',
198
    "/on/include/yes/no?$session", $create_session;
(-)c-modules/test_session/mod_test_session.c (-1 / +8 lines)
Lines 31-38 Link Here
31
        </Location>
31
        </Location>
32
    </IfModule>
32
    </IfModule>
33
    <Location /sessiontest/on/expire>
33
    <Location /sessiontest/on/expire>
34
        SessionMaxAge 10
34
        SessionMaxAge 100
35
    </Location>
35
    </Location>
36
    <IfModule mod_version.c>
37
        <IfVersion >= 2.5.0>
38
            <Location /sessiontest/on/expire/cache>
39
                SessionExpiryUpdateInterval 50
40
            </Location>
41
        </IfVersion>
42
    </IfModule>
36
    <Location /sessiontest/on/include>
43
    <Location /sessiontest/on/include>
37
        SessionInclude /sessiontest/on/include/yes
44
        SessionInclude /sessiontest/on/include/yes
38
        SessionExclude /sessiontest/on/include/yes/no
45
        SessionExclude /sessiontest/on/include/yes/no

Return to bug 57300