From 624c2d9d84706f918267d11a2213a2b4c86266db Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:43:12 +0100 Subject: [PATCH] chore: synchronize workspaces --- ...d_call_refresh_token_hook_if_configured-hook=new.json | 6 +++++- oauth2/oauth2_auth_code_test.go | 2 +- oauth2/oauth2_jwt_bearer_test.go | 9 +++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/oauth2/.snapshots/TestAuthCodeWithMockStrategy-strategy=opaque-case=0-description=should_pass_request_if_strategy_passes-should_call_refresh_token_hook_if_configured-hook=new.json b/oauth2/.snapshots/TestAuthCodeWithMockStrategy-strategy=opaque-case=0-description=should_pass_request_if_strategy_passes-should_call_refresh_token_hook_if_configured-hook=new.json index 1133cbe7f21..3748c3744f1 100644 --- a/oauth2/.snapshots/TestAuthCodeWithMockStrategy-strategy=opaque-case=0-description=should_pass_request_if_strategy_passes-should_call_refresh_token_hook_if_configured-hook=new.json +++ b/oauth2/.snapshots/TestAuthCodeWithMockStrategy-strategy=opaque-case=0-description=should_pass_request_if_strategy_passes-should_call_refresh_token_hook_if_configured-hook=new.json @@ -44,6 +44,10 @@ "grant_types": [ "refresh_token" ], - "payload": {} + "payload": { + "grant_type": [ + "refresh_token" + ] + } } } diff --git a/oauth2/oauth2_auth_code_test.go b/oauth2/oauth2_auth_code_test.go index 274f70181b7..9ea6e8f6a10 100644 --- a/oauth2/oauth2_auth_code_test.go +++ b/oauth2/oauth2_auth_code_test.go @@ -1667,7 +1667,7 @@ func TestAuthCodeWithMockStrategy(t *testing.T) { require.Equal(t, hookReq.Request.ClientID, oauthConfig.ClientID) require.ElementsMatch(t, hookReq.Request.GrantedScopes, expectedGrantedScopes) require.ElementsMatch(t, hookReq.Request.GrantedAudience, []string{}) - require.Equal(t, hookReq.Request.Payload, map[string][]string{}) + require.Equal(t, hookReq.Request.Payload, map[string][]string{"grant_type": {"refresh_token"}}) snapshotx.SnapshotT(t, hookReq, snapshotx.ExceptPaths(exceptKeys...)) } diff --git a/oauth2/oauth2_jwt_bearer_test.go b/oauth2/oauth2_jwt_bearer_test.go index 3931b72ac2b..0f5e4a7a8b8 100644 --- a/oauth2/oauth2_jwt_bearer_test.go +++ b/oauth2/oauth2_jwt_bearer_test.go @@ -335,7 +335,7 @@ func TestJWTBearer(t *testing.T) { require.NotEmpty(t, hookReq.Request) require.ElementsMatch(t, hookReq.Request.GrantedScopes, expectedGrantedScopes) require.ElementsMatch(t, hookReq.Request.GrantedAudience, expectedGrantedAudience) - require.Equal(t, hookReq.Request.Payload, expectedPayload) + require.Equal(t, expectedPayload, hookReq.Request.Payload) claims := map[string]interface{}{ "hooked": true, @@ -401,7 +401,12 @@ func TestJWTBearer(t *testing.T) { expectedGrantedScopes := []string{client.Scope} expectedGrantedAudience := []string{audience} - expectedPayload := map[string][]string(map[string][]string{"assertion": {token}}) + expectedPayload := map[string][]string{ + "assertion": {token}, + "client_id": {client.GetID()}, + "grant_type": {"urn:ietf:params:oauth:grant-type:jwt-bearer"}, + "scope": {"offline_access"}, + } var hookReq hydraoauth2.TokenHookRequest require.NoError(t, json.NewDecoder(r.Body).Decode(&hookReq))