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

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

Issue 332233002: enterprise.platformKeys: Copy-on-read the 'algorithm' member of Key objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed to copy-on-read. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/enterprise_platform_keys.crx ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js
diff --git a/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js b/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js
index a5915009c4c2880b6360964490c6fb5f4308a9f5..f38cf54e8086b6db2022ebd23c86fa5e29e9c886 100644
--- a/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js
+++ b/chrome/test/data/extensions/api_test/enterprise_platform_keys/basic.js
@@ -260,6 +260,50 @@ function beforeTests(callback) {
});
}
+function checkAlgorithmIsCopiedOnRead(key) {
+ var algorithm = key.algorithm;
+ var originalAlgorithm = {
+ name: algorithm.name,
+ modulusLength: algorithm.modulusLength,
+ publicExponent: algorithm.publicExponent,
+ hash: {name: algorithm.hash.name}
+ };
+ var originalModulusLength = algorithm.modulusLength;
+ algorithm.hash.name = null;
+ algorithm.hash = null;
+ algorithm.name = null;
+ algorithm.modulusLength = null;
+ algorithm.publicExponent = null;
+ assertEq(originalAlgorithm, key.algorithm);
+}
+
+function checkPropertyIsReadOnly(object, key) {
+ var original = object[key];
+ try {
+ object[key] = {};
+ fail('Expected that the property is read only and an exception to ' +
bartfab (slow) 2014/06/18 16:19:06 Nit: Grammar: "Expected the property to be read-on
+ 'be thrown');
+ } catch (error) {
+ assertEq(original, object[key]);
+ }
+}
+
+function checkKeyPairCommonFormat(keyPair) {
+ checkPropertyIsReadOnly(keyPair, 'privateKey');
+ var privateKey = keyPair.privateKey;
+ assertEq('private', privateKey.type);
+ assertEq(false, privateKey.extractable);
+ checkPropertyIsReadOnly(privateKey, 'algorithm');
+ checkAlgorithmIsCopiedOnRead(privateKey);
+
+ checkPropertyIsReadOnly(keyPair, 'publicKey');
+ var publicKey = keyPair.publicKey;
+ assertEq('public', publicKey.type);
+ assertEq(true, publicKey.extractable);
+ checkPropertyIsReadOnly(publicKey, 'algorithm');
+ checkAlgorithmIsCopiedOnRead(publicKey);
+}
+
function runTests(userToken) {
chrome.test.runTests([
function hasSubtleCryptoMethods() {
@@ -308,6 +352,9 @@ function runTests(userToken) {
function(error) { fail("GenerateKey failed: " + error); })
.then(callbackPass(function(publicKeySpki) {
// Ensure that the returned key pair has the expected format.
+ // Some parameter independent checks:
+ checkKeyPairCommonFormat(cachedKeyPair);
+
// Checks depending on the generateKey arguments:
var privateKey = cachedKeyPair.privateKey;
assertEq(['sign'], privateKey.usages);
« no previous file with comments | « chrome/test/data/extensions/api_test/enterprise_platform_keys.crx ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698