mirror of
https://github.com/kou029w/websri.git
synced 2025-02-22 16:55:58 +00:00
Update tests to assert expected output structure for IntegrityMetadataSet
This commit is contained in:
parent
d0415bbd04
commit
9a2e7ad45c
2 changed files with 53 additions and 38 deletions
|
@ -77,10 +77,14 @@ test("accepts an IntegrityMetadata like object as input", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
set,
|
[...set],
|
||||||
new IntegrityMetadataSet(
|
[
|
||||||
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
{
|
||||||
),
|
alg: "sha256",
|
||||||
|
val: "MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
||||||
|
opt: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -97,12 +101,14 @@ sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLs
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
set,
|
[...set],
|
||||||
new IntegrityMetadataSet([
|
[
|
||||||
|
...new IntegrityMetadataSet([
|
||||||
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
||||||
"sha384-VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r",
|
"sha384-VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r",
|
||||||
"sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLsmn1H256V/eUIQ==",
|
"sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLsmn1H256V/eUIQ==",
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -113,11 +119,13 @@ test("multiple overlapping algorithms can be accepted", function () {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
set,
|
[...set],
|
||||||
new IntegrityMetadataSet([
|
[
|
||||||
|
...new IntegrityMetadataSet([
|
||||||
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
||||||
"sha256-uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=",
|
"sha256-uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=",
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -127,10 +135,14 @@ test("trims leading and trailing whitespace", function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
set,
|
[...set],
|
||||||
new IntegrityMetadataSet(
|
[
|
||||||
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
{
|
||||||
),
|
alg: "sha256",
|
||||||
|
val: "MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
||||||
|
opt: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -140,37 +152,39 @@ test("whitespace can be analyzed as entry separator", function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
set,
|
[...set],
|
||||||
new IntegrityMetadataSet([
|
[
|
||||||
|
...new IntegrityMetadataSet([
|
||||||
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
"sha256-MV9b23bQeMQ7isAGTkoBZGErH853yGk0W/yUx1iU7dM=",
|
||||||
"sha384-VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r",
|
"sha384-VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r",
|
||||||
"sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLsmn1H256V/eUIQ==",
|
"sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLsmn1H256V/eUIQ==",
|
||||||
]),
|
]),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("discards unsupported hash algorithm", function () {
|
test("discards unsupported hash algorithm", function () {
|
||||||
const set = new IntegrityMetadataSet("sha1-lDpwLQbzRZmu4fjajvn3KWAx1pk=");
|
const set = new IntegrityMetadataSet("sha1-lDpwLQbzRZmu4fjajvn3KWAx1pk=");
|
||||||
|
|
||||||
assert.deepEqual(set, new IntegrityMetadataSet([]));
|
assert.deepEqual([...set], []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("discards null input", function () {
|
test("discards null input", function () {
|
||||||
const set = new IntegrityMetadataSet(null);
|
const set = new IntegrityMetadataSet(null);
|
||||||
|
|
||||||
assert.deepEqual(set, new IntegrityMetadataSet([]));
|
assert.deepEqual([...set], []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("discards empty string input", function () {
|
test("discards empty string input", function () {
|
||||||
const set = new IntegrityMetadataSet([]);
|
const set = new IntegrityMetadataSet([]);
|
||||||
|
|
||||||
assert.deepEqual(set, new IntegrityMetadataSet([]));
|
assert.deepEqual([...set], []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("discards invalid value", function () {
|
test("discards invalid value", function () {
|
||||||
const set = new IntegrityMetadataSet("md5\0/..invalid-value");
|
const set = new IntegrityMetadataSet("md5\0/..invalid-value");
|
||||||
|
|
||||||
assert.deepEqual(set, new IntegrityMetadataSet([]));
|
assert.deepEqual([...set], []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("discards invalid values in a list of multiple inputs", function () {
|
test("discards invalid values in a list of multiple inputs", function () {
|
||||||
|
@ -178,5 +192,5 @@ test("discards invalid values in a list of multiple inputs", function () {
|
||||||
"sha1-lDpwLQbzRZmu4fjajvn3KWAx1pk= md5\0/..invalid-value",
|
"sha1-lDpwLQbzRZmu4fjajvn3KWAx1pk= md5\0/..invalid-value",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(set, new IntegrityMetadataSet([]));
|
assert.deepEqual([...set], []);
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,10 +33,7 @@ sha1-lDpwLQbzRZmu4fjajvn3KWAx1pk=
|
||||||
md5-bNNVbesNpUvKBgtMOUeYOQ==
|
md5-bNNVbesNpUvKBgtMOUeYOQ==
|
||||||
`);
|
`);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual([...integrityMetadataSet.strongest], []);
|
||||||
integrityMetadataSet.strongest,
|
|
||||||
new IntegrityMetadataSet([]),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("custom getPrioritizedHashAlgorithm function can be used", function () {
|
test("custom getPrioritizedHashAlgorithm function can be used", function () {
|
||||||
|
@ -54,9 +51,13 @@ sha512-wVJ82JPBJHc9gRkRlwyP5uhX1t9dySJr2KFgYUwM2WOk3eorlLt9NgIe+dhl1c6ilKgt1JoLs
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
integrityMetadataSet.strongest,
|
[...integrityMetadataSet.strongest],
|
||||||
new IntegrityMetadataSet(
|
[
|
||||||
"sha384-VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r",
|
{
|
||||||
),
|
alg: "sha384",
|
||||||
|
val: "VbxVaw0v4Pzlgrpf4Huq//A1ZTY4x6wNVJTCpkwL6hzFczHHwSpFzbyn9MNKCJ7r",
|
||||||
|
opt: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue