renaming
This commit is contained in:
parent
720fe28f70
commit
4b2f7c9de4
5 changed files with 63 additions and 58 deletions
|
@ -1,47 +0,0 @@
|
|||
package server
|
||||
|
||||
// import (
|
||||
// "net/http"
|
||||
// "net/http/httptest"
|
||||
// "testing"
|
||||
|
||||
// "github.com/stretchr/testify/require"
|
||||
|
||||
// "github.com/caos/oidc/pkg/oidc"
|
||||
// )
|
||||
|
||||
// func TestDefaultHandler_HandleDiscovery(t *testing.T) {
|
||||
// type fields struct {
|
||||
// config *Config
|
||||
// discoveryConfig *oidc.DiscoveryConfiguration
|
||||
// storage Storage
|
||||
// http *http.Server
|
||||
// }
|
||||
// type args struct {
|
||||
// w http.ResponseWriter
|
||||
// r *http.Request
|
||||
// }
|
||||
// tests := []struct {
|
||||
// name string
|
||||
// fields fields
|
||||
// args args
|
||||
// want string
|
||||
// wantCode int
|
||||
// }{
|
||||
// {"OK", fields{config: nil, discoveryConfig: &oidc.DiscoveryConfiguration{Issuer: "test"}}, args{httptest.NewRecorder(), nil}, `{"issuer":"test"}`, 200},
|
||||
// }
|
||||
// for _, tt := range tests {
|
||||
// t.Run(tt.name, func(t *testing.T) {
|
||||
// h := &DefaultHandler{
|
||||
// config: tt.fields.config,
|
||||
// discoveryConfig: tt.fields.discoveryConfig,
|
||||
// storage: tt.fields.storage,
|
||||
// http: tt.fields.http,
|
||||
// }
|
||||
// h.HandleDiscovery(tt.args.w, tt.args.r)
|
||||
// rec := tt.args.w.(*httptest.ResponseRecorder)
|
||||
// require.Equal(t, tt.want, rec.Body.String())
|
||||
// require.Equal(t, tt.wantCode, rec.Code)
|
||||
// })
|
||||
// }
|
||||
// }
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
type DefaultOP struct {
|
||||
config *Config
|
||||
endpoints endpoints
|
||||
endpoints *endpoints
|
||||
discoveryConfig *oidc.DiscoveryConfiguration
|
||||
storage Storage
|
||||
http *http.Server
|
||||
|
@ -85,11 +85,11 @@ func CreateDiscoveryConfig(c Configuration) *oidc.DiscoveryConfiguration {
|
|||
Issuer: c.Issuer(),
|
||||
AuthorizationEndpoint: c.AuthorizationEndpoint().Absolute(c.Issuer()),
|
||||
TokenEndpoint: c.TokenEndpoint().Absolute(c.Issuer()),
|
||||
// IntrospectionEndpoint: c.absoluteEndpoint(c.IntrospectionEndpoint),
|
||||
// UserinfoEndpoint: c.absoluteEndpoint(c.UserinfoEndpoint),
|
||||
// EndSessionEndpoint: c.absoluteEndpoint(c.EndSessionEndpoint),
|
||||
// CheckSessionIframe: c.absoluteEndpoint(c.CheckSessionIframe),
|
||||
// JwksURI: c.absoluteEndpoint(c.JwksURI),
|
||||
// IntrospectionEndpoint: c.Intro().Absolute(c.Issuer()),
|
||||
UserinfoEndpoint: c.UserinfoEndpoint().Absolute(c.Issuer()),
|
||||
// EndSessionEndpoint: c.TokenEndpoint().Absolute(c.Issuer())(c.EndSessionEndpoint),
|
||||
// CheckSessionIframe: c.TokenEndpoint().Absolute(c.Issuer())(c.CheckSessionIframe),
|
||||
// JwksURI: c.TokenEndpoint().Absolute(c.Issuer())(c.JwksURI),
|
||||
// ScopesSupported: oidc.SupportedScopes,
|
||||
// ResponseTypesSupported: responseTypes,
|
||||
// GrantTypesSupported: oidc.SupportedGrantTypes,
|
||||
|
@ -101,7 +101,7 @@ func CreateDiscoveryConfig(c Configuration) *oidc.DiscoveryConfiguration {
|
|||
}
|
||||
}
|
||||
|
||||
var DefaultEndpoints = endpoints{
|
||||
var DefaultEndpoints = &endpoints{
|
||||
Authorization: defaultAuthorizationEndpoint,
|
||||
Token: defaulTokenEndpoint,
|
||||
IntrospectionEndpoint: defaultIntrospectEndpoint,
|
||||
|
@ -194,10 +194,10 @@ func (p *DefaultOP) HandleAuthorize(w http.ResponseWriter, r *http.Request) {
|
|||
// //TODO: return err
|
||||
// }
|
||||
}
|
||||
err = p.storage.CreateAuthRequest(authRequest)
|
||||
if err != nil {
|
||||
//TODO: return err
|
||||
}
|
||||
// err = p.storage.CreateAuthRequest(authRequest)
|
||||
// if err != nil {
|
||||
// //TODO: return err
|
||||
// }
|
||||
//TODO: redirect?
|
||||
}
|
||||
|
||||
|
|
49
pkg/op/default_op_test.go
Normal file
49
pkg/op/default_op_test.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/caos/oidc/pkg/oidc"
|
||||
)
|
||||
|
||||
func TestDefaultOP_HandleDiscovery(t *testing.T) {
|
||||
type fields struct {
|
||||
config *Config
|
||||
endpoints *endpoints
|
||||
discoveryConfig *oidc.DiscoveryConfiguration
|
||||
storage Storage
|
||||
http *http.Server
|
||||
}
|
||||
type args struct {
|
||||
w http.ResponseWriter
|
||||
r *http.Request
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want string
|
||||
wantCode int
|
||||
}{
|
||||
{"OK", fields{config: nil, endpoints: nil, discoveryConfig: &oidc.DiscoveryConfiguration{Issuer: "https://issuer.com"}}, args{httptest.NewRecorder(), nil}, `{"issuer":"https://issuer.com"}`, 200},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := &DefaultOP{
|
||||
config: tt.fields.config,
|
||||
endpoints: tt.fields.endpoints,
|
||||
discoveryConfig: tt.fields.discoveryConfig,
|
||||
storage: tt.fields.storage,
|
||||
http: tt.fields.http,
|
||||
}
|
||||
p.HandleDiscovery(tt.args.w, tt.args.r)
|
||||
rec := tt.args.w.(*httptest.ResponseRecorder)
|
||||
require.Equal(t, tt.want, rec.Body.String())
|
||||
require.Equal(t, tt.wantCode, rec.Code)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -3,5 +3,8 @@ package server
|
|||
import "github.com/caos/oidc/pkg/oidc"
|
||||
|
||||
func NeedsExistingSession(authRequest *oidc.AuthRequest) bool {
|
||||
if authRequest == nil {
|
||||
return true
|
||||
}
|
||||
return authRequest.IDTokenHint != "" //TODO: impl: https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.2
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue