Skip to content

Commit

Permalink
Apply fixes related to the bigint into the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Aug 28, 2024
1 parent f171639 commit 203a824
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
7 changes: 0 additions & 7 deletions js/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,6 @@ func TestNewBundle(t *testing.T) {
"InvalidCompat", "es1", `export default function() {};`,
`invalid compatibility mode "es1". Use: "extended", "base", "experimental_enhanced"`,
},
// BigInt is not supported
{
"BigInt", "base",
`module.exports.default = function() {};
BigInt(1231412444)`,
"ReferenceError: BigInt is not defined\n\tat file:///script.js:2:7(7)\n",
},
}

for _, tc := range testCases {
Expand Down
35 changes: 8 additions & 27 deletions js/modules/k6/crypto/x509/x509_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func TestParse(t *testing.T) {
value.algorithm === "RSA" &&
typeof value.key === "object" &&
typeof value.key.e === "number" &&
typeof value.key.n === "object"
typeof value.key.n === "bigint"
)) {
throw new Error("Bad RSA public key");
}`, material.rsaCertificate))
Expand Down Expand Up @@ -607,29 +607,10 @@ func TestParse(t *testing.T) {
_, err := rt.RunString(fmt.Sprintf(`
var pem = %q;
var cert = x509.parse(pem);
var value = cert.publicKey ? cert.publicKey.key.n.bytes() : null;
var expected = [
223, 249, 234, 71, 180, 36, 28, 62, 84, 141, 177, 118, 53, 2, 175,
45, 167, 89, 155, 216, 103, 86, 32, 216, 42, 92, 84, 125, 183, 102,
217, 40, 255, 129, 38, 203, 175, 98, 209, 147, 151, 106, 250, 12,
123, 236, 135, 45, 80, 80, 76, 253, 148, 141, 13, 36, 76, 47, 182,
58, 100, 153, 114, 13, 141, 96, 12, 109, 126, 74, 68, 119, 88, 15,
52, 107, 80, 117, 190, 163, 230, 120, 26, 44, 139, 245, 222, 188,
210, 237, 123, 83, 91, 98, 160, 218, 229, 244, 128, 31, 24, 139,
125, 25, 184, 108, 180, 23, 149, 136, 47, 140, 168, 51, 159, 35,
65, 150, 7, 51, 134, 138, 188, 225, 105, 92, 9, 91, 72, 133, 70,
195, 131, 105, 184, 191, 198, 177, 130, 191, 70, 6, 37, 159, 255,
244, 109, 238, 128, 138, 0, 201, 41, 87, 67, 87, 165, 118, 4, 253,
209, 31, 177, 1, 1, 116, 64, 14, 17, 19, 217, 6, 117, 75, 24, 174,
236, 129, 134, 115, 245, 226, 203, 222, 17, 113, 197, 215, 138,
241, 99, 169, 68, 77, 243, 36, 116, 69, 143, 150, 60, 245, 75, 200,
30, 207, 141, 139, 136, 35, 125, 184, 255, 174, 26, 6, 148, 56,
253, 124, 249, 158, 249, 117, 3, 126, 124, 89, 27, 96, 209, 0, 207,
152, 233, 166, 81, 7, 253, 155, 165, 96, 29, 72, 28, 172, 24, 104,
70, 229, 201, 107, 200, 169, 220, 35
]
if (value.join(":") !== expected.join(":")) {
throw new Error("Bad RSA public key modulus: " + value.join(":"));
var value = cert.publicKey ? cert.publicKey.key.n.toString(16) : null;
var expected = "dff9ea47b4241c3e548db1763502af2da7599bd8675620d82a5c547db766d928ff8126cbaf62d193976afa0c7bec872d50504cfd948d0d244c2fb63a6499720d8d600c6d7e4a4477580f346b5075bea3e6781a2c8bf5debcd2ed7b535b62a0dae5f4801f188b7d19b86cb41795882f8ca8339f2341960733868abce1695c095b488546c38369b8bfc6b182bf4606259ffff46dee808a00c929574357a57604fdd11fb1010174400e1113d906754b18aeec818673f5e2cbde1171c5d78af163a9444df32474458f963cf54bc81ecf8d8b88237db8ffae1a069438fd7cf99ef975037e7c591b60d100cf98e9a65107fd9ba5601d481cac186846e5c96bc8a9dc23";
if (value !== expected) {
throw new Error("Bad RSA public key modulus: " + value);
}`, material.rsaCertificate))
assert.NoError(t, err)
})
Expand All @@ -648,7 +629,7 @@ func TestParse(t *testing.T) {
typeof value === "object" &&
value.algorithm === "DSA" &&
typeof value.key.parameters === "object" &&
typeof value.key.y === "object"
typeof value.key.y === "bigint"
)) {
throw new Error("Bad DSA public key");
}`, material.dsaCertificate))
Expand All @@ -669,8 +650,8 @@ func TestParse(t *testing.T) {
typeof value === "object" &&
value.algorithm === "ECDSA" &&
typeof value.key.curve === "object" &&
typeof value.key.x === "object" &&
typeof value.key.y === "object"
typeof value.key.x === "bigint" &&
typeof value.key.y === "bigint"
)) {
throw new Error("Bad ECDSA public key");
}`, material.ecdsaCertificate))
Expand Down

0 comments on commit 203a824

Please sign in to comment.