Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/test/data/extensions/api_test/platform_keys/basic.js

Issue 1141253003: chrome.platformKeys: Add filtering by certificate types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 'use strict'; 5 'use strict';
6 6
7 var systemTokenEnabled = (location.search.indexOf("systemTokenEnabled") != -1); 7 var systemTokenEnabled = (location.search.indexOf("systemTokenEnabled") != -1);
8 var selectedTestSuite = location.hash.slice(1); 8 var selectedTestSuite = location.hash.slice(1);
9 console.log('[SELECTED TEST SUITE] ' + selectedTestSuite + 9 console.log('[SELECTED TEST SUITE] ' + selectedTestSuite +
10 ', systemTokenEnable ' + systemTokenEnabled); 10 ', systemTokenEnable ' + systemTokenEnabled);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 assertTrue(!!chrome.platformKeys.subtleCrypto().exportKey, 190 assertTrue(!!chrome.platformKeys.subtleCrypto().exportKey,
191 "No exportKey method."); 191 "No exportKey method.");
192 succeed(); 192 succeed();
193 } 193 }
194 194
195 var requestAll = { 195 var requestAll = {
196 certificateTypes: [], 196 certificateTypes: [],
197 certificateAuthorities: [] 197 certificateAuthorities: []
198 }; 198 };
199 199
200 var requestRSA = {
pneubeck (no reviews) 2015/05/19 10:09:00 as these two variables are used only once, just ma
cschuet (SLOW) 2015/05/19 11:36:23 Done.
201 certificateTypes: ['rsaSign'],
202 certificateAuthorities: []
203 };
204
205 var requestECDSA = {
206 certificateTypes: ['ecdsaSign'],
207 certificateAuthorities: []
208 };
209
200 // Depends on |data|, thus it cannot be created immediately. 210 // Depends on |data|, thus it cannot be created immediately.
201 function requestCA1() { 211 function requestCA1() {
202 return { 212 return {
203 certificateTypes: [], 213 certificateTypes: [],
204 certificateAuthorities: [data.client_1_issuer_dn.buffer] 214 certificateAuthorities: [data.client_1_issuer_dn.buffer]
205 }; 215 };
206 } 216 }
207 217
208 function testSelectAllCerts() { 218 function testSelectAllCerts() {
209 var expectedCerts = [data.client_1]; 219 var expectedCerts = [data.client_1];
(...skipping 20 matching lines...) Expand all
230 function testInteractiveSelectNoCerts() { 240 function testInteractiveSelectNoCerts() {
231 assertCertsSelected({interactive: true, request: requestAll}, 241 assertCertsSelected({interactive: true, request: requestAll},
232 [] /* no certs selected */); 242 [] /* no certs selected */);
233 } 243 }
234 244
235 function testInteractiveSelectClient1() { 245 function testInteractiveSelectClient1() {
236 assertCertsSelected({interactive: true, request: requestAll}, 246 assertCertsSelected({interactive: true, request: requestAll},
237 [data.client_1]); 247 [data.client_1]);
238 } 248 }
239 249
240 function testMatchResult() { 250 function testMatchResultCA1() {
241 chrome.platformKeys.selectClientCertificates( 251 chrome.platformKeys.selectClientCertificates(
242 {interactive: false, request: requestCA1()}, 252 {interactive: false, request: requestCA1()},
243 callbackPass(function(matches) { 253 callbackPass(function(matches) {
244 var expectedAlgorithm = { 254 var expectedAlgorithm = {
245 modulusLength: 2048, 255 modulusLength: 2048,
246 name: "RSASSA-PKCS1-v1_5", 256 name: "RSASSA-PKCS1-v1_5",
247 publicExponent: new Uint8Array([0x01, 0x00, 0x01]) 257 publicExponent: new Uint8Array([0x01, 0x00, 0x01])
248 }; 258 };
249 var actualAlgorithm = matches[0].keyAlgorithm; 259 var actualAlgorithm = matches[0].keyAlgorithm;
250 assertEq( 260 assertEq(
251 expectedAlgorithm, actualAlgorithm, 261 expectedAlgorithm, actualAlgorithm,
252 'Member algorithm of Match does not equal the expected algorithm'); 262 'Member algorithm of Match does not equal the expected algorithm');
253 })); 263 }));
254 } 264 }
255 265
266 function testMatchResultECDSA() {
267 chrome.platformKeys.selectClientCertificates(
268 {interactive: false, request: requestECDSA},
269 callbackPass(function(matches) {
270 assertEq(
271 0, matches.length,
pneubeck (no reviews) 2015/05/19 10:09:00 is this autoformatted?
cschuet (SLOW) 2015/05/19 11:36:23 Done.
272 'No matches expected.');
273 }));
274 }
275
276 function testMatchResultRSA() {
277 chrome.platformKeys.selectClientCertificates(
278 {interactive: false, request: requestRSA},
279 callbackPass(function(matches) {
280 var expectedAlgorithm = {
281 modulusLength: 2048,
282 name: "RSASSA-PKCS1-v1_5",
283 publicExponent: new Uint8Array([0x01, 0x00, 0x01])
284 };
285 var actualAlgorithm = matches[0].keyAlgorithm;
286 assertEq(
287 expectedAlgorithm, actualAlgorithm,
288 'Member algorithm of Match does not equal the expected algorithm');
289 }));
290 }
291
256 function testGetKeyPairMissingAlgorithName() { 292 function testGetKeyPairMissingAlgorithName() {
257 var keyParams = { 293 var keyParams = {
258 // This is missing the algorithm name. 294 // This is missing the algorithm name.
259 hash: {name: 'SHA-1'} 295 hash: {name: 'SHA-1'}
260 }; 296 };
261 try { 297 try {
262 chrome.platformKeys.getKeyPair( 298 chrome.platformKeys.getKeyPair(
263 data.client_1.buffer, keyParams, function(error) { 299 data.client_1.buffer, keyParams, function(error) {
264 fail('getKeyPair call was expected to fail.'); 300 fail('getKeyPair call was expected to fail.');
265 }); 301 });
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // On interactive selectClientCertificates calls, the simulated user does not 462 // On interactive selectClientCertificates calls, the simulated user does not
427 // select any cert. 463 // select any cert.
428 basicTests: function() { 464 basicTests: function() {
429 var tests = [ 465 var tests = [
430 testStaticMethods, 466 testStaticMethods,
431 testSelectAllCerts, 467 testSelectAllCerts,
432 testBackgroundNoninteractiveSelect, 468 testBackgroundNoninteractiveSelect,
433 testBackgroundInteractiveSelect, 469 testBackgroundInteractiveSelect,
434 testSelectCA1Certs, 470 testSelectCA1Certs,
435 testInteractiveSelectNoCerts, 471 testInteractiveSelectNoCerts,
436 testMatchResult, 472 testMatchResultCA1,
473 testMatchResultECDSA,
474 testMatchResultRSA,
437 testGetKeyPairMissingAlgorithName, 475 testGetKeyPairMissingAlgorithName,
438 testGetKeyPairRejectsRSAPSS, 476 testGetKeyPairRejectsRSAPSS,
439 testGetKeyPair, 477 testGetKeyPair,
440 testSignNoHash, 478 testSignNoHash,
441 testSignSha1Client1, 479 testSignSha1Client1,
442 ]; 480 ];
443 481
444 chrome.test.runTests(tests); 482 chrome.test.runTests(tests);
445 }, 483 },
446 484
(...skipping 23 matching lines...) Expand all
470 // Verify that client_1 but not client_2 is selected in non-interactive 508 // Verify that client_1 but not client_2 is selected in non-interactive
471 // calls. 509 // calls.
472 testSelectAllReturnsClient1, 510 testSelectAllReturnsClient1,
473 ]; 511 ];
474 512
475 chrome.test.runTests(tests); 513 chrome.test.runTests(tests);
476 } 514 }
477 }; 515 };
478 516
479 setUp(testSuites[selectedTestSuite]); 517 setUp(testSuites[selectedTestSuite]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698