Commit 3ca15ac0 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Cleanup cert provider tests: delete compareBuffers

Replace the custom handwritten compareBuffers() tool with the commonly
used and more bulletproof chrome.test.assertEq().

Bug: 1078761
Change-Id: Ic30bb450f6922a2fa69297cc60010f4661a4c0a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246683Reviewed-by: default avatarOmar Morsi <omorsi@google.com>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779759}
parent 8e8eb151
...@@ -30,16 +30,6 @@ function readFile(path, callback) { ...@@ -30,16 +30,6 @@ function readFile(path, callback) {
oReq.send(null); oReq.send(null);
} }
function compareBuffers(a, b) {
if (a.length != b.length)
return false;
for (var i = 0; i < a.length; i++) {
if (a[i] != b[i])
return false;
}
return true;
}
var signDigestRequest; var signDigestRequest;
var signCallback; var signCallback;
...@@ -59,8 +49,7 @@ function register() { ...@@ -59,8 +49,7 @@ function register() {
}; };
function checkResult(rejectedCerts) { function checkResult(rejectedCerts) {
assertEq(1, rejectedCerts.length); assertEq([invalidCert.buffer], rejectedCerts);
assertTrue(compareBuffers(invalidCert, new Uint8Array(rejectedCerts[0])));
} }
function reportCertificates(reportCallback) { function reportCertificates(reportCallback) {
...@@ -72,8 +61,7 @@ function register() { ...@@ -72,8 +61,7 @@ function register() {
chrome.certificateProvider.onSignDigestRequested.addListener(function( chrome.certificateProvider.onSignDigestRequested.addListener(function(
request, callback) { request, callback) {
assertTrue( assertEq(l1_leaf_cert.buffer, request.certificate);
compareBuffers(l1_leaf_cert, new Uint8Array(request.certificate)));
// The sign request must refer to the only hash that was declared to be // The sign request must refer to the only hash that was declared to be
// supported. // supported.
assertEq(1, validCertInfo.supportedHashes.length); assertEq(1, validCertInfo.supportedHashes.length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment