fixes for token endpoint

This commit is contained in:
Livio Amstutz 2019-12-16 14:10:43 +01:00
parent 20a90c71d9
commit a21f6745f7
12 changed files with 192 additions and 146 deletions

View file

@ -31,7 +31,7 @@ func NewMockStorageAny(t *testing.T) op.Storage {
m := NewStorage(t)
mockS := m.(*MockStorage)
mockS.EXPECT().GetClientByClientID(gomock.Any()).AnyTimes().Return(&ConfClient{}, nil)
mockS.EXPECT().AuthorizeClientIDSecret(gomock.Any(), gomock.Any()).AnyTimes().Return(&ConfClient{}, nil)
mockS.EXPECT().AuthorizeClientIDSecret(gomock.Any(), gomock.Any()).AnyTimes().Return(nil)
return m
}
@ -62,15 +62,19 @@ func ExpectValidClientID(s op.Storage) {
mockS.EXPECT().GetClientByClientID(gomock.Any()).DoAndReturn(
func(id string) (op.Client, error) {
var appType op.ApplicationType
var authMethod op.AuthMethod
switch id {
case "web_client":
appType = op.ApplicationTypeWeb
authMethod = op.AuthMethodBasic
case "native_client":
appType = op.ApplicationTypeNative
authMethod = op.AuthMethodNone
case "useragent_client":
appType = op.ApplicationTypeUserAgent
authMethod = op.AuthMethodBasic
}
return &ConfClient{appType: appType}, nil
return &ConfClient{id: id, appType: appType, authMethod: authMethod}, nil
})
}
@ -90,7 +94,9 @@ func ExpectSigningKey(s op.Storage) {
}
type ConfClient struct {
appType op.ApplicationType
id string
appType op.ApplicationType
authMethod op.AuthMethod
}
func (c *ConfClient) RedirectURIs() []string {
@ -109,3 +115,11 @@ func (c *ConfClient) LoginURL(id string) string {
func (c *ConfClient) ApplicationType() op.ApplicationType {
return c.appType
}
func (c *ConfClient) GetAuthMethod() op.AuthMethod {
return c.authMethod
}
func (c *ConfClient) GetID() string {
return c.id
}