-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from Versent/refactor_package_providers
refactor(Providers) Move providers into their own tree.
- Loading branch information
Showing
22 changed files
with
160 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package creds | ||
|
||
import "errors" | ||
|
||
// LoginDetails used to authenticate | ||
type LoginDetails struct { | ||
Username string | ||
Password string | ||
Hostname string | ||
} | ||
|
||
// Validate validate the login details | ||
func (ld *LoginDetails) Validate() error { | ||
if ld.Hostname == "" { | ||
return errors.New("Empty hostname") | ||
} | ||
if ld.Username == "" { | ||
return errors.New("Empty username") | ||
} | ||
if ld.Password == "" { | ||
return errors.New("Empty password") | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package creds | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestValidateEmptyLoginDetails(t *testing.T) { | ||
|
||
ld := &LoginDetails{} | ||
|
||
err := ld.Validate() | ||
|
||
require.Error(t, err) | ||
} | ||
func TestValidateEmptyHostnameLoginDetails(t *testing.T) { | ||
|
||
ld := &LoginDetails{Username: "test", Password: "test"} | ||
|
||
err := ld.Validate() | ||
|
||
require.Error(t, err) | ||
|
||
} | ||
|
||
func TestValidateEmptyUsernameLoginDetails(t *testing.T) { | ||
|
||
ld := &LoginDetails{Hostname: "test", Password: "test"} | ||
|
||
err := ld.Validate() | ||
|
||
require.Error(t, err) | ||
|
||
} | ||
func TestValidateEmptyPasswordLoginDetails(t *testing.T) { | ||
|
||
ld := &LoginDetails{Hostname: "test", Username: "test"} | ||
|
||
err := ld.Validate() | ||
|
||
require.Error(t, err) | ||
} | ||
|
||
func TestValidateLoginDetails(t *testing.T) { | ||
|
||
ld := &LoginDetails{Hostname: "test", Username: "test", Password: "test"} | ||
|
||
err := ld.Validate() | ||
|
||
require.Nil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.