OLD | NEW |
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 function testInteractiveSelectNoCerts() { | 230 function testInteractiveSelectNoCerts() { |
231 assertCertsSelected({interactive: true, request: requestAll}, | 231 assertCertsSelected({interactive: true, request: requestAll}, |
232 [] /* no certs selected */); | 232 [] /* no certs selected */); |
233 } | 233 } |
234 | 234 |
235 function testInteractiveSelectClient1() { | 235 function testInteractiveSelectClient1() { |
236 assertCertsSelected({interactive: true, request: requestAll}, | 236 assertCertsSelected({interactive: true, request: requestAll}, |
237 [data.client_1]); | 237 [data.client_1]); |
238 } | 238 } |
239 | 239 |
240 function testMatchResult() { | 240 function testMatchResultCA1() { |
241 chrome.platformKeys.selectClientCertificates( | 241 chrome.platformKeys.selectClientCertificates( |
242 {interactive: false, request: requestCA1()}, | 242 {interactive: false, request: requestCA1()}, |
243 callbackPass(function(matches) { | 243 callbackPass(function(matches) { |
244 var expectedAlgorithm = { | 244 var expectedAlgorithm = { |
245 modulusLength: 2048, | 245 modulusLength: 2048, |
246 name: "RSASSA-PKCS1-v1_5", | 246 name: "RSASSA-PKCS1-v1_5", |
247 publicExponent: new Uint8Array([0x01, 0x00, 0x01]) | 247 publicExponent: new Uint8Array([0x01, 0x00, 0x01]) |
248 }; | 248 }; |
249 var actualAlgorithm = matches[0].keyAlgorithm; | 249 var actualAlgorithm = matches[0].keyAlgorithm; |
250 assertEq( | 250 assertEq( |
251 expectedAlgorithm, actualAlgorithm, | 251 expectedAlgorithm, actualAlgorithm, |
252 'Member algorithm of Match does not equal the expected algorithm'); | 252 'Member algorithm of Match does not equal the expected algorithm'); |
253 })); | 253 })); |
254 } | 254 } |
255 | 255 |
| 256 function testMatchResultECDSA() { |
| 257 var requestECDSA = { |
| 258 certificateTypes: ['ecdsaSign'], |
| 259 certificateAuthorities: [] |
| 260 }; |
| 261 chrome.platformKeys.selectClientCertificates( |
| 262 {interactive: false, request: requestECDSA}, |
| 263 callbackPass(function(matches) { |
| 264 assertEq(0, matches.length, 'No matches expected.'); |
| 265 })); |
| 266 } |
| 267 |
| 268 function testMatchResultRSA() { |
| 269 var requestRSA = { |
| 270 certificateTypes: ['rsaSign'], |
| 271 certificateAuthorities: [] |
| 272 }; |
| 273 chrome.platformKeys.selectClientCertificates( |
| 274 {interactive: false, request: requestRSA}, |
| 275 callbackPass(function(matches) { |
| 276 var expectedAlgorithm = { |
| 277 modulusLength: 2048, |
| 278 name: "RSASSA-PKCS1-v1_5", |
| 279 publicExponent: new Uint8Array([0x01, 0x00, 0x01]) |
| 280 }; |
| 281 var actualAlgorithm = matches[0].keyAlgorithm; |
| 282 assertEq( |
| 283 expectedAlgorithm, actualAlgorithm, |
| 284 'Member algorithm of Match does not equal the expected algorithm'); |
| 285 })); |
| 286 } |
| 287 |
256 function testGetKeyPairMissingAlgorithName() { | 288 function testGetKeyPairMissingAlgorithName() { |
257 var keyParams = { | 289 var keyParams = { |
258 // This is missing the algorithm name. | 290 // This is missing the algorithm name. |
259 hash: {name: 'SHA-1'} | 291 hash: {name: 'SHA-1'} |
260 }; | 292 }; |
261 try { | 293 try { |
262 chrome.platformKeys.getKeyPair( | 294 chrome.platformKeys.getKeyPair( |
263 data.client_1.buffer, keyParams, function(error) { | 295 data.client_1.buffer, keyParams, function(error) { |
264 fail('getKeyPair call was expected to fail.'); | 296 fail('getKeyPair call was expected to fail.'); |
265 }); | 297 }); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // On interactive selectClientCertificates calls, the simulated user does not | 458 // On interactive selectClientCertificates calls, the simulated user does not |
427 // select any cert. | 459 // select any cert. |
428 basicTests: function() { | 460 basicTests: function() { |
429 var tests = [ | 461 var tests = [ |
430 testStaticMethods, | 462 testStaticMethods, |
431 testSelectAllCerts, | 463 testSelectAllCerts, |
432 testBackgroundNoninteractiveSelect, | 464 testBackgroundNoninteractiveSelect, |
433 testBackgroundInteractiveSelect, | 465 testBackgroundInteractiveSelect, |
434 testSelectCA1Certs, | 466 testSelectCA1Certs, |
435 testInteractiveSelectNoCerts, | 467 testInteractiveSelectNoCerts, |
436 testMatchResult, | 468 testMatchResultCA1, |
| 469 testMatchResultECDSA, |
| 470 testMatchResultRSA, |
437 testGetKeyPairMissingAlgorithName, | 471 testGetKeyPairMissingAlgorithName, |
438 testGetKeyPairRejectsRSAPSS, | 472 testGetKeyPairRejectsRSAPSS, |
439 testGetKeyPair, | 473 testGetKeyPair, |
440 testSignNoHash, | 474 testSignNoHash, |
441 testSignSha1Client1, | 475 testSignSha1Client1, |
442 ]; | 476 ]; |
443 | 477 |
444 chrome.test.runTests(tests); | 478 chrome.test.runTests(tests); |
445 }, | 479 }, |
446 | 480 |
(...skipping 23 matching lines...) Expand all Loading... |
470 // Verify that client_1 but not client_2 is selected in non-interactive | 504 // Verify that client_1 but not client_2 is selected in non-interactive |
471 // calls. | 505 // calls. |
472 testSelectAllReturnsClient1, | 506 testSelectAllReturnsClient1, |
473 ]; | 507 ]; |
474 | 508 |
475 chrome.test.runTests(tests); | 509 chrome.test.runTests(tests); |
476 } | 510 } |
477 }; | 511 }; |
478 | 512 |
479 setUp(testSuites[selectedTestSuite]); | 513 setUp(testSuites[selectedTestSuite]); |
OLD | NEW |