Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nsklikas committed Sep 17, 2024
1 parent 27dcafa commit 095a49b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions consent/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ func TestAcceptDeviceRequest(t *testing.T) {

deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, sig, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
reg.OAuth2Storage().CreateUserCodeSession(ctx, sig, deviceRequest)
Expand Down Expand Up @@ -395,6 +403,14 @@ func TestAcceptDuplicateDeviceRequest(t *testing.T) {

deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, sig, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
reg.OAuth2Storage().CreateUserCodeSession(ctx, sig, deviceRequest)
Expand Down Expand Up @@ -478,6 +494,14 @@ func TestAcceptCodeDeviceRequestFailure(t *testing.T) {
getBody: func() ([]byte, error) {
deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, _, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
return json.Marshal(&hydra.AcceptDeviceUserCodeRequest{UserCode: &userCode})
Expand All @@ -494,6 +518,14 @@ func TestAcceptCodeDeviceRequestFailure(t *testing.T) {
getBody: func() ([]byte, error) {
deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode := ""
return json.Marshal(&hydra.AcceptDeviceUserCodeRequest{UserCode: &userCode})
},
Expand All @@ -509,6 +541,14 @@ func TestAcceptCodeDeviceRequestFailure(t *testing.T) {
getBody: func() ([]byte, error) {
deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, _, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
return json.Marshal(&hydra.AcceptDeviceUserCodeRequest{UserCode: &userCode})
Expand All @@ -525,6 +565,14 @@ func TestAcceptCodeDeviceRequestFailure(t *testing.T) {
getBody: func() ([]byte, error) {
deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, _, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
return json.Marshal(&hydra.AcceptDeviceUserCodeRequest{UserCode: &userCode})
Expand All @@ -541,6 +589,14 @@ func TestAcceptCodeDeviceRequestFailure(t *testing.T) {
getBody: func() ([]byte, error) {
deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, sig, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
deviceRequest.SetSession(
Expand Down Expand Up @@ -572,6 +628,14 @@ func TestAcceptCodeDeviceRequestFailure(t *testing.T) {
getBody: func() ([]byte, error) {
deviceRequest := fosite.NewDeviceRequest()
deviceRequest.Client = cl
deviceRequest.SetSession(
&oauth2.Session{
DefaultSession: &openid.DefaultSession{
Headers: &jwt.Headers{},
},
BrowserFlowCompleted: false,
},
)
userCode, _, err := reg.RFC8628HMACStrategy().GenerateUserCode(ctx)
require.NoError(t, err)
ret := struct {
Expand Down
2 changes: 1 addition & 1 deletion flow/.snapshots/TestOAuth2ConsentRequest_MarshalJSON.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"{\"challenge\":\"\",\"requested_scope\":[],\"requested_access_token_audience\":[],\"skip\":false,\"subject\":\"\",\"oidc_context\":null,\"client\":null,\"request_url\":\"\",\"login_challenge\":\"\",\"login_session_id\":\"\",\"acr\":\"\",\"amr\":[]}"
"{\"challenge\":\"\",\"requested_scope\":[],\"requested_access_token_audience\":[],\"skip\":false,\"subject\":\"\",\"oidc_context\":null,\"client\":null,\"request_url\":\"\",\"login_challenge\":\"\",\"login_session_id\":\"\",\"device_challenge_id\":\"\",\"acr\":\"\",\"amr\":[]}"

0 comments on commit 095a49b

Please sign in to comment.