auth: Adding support for "auth disable" command.

Added support for the auth disable command in the server, added the
etcdctl command and a respective testcase.
This commit is contained in:
Ajit Yagaty
2016-05-07 11:24:43 -07:00
parent 3bcd2b5b9f
commit adc981c53d
9 changed files with 220 additions and 88 deletions

View File

@ -28,6 +28,7 @@ func NewAuthCommand() *cobra.Command {
}
ac.AddCommand(newAuthEnableCommand())
ac.AddCommand(newAuthDisableCommand())
return ac
}
@ -43,7 +44,7 @@ func newAuthEnableCommand() *cobra.Command {
// authEnableCommandFunc executes the "auth enable" command.
func authEnableCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("auth enable command does not accept argument."))
ExitWithError(ExitBadArgs, fmt.Errorf("auth enable command does not accept any arguments."))
}
ctx, cancel := commandCtx(cmd)
@ -55,3 +56,27 @@ func authEnableCommandFunc(cmd *cobra.Command, args []string) {
fmt.Println("Authentication Enabled")
}
func newAuthDisableCommand() *cobra.Command {
return &cobra.Command{
Use: "disable",
Short: "disable authentication",
Run: authDisableCommandFunc,
}
}
// authDisableCommandFunc executes the "auth disable" command.
func authDisableCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("auth disable command does not accept any arguments."))
}
ctx, cancel := commandCtx(cmd)
_, err := mustClientFromCmd(cmd).Auth.AuthDisable(ctx)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
fmt.Println("Authentication Disabled")
}