add test
This commit is contained in:
parent
32ff570f7c
commit
59bd5643e6
2 changed files with 37 additions and 0 deletions
|
@ -164,6 +164,15 @@ func authRequestToInternal(authReq *oidc.AuthRequest, userID string) *AuthReques
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AuthRequestWithSessionState struct {
|
||||||
|
*AuthRequest
|
||||||
|
SessionState string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AuthRequestWithSessionState) GetSessionState() string {
|
||||||
|
return a.SessionState
|
||||||
|
}
|
||||||
|
|
||||||
type OIDCCodeChallenge struct {
|
type OIDCCodeChallenge struct {
|
||||||
Challenge string
|
Challenge string
|
||||||
Method string
|
Method string
|
||||||
|
|
|
@ -1090,6 +1090,34 @@ func TestAuthResponseCode(t *testing.T) {
|
||||||
wantBody: "",
|
wantBody: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "success with state and session_state",
|
||||||
|
args: args{
|
||||||
|
authReq: &storage.AuthRequestWithSessionState{
|
||||||
|
AuthRequest: &storage.AuthRequest{
|
||||||
|
ID: "id1",
|
||||||
|
TransferState: "state1",
|
||||||
|
},
|
||||||
|
SessionState: "session_state1",
|
||||||
|
},
|
||||||
|
authorizer: func(t *testing.T) op.Authorizer {
|
||||||
|
ctrl := gomock.NewController(t)
|
||||||
|
storage := mock.NewMockStorage(ctrl)
|
||||||
|
storage.EXPECT().SaveAuthCode(gomock.Any(), "id1", "id1")
|
||||||
|
|
||||||
|
authorizer := mock.NewMockAuthorizer(ctrl)
|
||||||
|
authorizer.EXPECT().Storage().Return(storage)
|
||||||
|
authorizer.EXPECT().Crypto().Return(&mockCrypto{})
|
||||||
|
authorizer.EXPECT().Encoder().Return(schema.NewEncoder())
|
||||||
|
return authorizer
|
||||||
|
},
|
||||||
|
},
|
||||||
|
res: res{
|
||||||
|
wantCode: http.StatusFound,
|
||||||
|
wantLocationHeader: "/auth/callback/?code=id1&session_state=session_state1&state=state1",
|
||||||
|
wantBody: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "success without state", // reproduce issue #415
|
name: "success without state", // reproduce issue #415
|
||||||
args: args{
|
args: args{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue