loginsrv

Unnamed repository; edit this file 'description' to name the repository.
git clone git@jamesshield.xyz:repos/loginsrv.git
Log | Files | Refs | README | LICENSE

commit 7ceb900c37ac44d9abc444eda048d6bbccd3cba0
parent c6291ca7e9a5c99f8bd7c119d189ce03d6c98556
Author: Sebastian Mancke <s.mancke@tarent.de>
Date:   Fri,  9 Jun 2017 22:24:21 +0200

enhanced testcoverage of httpupstream

Diffstat:
MREADME.md | 8++++----
Mhttpupstream/auth_test.go | 22+++++++++++++++++++++-
Mhttpupstream/backend_test.go | 9+++++++++
3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md @@ -195,7 +195,7 @@ Parameters for the provider: Example: ``` -loginsrv -backend 'provider=htpasswd,file=users +loginsrv -htpasswd file=users ``` ### Httpupstream @@ -210,7 +210,7 @@ Parameters for the provider: Example: ``` -loginsrv -backend 'provider=httpupstream,upstream=https://google.com,timeout=1s' +loginsrv -httpupstream upstream=https://google.com,timeout=1s ``` ### OSIAM @@ -219,7 +219,7 @@ It implements the multiple OAuth2 flows, as well as SCIM for managing the user d To start loginsrv against the default OSIAM configuration on the same machine, use the following example. ``` -loginsrv --jwt-secret=jwtsecret --text-logging -backend 'provider=osiam,endpoint=http://localhost:8080,clientId=example-client,clientSecret=secret' +loginsrv --jwt-secret=jwtsecret --text-logging -osiam endpoint=http://localhost:8080,client_id=example-client,client_secret=secret' ``` Then go to http://127.0.0.1:6789/login and login with `admin/koala`. @@ -229,7 +229,7 @@ Simple is a demo provider for testing only. It holds a user/password table in me Example ``` -loginsrv -backend provider=simple,bob=secret +loginsrv -simple bob=secret ``` ## Oauth2 diff --git a/httpupstream/auth_test.go b/httpupstream/auth_test.go @@ -44,5 +44,25 @@ func TestAuth_ValidCredentials(t *testing.T) { authenticated, err := auth.Authenticate("bob-bcrypt", "secret") NoError(t, err) - False(t, authenticated) + True(t, authenticated) +} + +func TestAuth_InvalidUrl(t *testing.T) { + invalidUrl := &url.URL{Scheme: "\\\\"} + + auth, err := NewAuth(invalidUrl, time.Second, false) + NoError(t, err) + + _, err = auth.Authenticate("foo", "bar") + Error(t, err) +} + +func TestAuth_InvalidHost(t *testing.T) { + invalidServer, _ := url.Parse("http://0.0.0.0.0") + + auth, err := NewAuth(invalidServer, time.Second, false) + NoError(t, err) + + _, err = auth.Authenticate("foo", "bar") + Error(t, err) } diff --git a/httpupstream/backend_test.go b/httpupstream/backend_test.go @@ -62,6 +62,15 @@ func TestSetup_Error(t *testing.T) { _, err := p(map[string]string{}) Error(t, err) + + _, err = p(map[string]string{"upstream": ":invalid-url"}) + Error(t, err) + + _, err = p(map[string]string{"upstream": "http://example.com", "timeout": "some-string"}) + Error(t, err) + + _, err = p(map[string]string{"upstream": "http://example.com", "skipverify": "some-string"}) + Error(t, err) } func TestSimpleBackend_Authenticate(t *testing.T) {