Bug 911384 - Follow-up: tolerate explicitly falsy payloads in computeHAWK. r=rnewman

This commit is contained in:
Sam Penrose 2013-10-29 13:45:37 -07:00
Родитель 4b9a1c591b
Коммит 46a0db7e37
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -458,7 +458,9 @@ this.CryptoUtils = {
let contentType = CryptoUtils.stripHeaderAttributes(options.contentType);
if (!artifacts.hash && options.hasOwnProperty("payload")) {
if (!artifacts.hash &&
options.hasOwnProperty("payload") &&
options.payload) {
let hasher = Cc["@mozilla.org/security/hash;1"]
.createInstance(Ci.nsICryptoHash);
hasher.init(hash_algo);

Просмотреть файл

@ -188,6 +188,16 @@ add_test(function test_hawk() {
do_check_eq(result.artifacts.hash, undefined);
do_check_eq(result.artifacts.mac, "S3f8E4hAURAqJxOlsYugkPZxLoRYrClgbSQ/3FmKMbY=");
// Empty payload changes nothing.
result = compute(makeURI("http://example.net/path"), method,
{ credentials: credentials_sha256,
ts: 1353809207,
nonce: "Ygvqdz",
payload: null,
});
do_check_eq(result.artifacts.hash, undefined);
do_check_eq(result.artifacts.mac, "S3f8E4hAURAqJxOlsYugkPZxLoRYrClgbSQ/3FmKMbY=");
result = compute(makeURI("http://example.net/path"), method,
{ credentials: credentials_sha256,
ts: 1353809207,