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

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

Issue 298073009: Reuse WebCrypto's normalizeCryptoAlgorithm in enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 // Must be packed to ../enterprise_platform_keys.crx using the private key 5 // Must be packed to ../enterprise_platform_keys.crx using the private key
6 // ../enterprise_platform_keys.pem . 6 // ../enterprise_platform_keys.pem .
7 7
8 var assertEq = chrome.test.assertEq; 8 var assertEq = chrome.test.assertEq;
9 var assertTrue = chrome.test.assertTrue; 9 var assertTrue = chrome.test.assertTrue;
10 var assertThrows = chrome.test.assertThrows; 10 var assertThrows = chrome.test.assertThrows;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 assertCertsStored.bind(null, userToken, [cert1a, cert1b]), 351 assertCertsStored.bind(null, userToken, [cert1a, cert1b]),
352 chrome.enterprise.platformKeys.removeCertificate.bind( 352 chrome.enterprise.platformKeys.removeCertificate.bind(
353 null, userToken.id, cert1a.buffer), 353 null, userToken.id, cert1a.buffer),
354 assertCertsStored.bind(null, userToken, [cert1b]), 354 assertCertsStored.bind(null, userToken, [cert1b]),
355 chrome.enterprise.platformKeys.removeCertificate.bind( 355 chrome.enterprise.platformKeys.removeCertificate.bind(
356 null, userToken.id, cert1b.buffer), 356 null, userToken.id, cert1b.buffer),
357 assertCertsStored.bind(null, userToken, []) 357 assertCertsStored.bind(null, userToken, [])
358 ]); 358 ]);
359 }, 359 },
360 360
361 // Call generate key with invalid algorithm parameter, missing
362 // modulusLength.
363 function algorithmParameterMissingModulusLength() {
364 var algorithm = {
365 name: "RSASSA-PKCS1-v1_5",
366 publicExponent:
367 new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
368 hash: {
369 name: "SHA-1",
370 }
371 };
372 userToken.subtleCrypto.generateKey(algorithm, false, ['sign']).then(
373 function(keyPair) {
374 assertTrue(false, 'generateKey was expected to fail');
375 },
376 callbackPass(function(error) {
377 assertEq(
378 new Error('Error: A required parameter was missing our out-of-range'),
379 error);
380 }));
381 },
382
383 // Call generate key with invalid algorithm parameter, missing hash.
384 function algorithmParameterMissingHash() {
385 var algorithm = {
386 name: 'RSASSA-PKCS1-v1_5',
387 modulusLength: 512,
388 publicExponent:
389 new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
390 };
391 userToken.subtleCrypto.generateKey(algorithm, false, ['sign']).then(
392 function(keyPair) {
393 assertTrue(false, 'generateKey was expected to fail');
394 },
395 callbackPass(function(error) {
396 assertEq(
397 new Error('Error: A required parameter was missing our out-of-range'),
398 error);
399 }));
400 },
401
361 // Imports a certificate for which now private key was imported/generated 402 // Imports a certificate for which now private key was imported/generated
362 // before. 403 // before.
363 function missingPrivateKey() { 404 function missingPrivateKey() {
364 chrome.enterprise.platformKeys.importCertificate( 405 chrome.enterprise.platformKeys.importCertificate(
365 userToken.id, cert2.buffer, callbackFail('Key not found.')); 406 userToken.id, cert2.buffer, callbackFail('Key not found.'));
366 }, 407 },
367 function importInvalidCert() { 408 function importInvalidCert() {
368 var invalidCert = new ArrayBuffer(16); 409 var invalidCert = new ArrayBuffer(16);
369 chrome.enterprise.platformKeys.importCertificate( 410 chrome.enterprise.platformKeys.importCertificate(
370 userToken.id, 411 userToken.id,
(...skipping 14 matching lines...) Expand all
385 callbackFail('Certificate is not a valid X.509 certificate.')); 426 callbackFail('Certificate is not a valid X.509 certificate.'));
386 }, 427 },
387 function getCertsInvalidToken() { 428 function getCertsInvalidToken() {
388 chrome.enterprise.platformKeys.getCertificates( 429 chrome.enterprise.platformKeys.getCertificates(
389 'invalid token id', callbackFail('The token is not valid.')); 430 'invalid token id', callbackFail('The token is not valid.'));
390 } 431 }
391 ]); 432 ]);
392 } 433 }
393 434
394 beforeTests(runTests); 435 beforeTests(runTests);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698