Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
const (
Port = 5985
TlsPort = 5986
AuthDefault = AuthBasic
AuthDefault = AuthNTLM
AuthBasic = "basic"
AuthNTLM = "ntlm"
AuthSSH = "ssh"
Expand Down Expand Up @@ -66,7 +66,7 @@ func BuildConfigFlags(fs *pflag.FlagSet) (config *Config) {
fs.StringVar(&config.IcingaCommand, "icingacmd", "",
"Executes commands of Icinga PowerShell Framework (e.g. Invoke-IcingaCheckCPU)")

fs.StringVar(&config.AuthType, "auth", AuthDefault, "Authentication mechanism - NTLM | SSH")
fs.StringVar(&config.AuthType, "auth", AuthDefault, "Authentication mechanism - Basic, NTLM, TLS, SSH")

// AuthSSH
fs.StringVar(&config.SSHHost, "sshhost", "", "SSH Host (mandatory if --auth=SSH)")
Expand Down Expand Up @@ -136,6 +136,10 @@ func (c *Config) Validate() (err error) {
}

// AuthType
if c.AuthType == "" {
c.AuthType = AuthDefault
}

auth := strings.ToLower(c.AuthType)
switch auth {
case AuthBasic, AuthNTLM:
Expand All @@ -147,8 +151,6 @@ func (c *Config) Validate() (err error) {
if c.SSHHost == "" || c.SSHUser == "" || c.SSHPassword == "" {
return fmt.Errorf("please specify host, user and port for auth type: %s", c.AuthType)
}
case "":
auth = AuthDefault
default:
return fmt.Errorf("invalid auth type specified: %s", c.AuthType)
}
Expand Down
2 changes: 1 addition & 1 deletion check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestConfig_Validate(t *testing.T) {
assert.NoError(t, c.Validate())
assert.Equal(t, c.Port, TlsPort)
assert.False(t, c.NoTls)
assert.Equal(t, c.AuthType, AuthBasic)
assert.Equal(t, c.AuthType, AuthDefault)
assert.True(t, c.validated)
}

Expand Down