aboutsummaryrefslogtreecommitdiff
path: root/server/auth/github/github_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/auth/github/github_test.go')
-rw-r--r--server/auth/github/github_test.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/server/auth/github/github_test.go b/server/auth/github/github_test.go
index 383642f..f50d134 100644
--- a/server/auth/github/github_test.go
+++ b/server/auth/github/github_test.go
@@ -19,7 +19,7 @@ var (
func TestNew(t *testing.T) {
a := assert.New(t)
- p := newGithub()
+ p, _ := newGithub()
g := p.(*Config)
a.Equal(g.config.ClientID, oauthClientID)
a.Equal(g.config.ClientSecret, oauthClientSecret)
@@ -27,10 +27,20 @@ func TestNew(t *testing.T) {
a.Equal(g.organization, organization)
}
+func TestNewEmptyOrganization(t *testing.T) {
+ organization = ""
+ a := assert.New(t)
+
+ _, err := newGithub()
+ a.EqualError(err, "github_opts organization must not be empty")
+
+ organization = "exampleorg"
+}
+
func TestStartSession(t *testing.T) {
a := assert.New(t)
- p := newGithub()
+ p, _ := newGithub()
s := p.StartSession("test_state")
a.Equal(s.State, "test_state")
a.Contains(s.AuthURL, "github.com/login/oauth/authorize")
@@ -38,7 +48,7 @@ func TestStartSession(t *testing.T) {
a.Contains(s.AuthURL, fmt.Sprintf("client_id=%s", oauthClientID))
}
-func newGithub() auth.Provider {
+func newGithub() (auth.Provider, error) {
c := &config.Auth{
OauthClientID: oauthClientID,
OauthClientSecret: oauthClientSecret,