Changeset 51415 for trunk/tests/phpunit/tests/functions/anonymization.php
- Timestamp:
- 07/13/2021 10:43:42 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/anonymization.php
r49025 r51415 26 26 * @ticket 41083 27 27 * @ticket 43545 28 * @requires function inet_ntop29 * @requires function inet_pton30 28 * 31 29 * @param string $raw_ip Raw IP address. … … 91 89 '::', 92 90 ), 93 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings.94 array(95 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]:400',96 '1000::',97 ),98 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings.99 array(100 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]',101 '1000::',102 ),103 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings.104 array(105 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]400',106 '1000::',107 ),108 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings.109 array(110 '[1000:0000:0000:0000:0000:0000:0000:0001]:235\"or=',111 '1000::',112 ),113 91 // IPv4, no port. 114 92 array( … … 126 104 '10.20.30.0', 127 105 ), 106 // IPv6, no port, reducible representation. 107 array( 108 '0000:0000:0000:0000:0000:0000:0000:0001', 109 '::', 110 ), 111 // IPv6, port, reducible representation. 112 array( 113 '[0000:0000:0000:0000:0000:0000:0000:0001]:1234', 114 '::', 115 ), 116 // IPv6, no port, reduced representation. 117 array( 118 '::', 119 '::', 120 ), 121 // IPv6, no port, reduced representation. 122 array( 123 '::1', 124 '::', 125 ), 126 // IPv6, port, reduced representation. 127 array( 128 '[::]:20000', 129 '::', 130 ), 131 // IPv6, address brackets without port delimiter and number, reduced representation. 132 array( 133 '[::1]', 134 '::', 135 ), 136 // IPv6, no port, compatibility mode. 137 array( 138 '::ffff:10.15.20.25', 139 '::ffff:10.15.20.0', 140 ), 141 // IPv6, port, compatibility mode. 142 array( 143 '[::FFFF:10.15.20.25]:30000', 144 '::ffff:10.15.20.0', 145 ), 146 // IPv6, no port, compatibility mode shorthand. 147 array( 148 '::127.0.0.1', 149 '::ffff:127.0.0.0', 150 ), 151 // IPv6, port, compatibility mode shorthand. 152 array( 153 '[::127.0.0.1]:30000', 154 '::ffff:127.0.0.0', 155 ), 156 ); 157 } 158 159 /** 160 * Test that wp_privacy_anonymize_ip() properly anonymizes all possible IP address formats. 161 * 162 * @dataProvider data_wp_privacy_anonymize_ip_with_inet_dependency 163 * 164 * @ticket 41083 165 * @ticket 43545 166 * @requires function inet_ntop 167 * @requires function inet_pton 168 * 169 * @param string $raw_ip Raw IP address. 170 * @param string $expected_result Expected result. 171 */ 172 public function test_wp_privacy_anonymize_ip_with_inet_dependency( $raw_ip, $expected_result ) { 173 $this->test_wp_privacy_anonymize_ip( $raw_ip, $expected_result ); 174 } 175 176 /** 177 * Provide test cases for `test_wp_privacy_anonymize_ip()`. 178 * 179 * @since 4.9.6 Moved from `Test_WP_Community_Events::data_get_unsafe_client_ip_anonymization()`. 180 * 181 * @return array { 182 * @type array { 183 * @string string $raw_ip Raw IP address. 184 * @string string $expected_result Expected result. 185 * } 186 * } 187 */ 188 public function data_wp_privacy_anonymize_ip_with_inet_dependency() { 189 return array( 190 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. 191 array( 192 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]:400', 193 '1000::', 194 ), 195 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. 196 array( 197 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]', 198 '1000::', 199 ), 200 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. 201 array( 202 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]400', 203 '1000::', 204 ), 205 // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. 206 array( 207 '[1000:0000:0000:0000:0000:0000:0000:0001]:235\"or=', 208 '1000::', 209 ), 128 210 // IPv6, no port. 129 211 array( … … 136 218 '2a03:2880:2110:df07::', 137 219 ), 138 // IPv6, no port, reducible representation.139 array(140 '0000:0000:0000:0000:0000:0000:0000:0001',141 '::',142 ),143 220 // IPv6, no port, partially reducible representation. 144 221 array( … … 146 223 '1000::', 147 224 ), 148 // IPv6, port, reducible representation.149 array(150 '[0000:0000:0000:0000:0000:0000:0000:0001]:1234',151 '::',152 ),153 225 // IPv6, port, partially reducible representation. 154 226 array( 155 227 '[1000:0000:0000:0000:0000:0000:0000:0001]:5678', 156 228 '1000::', 157 ),158 // IPv6, no port, reduced representation.159 array(160 '::',161 '::',162 ),163 // IPv6, no port, reduced representation.164 array(165 '::1',166 '::',167 ),168 // IPv6, port, reduced representation.169 array(170 '[::]:20000',171 '::',172 ),173 // IPv6, address brackets without port delimiter and number, reduced representation.174 array(175 '[::1]',176 '::',177 ),178 // IPv6, no port, compatibility mode.179 array(180 '::ffff:10.15.20.25',181 '::ffff:10.15.20.0',182 ),183 // IPv6, port, compatibility mode.184 array(185 '[::FFFF:10.15.20.25]:30000',186 '::ffff:10.15.20.0',187 ),188 // IPv6, no port, compatibility mode shorthand.189 array(190 '::127.0.0.1',191 '::ffff:127.0.0.0',192 ),193 // IPv6, port, compatibility mode shorthand.194 array(195 '[::127.0.0.1]:30000',196 '::ffff:127.0.0.0',197 229 ), 198 230 // IPv6 with reachability scope.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)