OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * Tests the behavior of stripCookiesAndLoginInfo. |
| 7 */ |
| 8 netInternalsTest('NetInternalsLogViewPainterStripInfo', function() { |
| 9 // Each entry in |expectations| is a list consisting of a header element |
| 10 // before and after applying the filter. If the second entry is null, the |
| 11 // element should be unmodified. |
| 12 var expectations = [ |
| 13 ['set-cookie: blah', 'set-cookie: [value was stripped]'], |
| 14 ['set-cookie2: blah', 'set-cookie2: [value was stripped]'], |
| 15 ['cookie: blah', 'cookie: [value was stripped]'], |
| 16 ['authorization: NTLM blah', 'authorization: NTLM [value was stripped]'], |
| 17 |
| 18 ['proxy-authorization: Basic blah', |
| 19 'proxy-authorization: Basic [value was stripped]'], |
| 20 |
| 21 ['WWW-Authenticate: Basic realm="Something, or another"', null], |
| 22 |
| 23 ['WWW-Authenticate: Negotiate blah-token-blah', |
| 24 'WWW-Authenticate: Negotiate [value was stripped]'], |
| 25 |
| 26 ['WWW-Authenticate: NTLM asdllk2j3l423lk4j23l4kj', |
| 27 'WWW-Authenticate: NTLM [value was stripped]'], |
| 28 |
| 29 ['WWW-Authenticate: Kerberos , Negotiate asdfasdfasdfasfa', null], |
| 30 ['WWW-Authenticate: Kerberos, Negotiate asdfasdfasdfasfa', null], |
| 31 ['WWW-Authenticate: Digest , Negotiate asdfasdfasdfasfa', null], |
| 32 ['WWW-Authenticate: Digest realm="Foo realm", Negotiate asdf', null], |
| 33 ['WWW-Authenticate: Kerberos,Digest,Basic', null], |
| 34 ['WWW-Authenticate: Digest realm="asdfasdf", nonce=5, qop="auth"', null], |
| 35 ['WWW-Authenticate: Basic realm=foo,foo=bar , Digest ', null], |
| 36 ['Proxy-Authenticate: Basic realm="Something, or another"', null], |
| 37 |
| 38 ['Proxy-Authenticate: Negotiate blah-token-blah', |
| 39 'Proxy-Authenticate: Negotiate [value was stripped]'], |
| 40 |
| 41 ['Proxy-Authenticate: NTLM asdllk2j3l423lk4j23l4kj', |
| 42 'Proxy-Authenticate: NTLM [value was stripped]'], |
| 43 |
| 44 ['Proxy-Authenticate: Kerberos , Negotiate asdfasdfa', null], |
| 45 ['Proxy-Authenticate: Kerberos, Negotiate asdfasdfa', null], |
| 46 ['Proxy-Authenticate: Digest , Negotiate asdfasdfa', null], |
| 47 ['Proxy-Authenticate: Digest realm="Foo realm", Negotiate asdfasdfa', null], |
| 48 ['Proxy-Authenticate: Kerberos,Digest,Basic', null], |
| 49 ['Proxy-Authenticate: Digest realm="asdfasdf", nonce=5, qop="auth"', null], |
| 50 ['Proxy-Authenticate: Basic realm=foo,foo=bar , Digest ', null] |
| 51 ]; |
| 52 |
| 53 for (var i = 0; i < expectations.length; ++i) { |
| 54 var expectation = expectations[i]; |
| 55 // Position within params.headers where the authentication information goes. |
| 56 for (var position = 0; position < 3; ++position) { |
| 57 var entry = { |
| 58 'params': { |
| 59 'headers': [ |
| 60 'Host: clients1.google.com', |
| 61 'Connection: keep-alive', |
| 62 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)'], |
| 63 'line': 'GET / HTTP/1.1\r\n'}, |
| 64 'phase': 0, |
| 65 'source': {'id': 329, 'type': 1}, |
| 66 'time': '22468349', |
| 67 'type': 104}; |
| 68 |
| 69 entry.params.headers[position] = expectation[0]; |
| 70 var stripped = stripCookiesAndLoginInfo(entry); |
| 71 expectTrue(stripped !== entry, |
| 72 expectation[0] + ': not duplicated.'); |
| 73 if (expectation[1] == null) { |
| 74 expectEquals(stripped.params.headers[position], expectation[0]); |
| 75 } else { |
| 76 expectEquals(stripped.params.headers[position], expectation[1]); |
| 77 } |
| 78 } |
| 79 } |
| 80 testDone(); |
| 81 }); |
OLD | NEW |