Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: parsing non RFC uuid values #455

Merged
merged 13 commits into from
Jun 2, 2020
46 changes: 46 additions & 0 deletions test/unit/v35.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ describe('v5', () => {
assert.ok(v3('hello.example.com', '00000000-0000-0000-0000-000000000000'));
});

test('v3 parsing non RFC uuid values', () => {
assert.strictEqual(
v3(
'hello.example.com',
// equal '00000000-0000-0000-0000-000000000000'
'00000000000000000000000000000000',
ctavan marked this conversation as resolved.
Show resolved Hide resolved
),
'8ccfd135-fc23-3a10-a477-5a4f02f92cf9',
);

// During parsing only two hex chars in a row are taken into account
// The remaining characters are ignored.
awwit marked this conversation as resolved.
Show resolved Hide resolved

assert.strictEqual(
v3(
'hello.example.com',
// equal '00000000-0000-0000-0000-000000000000'
awwit marked this conversation as resolved.
Show resolved Hide resolved
'=Y00a-f*v00b*-00c-00d#-p00f\b-00g-00h-####00i^^^-00j*1*2*3&-L00k-\n00l-/00m-----00n-fg000-00p-00r+',
),
'8ccfd135-fc23-3a10-a477-5a4f02f92cf9',
);
});

test('v3 namespace buffer validation', () => {
assert.throws(() => {
v3('hello.example.com', new Array(15));
Expand Down Expand Up @@ -204,6 +227,29 @@ describe('v5', () => {
assert.ok(v5('hello.example.com', '00000000-0000-0000-0000-000000000000'));
});

test('v5 parsing non RFC uuid values', () => {
awwit marked this conversation as resolved.
Show resolved Hide resolved
assert.strictEqual(
v5(
'hello.example.com',
// equal '00000000-0000-0000-0000-000000000000'
awwit marked this conversation as resolved.
Show resolved Hide resolved
'00000000000000000000000000000000',
),
'9aefd4c8-16b3-555b-9731-72b19be683e4',
);

// During parsing only two hex chars in a row are taken into account
// The remaining characters are ignored.
awwit marked this conversation as resolved.
Show resolved Hide resolved

assert.strictEqual(
v5(
'hello.example.com',
// equal '00000000-0000-0000-0000-000000000000'
awwit marked this conversation as resolved.
Show resolved Hide resolved
'=Y00a-f*v00b*-00c-00d#-p00f\b-00g-00h-####00i^^^-00j*1*2*3&-L00k-\n00l-/00m-----00n-fg000-00p-00r+',
),
'9aefd4c8-16b3-555b-9731-72b19be683e4',
);
});

test('v5 namespace buffer validation', () => {
assert.throws(() => {
v5('hello.example.com', new Array(15));
Expand Down