Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 22... Línea 22...
22
 * @package    core
22
 * @package    core
23
 * @copyright  2024 Jake Dallimore <jrhdallimore@gmail.com>
23
 * @copyright  2024 Jake Dallimore <jrhdallimore@gmail.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @covers \core\session\utility\cookie_helper
25
 * @covers \core\session\utility\cookie_helper
26
 */
26
 */
27
class cookie_helper_test extends \advanced_testcase {
27
final class cookie_helper_test extends \advanced_testcase {
Línea 28... Línea 28...
28
 
28
 
29
    /**
29
    /**
30
     * Testing cookie_response_headers_add_attributes().
30
     * Testing cookie_response_headers_add_attributes().
31
     *
31
     *
Línea 63... Línea 63...
63
                    'Partitioned',
63
                    'Partitioned',
64
                    'SameSite=None',
64
                    'SameSite=None',
65
                    'Secure',
65
                    'Secure',
66
                ],
66
                ],
67
                'casesensitive' => false,
67
                'casesensitive' => false,
68
                'output' => [
68
                'expectedheaders' => [
69
                    'Set-Cookie: testcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
69
                    'Set-Cookie: testcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
70
                ],
70
                ],
71
            ],
71
            ],
72
            'Several matching cookie headers, without attributes' => [
72
            'Several matching cookie headers, without attributes' => [
73
                'headers' => [
73
                'headers' => [
Línea 82... Línea 82...
82
                    'Partitioned',
82
                    'Partitioned',
83
                    'SameSite=None',
83
                    'SameSite=None',
84
                    'Secure',
84
                    'Secure',
85
                ],
85
                ],
86
                'casesensitive' => false,
86
                'casesensitive' => false,
87
                'output' => [
87
                'expectedheaders' => [
88
                    'Set-Cookie: testcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
88
                    'Set-Cookie: testcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
89
                    'Set-Cookie: mytestcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
89
                    'Set-Cookie: mytestcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
90
                ],
90
                ],
91
            ],
91
            ],
92
            'Several matching cookie headers, several non-matching, all missing all attributes' => [
92
            'Several matching cookie headers, several non-matching, all missing all attributes' => [
Línea 105... Línea 105...
105
                    'Partitioned',
105
                    'Partitioned',
106
                    'SameSite=None',
106
                    'SameSite=None',
107
                    'Secure',
107
                    'Secure',
108
                ],
108
                ],
109
                'casesensitive' => false,
109
                'casesensitive' => false,
110
                'output' => [
110
                'expectedheaders' => [
111
                    'Set-Cookie: testcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
111
                    'Set-Cookie: testcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
112
                    'Set-Cookie: mytestcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
112
                    'Set-Cookie: mytestcookie=value; path=/test/; HttpOnly; Partitioned; SameSite=None; Secure;',
113
                    'Set-Cookie: anothertestcookie=value; path=/test/; HttpOnly;',
113
                    'Set-Cookie: anothertestcookie=value; path=/test/; HttpOnly;',
114
                ],
114
                ],
115
            ],
115
            ],
Línea 127... Línea 127...
127
                    'Partitioned',
127
                    'Partitioned',
128
                    'SameSite=None',
128
                    'SameSite=None',
129
                    'Secure',
129
                    'Secure',
130
                ],
130
                ],
131
                'casesensitive' => false,
131
                'casesensitive' => false,
132
                'output' => [
132
                'expectedheaders' => [
133
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; Partitioned; SameSite=None',
133
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; Partitioned; SameSite=None',
134
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned;',
134
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned;',
135
                ],
135
                ],
136
            ],
136
            ],
137
            'Matching headers, some with existing attributes, case sensitive' => [
137
            'Matching headers, some with existing attributes, case sensitive' => [
Línea 148... Línea 148...
148
                    'Partitioned',
148
                    'Partitioned',
149
                    'SameSite=None',
149
                    'SameSite=None',
150
                    'Secure',
150
                    'Secure',
151
                ],
151
                ],
152
                'casesensitive' => true,
152
                'casesensitive' => true,
153
                'output' => [
153
                'expectedheaders' => [
154
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; partitioned; Partitioned; Secure;',
154
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; partitioned; Partitioned; Secure;',
155
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned; Secure;',
155
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned; Secure;',
156
                ],
156
                ],
157
            ],
157
            ],
158
            'Empty list of cookie names to match, so unmodified inputs' => [
158
            'Empty list of cookie names to match, so unmodified inputs' => [
Línea 165... Línea 165...
165
                    'Partitioned',
165
                    'Partitioned',
166
                    'SameSite=None',
166
                    'SameSite=None',
167
                    'Secure',
167
                    'Secure',
168
                ],
168
                ],
169
                'casesensitive' => false,
169
                'casesensitive' => false,
170
                'output' => [
170
                'expectedheaders' => [
171
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; partitioned',
171
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; partitioned',
172
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None',
172
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None',
173
                ],
173
                ],
174
            ],
174
            ],
175
            'Empty list of attributes to set, so unmodified inputs' => [
175
            'Empty list of attributes to set, so unmodified inputs' => [
Línea 181... Línea 181...
181
                    'testcookie',
181
                    'testcookie',
182
                    'mycookie',
182
                    'mycookie',
183
                ],
183
                ],
184
                'attributes' => [],
184
                'attributes' => [],
185
                'casesensitive' => false,
185
                'casesensitive' => false,
186
                'output' => [
186
                'expectedheaders' => [
187
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; partitioned',
187
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; partitioned',
188
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None',
188
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None',
189
                ],
189
                ],
190
            ],
190
            ],
191
            'Other HTTP headers, some matching Set-Cookie, some not' => [
191
            'Other HTTP headers, some matching Set-Cookie, some not' => [
Línea 202... Línea 202...
202
                    'Partitioned',
202
                    'Partitioned',
203
                    'SameSite=None',
203
                    'SameSite=None',
204
                    'Secure',
204
                    'Secure',
205
                ],
205
                ],
206
                'casesensitive' => false,
206
                'casesensitive' => false,
207
                'output' => [
207
                'expectedheaders' => [
208
                    'Authorization: blah',
208
                    'Authorization: blah',
209
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned',
209
                    'Set-Cookie: testcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned',
210
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned;',
210
                    'Set-Cookie: mytestcookie=value; path=/test/; secure; HttpOnly; SameSite=None; Partitioned;',
211
                ],
211
                ],
212
            ],
212
            ],