Home | History | Annotate | Download | only in browser
      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
      3 // found in the LICENSE file.
      4 
      5 package org.chromium.chrome.browser;
      6 
      7 import android.content.Context;
      8 import android.test.InstrumentationTestCase;
      9 import android.test.suitebuilder.annotation.SmallTest;
     10 
     11 public class WebappAuthenticatorTest extends InstrumentationTestCase {
     12     @SmallTest
     13     public void testAuthentication() {
     14         Context context = getInstrumentation().getTargetContext();
     15         String url = "http://www.example.org/hello.html";
     16         byte[] mac = WebappAuthenticator.getMacForUrl(context, url);
     17         assertNotNull(mac);
     18         assertTrue(WebappAuthenticator.isUrlValid(context, url, mac));
     19         assertFalse(WebappAuthenticator.isUrlValid(context, url + "?goats=true", mac));
     20         mac[4] += 1;
     21         assertFalse(WebappAuthenticator.isUrlValid(context, url, mac));
     22     }
     23 }
     24