mirror of
https://github.com/wahyd4/loginsrv.git
synced 2026-08-09 04:46:29 +10:00
enhanced testcoverage of httpupstream
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user