| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,23 +53,33 @@ assert.throws(function() { | |||
| 53 | 53 | }, /^TypeError: Data must be a string or a buffer$/); | |
| 54 | 54 | ||
| 55 | 55 | ||
| 56 | - function assertSorted(list) { | ||
| 56 | + function validateList(list) { | ||
| 57 | + // The list must not be empty | ||
| 58 | + assert(list.length > 0); | ||
| 59 | + | ||
| 60 | + // The list should be sorted. | ||
| 57 | 61 | // Array#sort() modifies the list in place so make a copy. | |
| 58 | - const sorted = list.slice().sort(); | ||
| 62 | + const sorted = [...list].sort(); | ||
| 59 | 63 | assert.deepStrictEqual(list, sorted); | |
| 64 | + | ||
| 65 | + // Each element should be unique. | ||
| 66 | + assert.strictEqual([...new Set(list)].length, list.length); | ||
| 67 | + | ||
| 68 | + // Each element should be a string. | ||
| 69 | + assert(list.every((value) => typeof value === 'string')); | ||
| 60 | 70 | } | |
| 61 | 71 | ||
| 62 | 72 | // Assume that we have at least AES-128-CBC. | |
| 63 | - assert.notStrictEqual(0, crypto.getCiphers().length); | ||
| 73 | + const cryptoCiphers = crypto.getCiphers(); | ||
| 64 | 74 | assert(crypto.getCiphers().includes('aes-128-cbc')); | |
| 65 | - assert(!crypto.getCiphers().includes('AES-128-CBC')); | ||
| 66 | - assertSorted(crypto.getCiphers()); | ||
| 75 | + validateList(cryptoCiphers); | ||
| 67 | 76 | ||
| 68 | 77 | // Assume that we have at least AES256-SHA. | |
| 69 | - assert.notStrictEqual(0, tls.getCiphers().length); | ||
| 78 | + const tlsCiphers = tls.getCiphers(); | ||
| 70 | 79 | assert(tls.getCiphers().includes('aes256-sha')); | |
| 71 | - assert(!tls.getCiphers().includes('AES256-SHA')); | ||
| 72 | - assertSorted(tls.getCiphers()); | ||
| 80 | + // There should be no capital letters in any element. | ||
| 81 | + assert(tlsCiphers.every((value) => /^[^A-Z]+$/.test(value))); | ||
| 82 | + validateList(tlsCiphers); | ||
| 73 | 83 | ||
| 74 | 84 | // Assert that we have sha and sha1 but not SHA and SHA1. | |
| 75 | 85 | assert.notStrictEqual(0, crypto.getHashes().length); | |
@@ -79,13 +89,13 @@ assert(!crypto.getHashes().includes('SHA1')); | |||
| 79 | 89 | assert(!crypto.getHashes().includes('SHA')); | |
| 80 | 90 | assert(crypto.getHashes().includes('RSA-SHA1')); | |
| 81 | 91 | assert(!crypto.getHashes().includes('rsa-sha1')); | |
| 82 | - assertSorted(crypto.getHashes()); | ||
| 92 | + validateList(crypto.getHashes()); | ||
| 83 | 93 | ||
| 84 | 94 | // Assume that we have at least secp384r1. | |
| 85 | 95 | assert.notStrictEqual(0, crypto.getCurves().length); | |
| 86 | 96 | assert(crypto.getCurves().includes('secp384r1')); | |
| 87 | 97 | assert(!crypto.getCurves().includes('SECP384R1')); | |
| 88 | - assertSorted(crypto.getCurves()); | ||
| 98 | + validateList(crypto.getCurves()); | ||
| 89 | 99 | ||
| 90 | 100 | // Regression tests for #5725: hex input that's not a power of two should | |
| 91 | 101 | // throw, not assert in C++ land. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments