From 2fbb9c285d52ce9ffd43359fa25e95edad074b13 Mon Sep 17 00:00:00 2001 From: Bryce Curtis Date: Wed, 16 May 2012 15:13:42 -0500 Subject: [PATCH] CB-369: Authentication Code doesn't seem to work. -- Verified basic auth works and provided test case. --- test/AndroidManifest.xml | 3 ++ test/assets/www/basicauth/index.html | 42 +++++++++++++++++ test/assets/www/index.html | 33 ++++++------- .../org/apache/cordova/test/basicauth.java | 46 +++++++++++++++++++ 4 files changed, 108 insertions(+), 16 deletions(-) mode change 100644 => 100755 test/AndroidManifest.xml create mode 100755 test/assets/www/basicauth/index.html create mode 100755 test/src/org/apache/cordova/test/basicauth.java diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml old mode 100644 new mode 100755 index b8038c7d..4918fe51 --- a/test/AndroidManifest.xml +++ b/test/AndroidManifest.xml @@ -144,5 +144,8 @@ + + diff --git a/test/assets/www/basicauth/index.html b/test/assets/www/basicauth/index.html new file mode 100755 index 00000000..02ff0b2a --- /dev/null +++ b/test/assets/www/basicauth/index.html @@ -0,0 +1,42 @@ + + + + + + + Cordova Tests + + + + + +

Basic Auth

+
+

Platform:  , Version:  

+

UUID:  , Name:  

+

Width:  , Height:   + , Color Depth:

+
+
+ Loading link below should be successful and show page indicating username=test & password=test.
+
+ Test password + + diff --git a/test/assets/www/index.html b/test/assets/www/index.html index 0fd4eafa..6838156f 100755 --- a/test/assets/www/index.html +++ b/test/assets/www/index.html @@ -1,20 +1,20 @@ @@ -49,6 +49,7 @@ $ + diff --git a/test/src/org/apache/cordova/test/basicauth.java b/test/src/org/apache/cordova/test/basicauth.java new file mode 100755 index 00000000..4007c97c --- /dev/null +++ b/test/src/org/apache/cordova/test/basicauth.java @@ -0,0 +1,46 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.cordova.test; + +import android.os.Bundle; +import android.webkit.WebView; + +import org.apache.cordova.*; +import org.apache.cordova.api.LOG; + +public class basicauth extends DroidGap { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + super.init(); + + // LogCat: onReceivedHttpAuthRequest(browserspy.dk:80,BrowserSpy.dk - HTTP Password Test) + AuthenticationToken token = new AuthenticationToken(); + token.setUserName("test"); + token.setPassword("test"); + super.setAuthenticationToken(token, "browserspy.dk:80", "BrowserSpy.dk - HTTP Password Test"); + + // Add web site to whitelist + super.appView.addWhiteListEntry("http://browserspy.dk*", true); + + // Load test + super.loadUrl("file:///android_asset/www/basicauth/index.html"); + } + +}