| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.test.InstrumentationTestCase; | 8 import android.test.InstrumentationTestCase; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 | 10 |
| 11 public class WebappAuthenticatorTest extends InstrumentationTestCase { | 11 public class WebappAuthenticatorTest extends InstrumentationTestCase { |
| 12 @SmallTest | 12 @SmallTest |
| 13 public void testAuthentication() { | 13 public void testAuthentication() { |
| 14 Context context = getInstrumentation().getTargetContext(); | 14 Context context = getInstrumentation().getTargetContext(); |
| 15 String url = "http://www.example.org/hello.html"; | 15 String url = "http://www.example.org/hello.html"; |
| 16 byte[] mac = WebappAuthenticator.getMacForUrl(context, url); | 16 byte[] mac = WebappAuthenticator.getMacForUrl(context, url); |
| 17 assertNotNull(mac); | 17 assertNotNull(mac); |
| 18 assertTrue(WebappAuthenticator.isUrlValid(context, url, mac)); | 18 assertTrue(WebappAuthenticator.isUrlValid(context, url, mac)); |
| 19 assertFalse(WebappAuthenticator.isUrlValid(context, url + "?goats=true",
mac)); | 19 assertFalse(WebappAuthenticator.isUrlValid(context, url + "?goats=true",
mac)); |
| 20 mac[4] += 1; | 20 mac[4] += 1; |
| 21 assertFalse(WebappAuthenticator.isUrlValid(context, url, mac)); | 21 assertFalse(WebappAuthenticator.isUrlValid(context, url, mac)); |
| 22 } | 22 } |
| 23 } | 23 } |
| OLD | NEW |