Skip to content

Commit cd353df

Browse files
committed
keyParser: fix equals()
1 parent be9165b commit cd353df

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/protocol/keyParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ const BaseKey = {
446446
this.type === parsed.type
447447
&& this[SYM_PRIV_PEM] === parsed[SYM_PRIV_PEM]
448448
&& this[SYM_PUB_PEM] === parsed[SYM_PUB_PEM]
449-
&& this[SYM_PUB_SSH] === parsed[SYM_PUB_SSH]
449+
&& this[SYM_PUB_SSH].equals(parsed[SYM_PUB_SSH])
450450
);
451451
},
452452
};

test/test-protocol-keyparser.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ readdirSync(BASE_PATH).forEach((name) => {
8282
+ `Received: ${inspect(details)}`)
8383
);
8484
});
85+
86+
// Test `equals()`
87+
let copy;
88+
if (isEncrypted)
89+
copy = parseKey(key, (isPPK ? 'node.js' : 'password'));
90+
else
91+
copy = parseKey(key);
92+
if (!Array.isArray(copy))
93+
copy = [copy];
94+
for (let i = 0; i < res.length; ++i) {
95+
assert.strictEqual(
96+
res[i].equals(copy[i]),
97+
true,
98+
failMsg(name, 'equals() failed with copy')
99+
);
100+
}
85101
}
86102

87103
if (isEncrypted && !isPublic) {

0 commit comments

Comments
 (0)