feat: support UUID v1, v3, v4, v5, v6, v7

- Add v6 and v7 as valid options
- Add unit tests for generating and analyzing all supported versions
This commit is contained in:
Bart van Andel 2025-04-03 14:08:14 +02:00
parent e0bdde89c4
commit 457d28fc55
2 changed files with 12 additions and 12 deletions

View file

@ -20,7 +20,7 @@ class GenerateUUID extends Operation {
this.name = "Generate UUID";
this.module = "Crypto";
this.description = "Generates an RFC 4122 compliant Universally Unique Identifier (UUID), also known as a Globally Unique Identifier (GUID).<br><br>A version 4 UUID relies on random numbers, in this case generated using <code>uuid</code> package";
this.description = "Generates an RFC 9562 (formerly RFC 4122) compliant Universally Unique Identifier (UUID), also known as a Globally Unique Identifier (GUID).<br><br>A version 4 UUID relies on random numbers, in this case generated using <code>uuid</code> package";
this.infoURL = "https://wikipedia.org/wiki/Universally_unique_identifier";
this.inputType = "string";
this.outputType = "string";
@ -29,7 +29,7 @@ class GenerateUUID extends Operation {
name: "UUID Version",
type: "option",
value: [
"v1", "v3", "v4", "v5"
"v1", "v3", "v4", "v5", "v6", "v7",
]
},
{

View file

@ -580,18 +580,18 @@ Password: 282760`;
assert.strictEqual(result.toString().substr(0, 37), "-----BEGIN PGP PRIVATE KEY BLOCK-----");
}),
it("Generate UUID v1", () => {
const result = chef.generateUUID("", { version: "v1" }).toString();
...[1, 3, 4, 5, 6, 7].map(version => it(`Generate UUID v${version}`, () => {
const result = chef.generateUUID("", { "UUID version": `v${version}` }).toString();
assert.ok(result);
assert.equal(result.length, 36);
}),
assert.strictEqual(result.length, 36);
})),
it("Analyse UUID v1", () => {
const uuidv1 = chef.generateUUID("", { version: "v1" }).toString();
const uuidAnalysis = chef.analyseUUID(uuidv1).toString();
assert.equal(uuidAnalysis, "UUID version: 1");
}),
...[1, 3, 4, 5, 6, 7].map(version => it(`Analyze UUID v${version}`, () => {
const uuid = chef.generateUUID("", { "UUID version": `v${version}` }).toString();
const result = chef.analyseUUID(uuid).toString();
const expected = `UUID version: ${version}`;
assert.strictEqual(result, expected);
})),
it("Gzip, Gunzip", () => {
assert.strictEqual(chef.gunzip(chef.gzip("Down To The Wire")).toString(), "Down To The Wire");