airshipctl/cmd/secret/generate/encryptionkey/encryptionkey_test.go
Sirisha Gopigiri 07b66906ad Cmd changes to add regex support
Added support to accept regex parameter as part of `airshipctl secret
generate encryptionkey` command. This allows user to pass regex parameter
so that the passphrase generated matches the regex.

Relates-To: #398

Change-Id: I3914e6a896bb669e3974fe67c466336e15989a8d
2020-11-18 11:32:28 +05:30

44 lines
1.2 KiB
Go

/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package encryptionkey_test
import (
"fmt"
"testing"
"opendev.org/airship/airshipctl/cmd/secret/generate/encryptionkey"
"opendev.org/airship/airshipctl/testutil"
)
func TestGenerateEncryptionKey(t *testing.T) {
cmdTests := []*testutil.CmdTest{
{
Name: "generate-encryptionkey-cmd-with-help",
CmdLine: "--help",
Cmd: encryptionkey.NewGenerateEncryptionKeyCommand(),
},
{
Name: "generate-encryptionkey-cmd-error",
CmdLine: "--limit 10",
Error: fmt.Errorf("Required Regex flag with limit option"),
Cmd: encryptionkey.NewGenerateEncryptionKeyCommand(),
},
}
for _, tt := range cmdTests {
testutil.RunTest(t, tt)
}
}