Revert of Refactoring of Cast-related crypto code (patchset #19 id:350001 of https...
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / networking_private / test.js
blob0af2e86e85567fb893bdd675d3041c02952cebde
1 // Copyright 2014 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.
5 // This just tests the interface. It does not test for specific results, only
6 // that callbacks are correctly invoked, expected parameters are correct,
7 // and failures are detected.
9 var callbackPass = chrome.test.callbackPass;
11 var kFailure = 'Failure';
12 var kGuid = 'SOME_GUID';
14 // Test properties for the verification API.
15 var verificationProperties = {
16   "certificate": "certificate",
17   "publicKey": "cHVibGljX2tleQ==",  // Base64("public_key")
18   "nonce": "nonce",
19   "signedData": "c2lnbmVkX2RhdGE=",  // Base64("signed_data")
20   "deviceSerial": "device_serial",
21   "deviceSsid": "Device 0123",
22   "deviceBssid": "00:01:02:03:04:05"
25 function callbackResult(result) {
26   if (chrome.runtime.lastError)
27     chrome.test.fail(chrome.runtime.lastError.message);
28   else if (result == false || result == kFailure)
29     chrome.test.fail('Failed: ' + result);
32 var availableTests = [
33   function getProperties() {
34     chrome.networkingPrivate.getProperties(
35         kGuid, callbackPass(callbackResult));
36   },
37   function getManagedProperties() {
38     chrome.networkingPrivate.getManagedProperties(
39         kGuid, callbackPass(callbackResult));
40   },
41   function getState() {
42     chrome.networkingPrivate.getState(
43         kGuid, callbackPass(callbackResult));
44   },
45   function setProperties() {
46     chrome.networkingPrivate.setProperties(
47         kGuid, { 'GUID': kGuid }, callbackPass(callbackResult));
48   },
49   function createNetwork() {
50     chrome.networkingPrivate.createNetwork(
51         false, { 'GUID': kGuid }, callbackPass(callbackResult));
52   },
53   function getNetworks() {
54     chrome.networkingPrivate.getNetworks(
55         { networkType: 'Ethernet' }, callbackPass(callbackResult));
56   },
57   function getVisibleNetworks() {
58     chrome.networkingPrivate.getVisibleNetworks(
59         'Ethernet', callbackPass(callbackResult));
60   },
61   function getEnabledNetworkTypes() {
62     chrome.networkingPrivate.getEnabledNetworkTypes(
63         callbackPass(callbackResult));
64   },
65   function enableNetworkType() {
66     chrome.networkingPrivate.enableNetworkType('Ethernet');
67     chrome.test.succeed();
68   },
69   function disableNetworkType() {
70     chrome.networkingPrivate.disableNetworkType('Ethernet');
71     chrome.test.succeed();
72   },
73   function requestNetworkScan() {
74     chrome.networkingPrivate.requestNetworkScan();
75     chrome.test.succeed();
76   },
77   function startConnect() {
78     chrome.networkingPrivate.startConnect(
79         kGuid, callbackPass(callbackResult));
80   },
81   function startDisconnect() {
82     chrome.networkingPrivate.startDisconnect(
83         kGuid, callbackPass(callbackResult));
84   },
85   function verifyDestination() {
86     chrome.networkingPrivate.verifyDestination(
87         verificationProperties, callbackPass(callbackResult));
88   },
89   function verifyAndEncryptCredentials() {
90     chrome.networkingPrivate.verifyAndEncryptCredentials(
91         verificationProperties, kGuid, callbackPass(callbackResult));
92   },
93   function verifyAndEncryptData() {
94     chrome.networkingPrivate.verifyAndEncryptData(
95         verificationProperties, 'data', callbackPass(callbackResult));
96   },
97   function setWifiTDLSEnabledState() {
98     chrome.networkingPrivate.setWifiTDLSEnabledState(
99         '', true, callbackPass(callbackResult));
100   },
101   function getWifiTDLSStatus() {
102     chrome.networkingPrivate.getWifiTDLSStatus(
103         '', callbackPass(callbackResult));
104   },
105   function getCaptivePortalStatus() {
106     chrome.networkingPrivate.getWifiTDLSStatus(
107         kGuid, callbackPass(callbackResult));
108   },
111 var testToRun = window.location.search.substring(1);
112 chrome.test.runTests(availableTests.filter(function(op) {
113   return op.name == testToRun;
114 }));