Fix tests
This commit is contained in:
parent
5ee1951f03
commit
1441449b81
|
|
@ -72,7 +72,7 @@ func (p *CIDAASProvider) EnrichSession(ctx context.Context, s *sessions.SessionS
|
||||||
|
|
||||||
// Try to get missing emails or groups from a profileURL
|
// Try to get missing emails or groups from a profileURL
|
||||||
if err := p.enrichFromUserinfoEndpoint(ctx, s); err != nil {
|
if err := p.enrichFromUserinfoEndpoint(ctx, s); err != nil {
|
||||||
logger.Errorf("Warning: Profile URL request failed: %w", err)
|
logger.Errorf("Warning: Profile URL request failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a mandatory email wasn't set, error at this point.
|
// If a mandatory email wasn't set, error at this point.
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
@ -46,8 +47,11 @@ func newCidaasProvider(serverURL *url.URL) *CIDAASProvider {
|
||||||
&oidc.Config{ClientID: oidcClientID},
|
&oidc.Config{ClientID: oidcClientID},
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
cfg := options.Provider{
|
||||||
|
Type: options.CidaasProvider,
|
||||||
|
}
|
||||||
|
|
||||||
p := NewCIDAASProvider(providerData)
|
p := NewCIDAASProvider(providerData, cfg)
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
@ -394,7 +398,11 @@ func TestCidaasProvider_EnrichSession(t *testing.T) {
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
err = provider.EnrichSession(context.Background(), tc.ExistingSession)
|
err = provider.EnrichSession(context.Background(), tc.ExistingSession)
|
||||||
assert.Equal(t, tc.ExpectedError, err)
|
if tc.ExpectedError != nil {
|
||||||
|
assert.EqualError(t, err, tc.ExpectedError.Error())
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
assert.Equal(t, *tc.ExpectedSession, *tc.ExistingSession)
|
assert.Equal(t, *tc.ExpectedSession, *tc.ExistingSession)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -471,7 +479,11 @@ func TestCidaasProvider_RefreshSession(t *testing.T) {
|
||||||
var refreshed bool
|
var refreshed bool
|
||||||
refreshed, err = provider.RefreshSession(context.Background(), tc.ExistingSession)
|
refreshed, err = provider.RefreshSession(context.Background(), tc.ExistingSession)
|
||||||
|
|
||||||
assert.Equal(t, tc.ExpectedError, err)
|
if tc.ExpectedError != nil {
|
||||||
|
assert.EqualError(t, err, tc.ExpectedError.Error())
|
||||||
|
} else {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
assert.Equal(t, tc.ExpectedRefreshed, refreshed)
|
assert.Equal(t, tc.ExpectedRefreshed, refreshed)
|
||||||
assert.Equal(t, tc.ExpectedEmail, tc.ExistingSession.Email)
|
assert.Equal(t, tc.ExpectedEmail, tc.ExistingSession.Email)
|
||||||
assert.Equal(t, tc.ExpectedUser, tc.ExistingSession.User)
|
assert.Equal(t, tc.ExpectedUser, tc.ExistingSession.User)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue