(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestGenerateASCIIPassword(t *testing.T) { |
| 72 | for _, length := range []int{0, 1, 2, 3, 5, 20, 200} { |
| 73 | password, err := GenerateASCIIPassword(length) |
| 74 | |
| 75 | assert.NilError(t, err) |
| 76 | assert.Equal(t, length, len(password)) |
| 77 | |
| 78 | // Check every rune in the string. See [TestPolicyASCII]. |
| 79 | for _, c := range password { |
| 80 | assert.Assert(t, strings.ContainsRune(policyASCII, c), "%q is not acceptable", c) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | previous := sets.Set[string]{} |
| 85 | for range 10 { |
| 86 | password, err := GenerateASCIIPassword(5) |
| 87 | |
| 88 | assert.NilError(t, err) |
| 89 | assert.Equal(t, 5, len(password)) |
| 90 | |
| 91 | // Check every rune in the string. See [TestPolicyASCII]. |
| 92 | for _, c := range password { |
| 93 | assert.Assert(t, strings.ContainsRune(policyASCII, c), "%q is not acceptable", c) |
| 94 | } |
| 95 | |
| 96 | assert.Assert(t, !previous.Has(password), "%q generated twice", password) |
| 97 | previous.Insert(password) |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | func TestPolicyASCII(t *testing.T) { |
| 102 | // [GenerateASCIIPassword] used to pick random characters by doing |
nothing calls this directly
no test coverage detected