Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

60 řádky
3.0 KiB

  1. var assert = chai.assert;
  2. describe('LessPass v2', function () {
  3. describe('set of characters', function () {
  4. it('get default set of characters', function () {
  5. var setOfCharacters = LessPass._getSetOfCharacters();
  6. assert.equal(
  7. 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~',
  8. setOfCharacters
  9. );
  10. assert.equal(26 * 2 + 10 + 32, setOfCharacters.length);
  11. });
  12. it('get default set of characters concat rules in order', function () {
  13. var setOfCharacters = LessPass._getSetOfCharacters(['lowercase', 'uppercase', 'digits']);
  14. assert.equal('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', setOfCharacters);
  15. assert.equal(26 * 2 + 10, setOfCharacters.length);
  16. });
  17. it('get set of characters only lowercase', function () {
  18. var setOfCharacters = LessPass._getSetOfCharacters(['lowercase']);
  19. assert.equal('abcdefghijklmnopqrstuvwxyz', setOfCharacters);
  20. assert.equal(26, setOfCharacters.length);
  21. });
  22. it('get set of characters only uppercase', function () {
  23. var setOfCharacters = LessPass._getSetOfCharacters(['uppercase']);
  24. assert.equal('ABCDEFGHIJKLMNOPQRSTUVWXYZ', setOfCharacters);
  25. assert.equal(26, setOfCharacters.length);
  26. });
  27. it('get set of characters only digits', function () {
  28. var setOfCharacters = LessPass._getSetOfCharacters(['digits']);
  29. assert.equal('0123456789', setOfCharacters);
  30. assert.equal(10, setOfCharacters.length);
  31. });
  32. it('get set of characters only symbols', function () {
  33. var setOfCharacters = LessPass._getSetOfCharacters(['symbols']);
  34. assert.equal('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~', setOfCharacters);
  35. assert.equal(32, setOfCharacters.length);
  36. });
  37. it('generate one char per rules', function () {
  38. var oneCharPerSetOfCharacters = LessPass._getOneCharPerRule(
  39. bigInt(26 * 26),
  40. ['lowercase', 'uppercase']
  41. );
  42. assert.equal('aA', oneCharPerSetOfCharacters.value);
  43. assert.equal(2, oneCharPerSetOfCharacters.value.length);
  44. assert.equal(1, oneCharPerSetOfCharacters.entropy);
  45. });
  46. it('configured rules', function () {
  47. assert.deepEqual(['uppercase'], LessPass._getConfiguredRules({uppercase: true}));
  48. assert.deepEqual(['lowercase', 'uppercase'], LessPass._getConfiguredRules({uppercase: true, lowercase: true}));
  49. assert.deepEqual(['lowercase'], LessPass._getConfiguredRules({lowercase: true, symbols: false}));
  50. assert.deepEqual(['lowercase', 'uppercase', 'digits', 'symbols'], LessPass._getConfiguredRules({
  51. lowercase: true,
  52. uppercase: true,
  53. symbols: true,
  54. digits: true
  55. }));
  56. });
  57. });
  58. });