Skip to content

Commit 477223c

Browse files
author
Isobel Redelmeier
committed
Users can generate a password with only hex chars
[#131585619] User should be able to generate password with hex charset
1 parent 4828b63 commit 477223c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

commands/generate.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type GenerateCommand struct {
1717
ExcludeNumber bool `short:"N" long:"exclude-number" description:"[Password] Exclude number characters from the generated value"`
1818
ExcludeUpper bool `short:"U" long:"exclude-upper" description:"[Password] Exclude upper alpha characters from the generated value"`
1919
ExcludeLower bool `short:"L" long:"exclude-lower" description:"[Password] Exclude lower alpha characters from the generated value"`
20+
OnlyHex bool `short:"H" long:"only-hex" description:"[Password] Use only hexadecimal characters"`
2021
Ca string `long:"ca" description:"[Certificate] Name of CA used to sign the generated certificate (Default: 'default')"`
2122
Duration int `short:"d" long:"duration" description:"[Certificate] Valid duration (in days) of the generated certificate (Default: 365)"`
2223
KeyLength int `short:"k" long:"key-length" description:"[Certificate, SSH, RSA] Bit length of the generated key (Default: 2048)"`
@@ -44,6 +45,7 @@ func (cmd GenerateCommand) Execute([]string) error {
4445
ExcludeNumber: cmd.ExcludeNumber,
4546
ExcludeUpper: cmd.ExcludeUpper,
4647
ExcludeLower: cmd.ExcludeLower,
48+
OnlyHex: cmd.OnlyHex,
4749
Length: cmd.Length,
4850
CommonName: cmd.CommonName,
4951
Organization: cmd.Organization,

commands/generate_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var _ = Describe("Generate", func() {
3434
Expect(session.Out).To(Say(responseMyPasswordPotatoes))
3535
})
3636

37-
It("can the generated password secret as JSON", func() {
37+
It("can print the generated password secret as JSON", func() {
3838
setupPasswordPostServer("my-password", "potatoes", generateDefaultTypeRequestJson(`{}`, true))
3939

4040
session := runCommand("generate", "-n", "my-password", "--output-json")
@@ -111,6 +111,12 @@ var _ = Describe("Generate", func() {
111111
session := runCommand("generate", "-n", "my-password", "-t", "password", "--exclude-number")
112112
Eventually(session).Should(Exit(0))
113113
})
114+
115+
It("including only hex", func() {
116+
setupPasswordPostServer("my-password", "potatoes", generateRequestJson("password", `{"only_hex":true}`, true))
117+
session := runCommand("generate", "-n", "my-password", "-t", "password", "--only-hex")
118+
Eventually(session).Should(Exit(0))
119+
})
114120
})
115121

116122
Describe("with a variety of SSH parameters", func() {
@@ -316,6 +322,7 @@ var _ = Describe("Generate", func() {
316322
commands.HaveFlag("exclude-number", "N"),
317323
commands.HaveFlag("exclude-upper", "U"),
318324
commands.HaveFlag("exclude-lower", "L"),
325+
commands.HaveFlag("only-hex", "H"),
319326
commands.HaveFlag("common-name", "c"),
320327
commands.HaveFlag("organization", "o"),
321328
commands.HaveFlag("organization-unit", "u"),

models/secret_parameters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type SecretParameters struct {
55
ExcludeNumber bool `json:"exclude_number,omitempty"`
66
ExcludeUpper bool `json:"exclude_upper,omitempty"`
77
ExcludeLower bool `json:"exclude_lower,omitempty"`
8+
OnlyHex bool `json:"only_hex,omitempty"`
89
Length int `json:"length,omitempty"`
910
CommonName string `json:"common_name,omitempty"`
1011
Organization string `json:"organization,omitempty"`

0 commit comments

Comments
 (0)