mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-01-10 04:18:14 +02:00
3fa42edb73
* fix import path for v7 find ./ -name "*.go" | xargs sed -i -e 's|"github.com/oauth2-proxy/oauth2-proxy|"github.com/oauth2-proxy/oauth2-proxy/v7|' * fix module path * go mod tidy * fix installation docs * update CHANGELOG * Update CHANGELOG.md Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk> Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package providers
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/sessions"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRefresh(t *testing.T) {
|
|
p := &ProviderData{}
|
|
|
|
expires := time.Now().Add(time.Duration(-11) * time.Minute)
|
|
refreshed, err := p.RefreshSessionIfNeeded(context.Background(), &sessions.SessionState{
|
|
ExpiresOn: &expires,
|
|
})
|
|
assert.Equal(t, false, refreshed)
|
|
assert.Equal(t, nil, err)
|
|
}
|
|
|
|
func TestAcrValuesNotConfigured(t *testing.T) {
|
|
p := &ProviderData{
|
|
LoginURL: &url.URL{
|
|
Scheme: "http",
|
|
Host: "my.test.idp",
|
|
Path: "/oauth/authorize",
|
|
},
|
|
}
|
|
|
|
result := p.GetLoginURL("https://my.test.app/oauth", "")
|
|
assert.NotContains(t, result, "acr_values")
|
|
}
|
|
|
|
func TestAcrValuesConfigured(t *testing.T) {
|
|
p := &ProviderData{
|
|
LoginURL: &url.URL{
|
|
Scheme: "http",
|
|
Host: "my.test.idp",
|
|
Path: "/oauth/authorize",
|
|
},
|
|
AcrValues: "testValue",
|
|
}
|
|
|
|
result := p.GetLoginURL("https://my.test.app/oauth", "")
|
|
assert.Contains(t, result, "acr_values=testValue")
|
|
}
|