github.com/prebid/prebid-server@v0.275.0/hooks/hookexecution/mocks_test.go (about)

     1  package hookexecution
     2  
     3  import (
     4  	"context"
     5  	"errors"
     6  	"time"
     7  
     8  	"github.com/prebid/prebid-server/hooks/hookstage"
     9  	"github.com/prebid/prebid-server/openrtb_ext"
    10  )
    11  
    12  type mockUpdateHeaderEntrypointHook struct{}
    13  
    14  func (e mockUpdateHeaderEntrypointHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
    15  	c := hookstage.ChangeSet[hookstage.EntrypointPayload]{}
    16  	c.AddMutation(func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
    17  		payload.Request.Header.Add("foo", "bar")
    18  		return payload, nil
    19  	}, hookstage.MutationUpdate, "header", "foo")
    20  
    21  	return hookstage.HookResult[hookstage.EntrypointPayload]{ChangeSet: c}, nil
    22  }
    23  
    24  type mockUpdateQueryEntrypointHook struct{}
    25  
    26  func (e mockUpdateQueryEntrypointHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
    27  	c := hookstage.ChangeSet[hookstage.EntrypointPayload]{}
    28  	c.AddMutation(func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
    29  		params := payload.Request.URL.Query()
    30  		params.Add("foo", "baz")
    31  		payload.Request.URL.RawQuery = params.Encode()
    32  		return payload, nil
    33  	}, hookstage.MutationUpdate, "param", "foo")
    34  
    35  	return hookstage.HookResult[hookstage.EntrypointPayload]{ChangeSet: c}, nil
    36  }
    37  
    38  type mockUpdateBodyHook struct{}
    39  
    40  func (e mockUpdateBodyHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
    41  	c := hookstage.ChangeSet[hookstage.EntrypointPayload]{}
    42  	c.AddMutation(
    43  		func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
    44  			payload.Body = []byte(`{"name": "John", "last_name": "Doe", "foo": "bar"}`)
    45  			return payload, nil
    46  		}, hookstage.MutationUpdate, "body", "foo",
    47  	).AddMutation(
    48  		func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
    49  			payload.Body = []byte(`{"last_name": "Doe", "foo": "bar"}`)
    50  			return payload, nil
    51  		}, hookstage.MutationDelete, "body", "name",
    52  	)
    53  
    54  	return hookstage.HookResult[hookstage.EntrypointPayload]{ChangeSet: c}, nil
    55  }
    56  
    57  func (e mockUpdateBodyHook) HandleRawAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
    58  	c := hookstage.ChangeSet[hookstage.RawAuctionRequestPayload]{}
    59  	c.AddMutation(
    60  		func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) {
    61  			payload = []byte(`{"name": "John", "last_name": "Doe", "foo": "bar"}`)
    62  			return payload, nil
    63  		}, hookstage.MutationUpdate, "body", "foo",
    64  	).AddMutation(
    65  		func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) {
    66  			payload = []byte(`{"last_name": "Doe", "foo": "bar"}`)
    67  			return payload, nil
    68  		}, hookstage.MutationDelete, "body", "name",
    69  	)
    70  
    71  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{ChangeSet: c}, nil
    72  }
    73  
    74  type mockRejectHook struct{}
    75  
    76  func (e mockRejectHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
    77  	return hookstage.HookResult[hookstage.EntrypointPayload]{Reject: true}, nil
    78  }
    79  
    80  func (e mockRejectHook) HandleRawAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
    81  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{Reject: true}, nil
    82  }
    83  
    84  func (e mockRejectHook) HandleProcessedAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.ProcessedAuctionRequestPayload) (hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload], error) {
    85  	return hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload]{Reject: true}, nil
    86  }
    87  
    88  func (e mockRejectHook) HandleBidderRequestHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
    89  	return hookstage.HookResult[hookstage.BidderRequestPayload]{Reject: true}, nil
    90  }
    91  
    92  func (e mockRejectHook) HandleRawBidderResponseHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawBidderResponsePayload) (hookstage.HookResult[hookstage.RawBidderResponsePayload], error) {
    93  	return hookstage.HookResult[hookstage.RawBidderResponsePayload]{Reject: true}, nil
    94  }
    95  
    96  func (e mockRejectHook) HandleAllProcessedBidResponsesHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
    97  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{Reject: true}, nil
    98  }
    99  
   100  func (e mockRejectHook) HandleAuctionResponseHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AuctionResponsePayload) (hookstage.HookResult[hookstage.AuctionResponsePayload], error) {
   101  	return hookstage.HookResult[hookstage.AuctionResponsePayload]{Reject: true}, nil
   102  }
   103  
   104  type mockTimeoutHook struct{}
   105  
   106  func (e mockTimeoutHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
   107  	time.Sleep(20 * time.Millisecond)
   108  	c := hookstage.ChangeSet[hookstage.EntrypointPayload]{}
   109  	c.AddMutation(func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
   110  		params := payload.Request.URL.Query()
   111  		params.Add("bar", "foo")
   112  		payload.Request.URL.RawQuery = params.Encode()
   113  		return payload, nil
   114  	}, hookstage.MutationUpdate, "param", "bar")
   115  
   116  	return hookstage.HookResult[hookstage.EntrypointPayload]{ChangeSet: c}, nil
   117  }
   118  
   119  func (e mockTimeoutHook) HandleRawAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
   120  	time.Sleep(20 * time.Millisecond)
   121  	c := hookstage.ChangeSet[hookstage.RawAuctionRequestPayload]{}
   122  	c.AddMutation(func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) {
   123  		payload = []byte(`{"last_name": "Doe", "foo": "bar", "address": "A st."}`)
   124  		return payload, nil
   125  	}, hookstage.MutationUpdate, "param", "address")
   126  
   127  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{ChangeSet: c}, nil
   128  }
   129  
   130  func (e mockTimeoutHook) HandleProcessedAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.ProcessedAuctionRequestPayload) (hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload], error) {
   131  	time.Sleep(20 * time.Millisecond)
   132  	c := hookstage.ChangeSet[hookstage.ProcessedAuctionRequestPayload]{}
   133  	c.AddMutation(func(payload hookstage.ProcessedAuctionRequestPayload) (hookstage.ProcessedAuctionRequestPayload, error) {
   134  		payload.RequestWrapper.User.CustomData = "some-custom-data"
   135  		return payload, nil
   136  	}, hookstage.MutationUpdate, "bidRequest", "user.customData")
   137  
   138  	return hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload]{ChangeSet: c}, nil
   139  }
   140  
   141  func (e mockTimeoutHook) HandleBidderRequestHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
   142  	time.Sleep(20 * time.Millisecond)
   143  	c := hookstage.ChangeSet[hookstage.BidderRequestPayload]{}
   144  	c.AddMutation(func(payload hookstage.BidderRequestPayload) (hookstage.BidderRequestPayload, error) {
   145  		payload.BidRequest.User.CustomData = "some-custom-data"
   146  		return payload, nil
   147  	}, hookstage.MutationUpdate, "bidRequest", "user.customData")
   148  
   149  	return hookstage.HookResult[hookstage.BidderRequestPayload]{ChangeSet: c}, nil
   150  }
   151  
   152  func (e mockTimeoutHook) HandleRawBidderResponseHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawBidderResponsePayload) (hookstage.HookResult[hookstage.RawBidderResponsePayload], error) {
   153  	time.Sleep(20 * time.Millisecond)
   154  	c := hookstage.ChangeSet[hookstage.RawBidderResponsePayload]{}
   155  	c.AddMutation(func(payload hookstage.RawBidderResponsePayload) (hookstage.RawBidderResponsePayload, error) {
   156  		payload.Bids[0].BidMeta = &openrtb_ext.ExtBidPrebidMeta{AdapterCode: "new-code"}
   157  		return payload, nil
   158  	}, hookstage.MutationUpdate, "bidderResponse", "bidMeta.AdapterCode")
   159  
   160  	return hookstage.HookResult[hookstage.RawBidderResponsePayload]{ChangeSet: c}, nil
   161  }
   162  
   163  func (e mockTimeoutHook) HandleAllProcessedBidResponsesHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
   164  	time.Sleep(20 * time.Millisecond)
   165  	c := hookstage.ChangeSet[hookstage.AllProcessedBidResponsesPayload]{}
   166  	c.AddMutation(func(payload hookstage.AllProcessedBidResponsesPayload) (hookstage.AllProcessedBidResponsesPayload, error) {
   167  		payload.Responses["some-bidder"].Bids[0].BidMeta = &openrtb_ext.ExtBidPrebidMeta{AdapterCode: "new-code"}
   168  		return payload, nil
   169  	}, hookstage.MutationUpdate, "processedBidderResponse", "bidMeta.AdapterCode")
   170  
   171  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{ChangeSet: c}, nil
   172  }
   173  
   174  func (e mockTimeoutHook) HandleAuctionResponseHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AuctionResponsePayload) (hookstage.HookResult[hookstage.AuctionResponsePayload], error) {
   175  	time.Sleep(2 * time.Millisecond)
   176  	c := hookstage.ChangeSet[hookstage.AuctionResponsePayload]{}
   177  	c.AddMutation(func(payload hookstage.AuctionResponsePayload) (hookstage.AuctionResponsePayload, error) {
   178  		payload.BidResponse.Ext = []byte("another-byte")
   179  		return payload, nil
   180  	}, hookstage.MutationUpdate, "auctionResponse", "bidResponse.Ext")
   181  
   182  	return hookstage.HookResult[hookstage.AuctionResponsePayload]{ChangeSet: c}, nil
   183  }
   184  
   185  type mockModuleContextHook struct {
   186  	key, val string
   187  }
   188  
   189  func (e mockModuleContextHook) HandleEntrypointHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
   190  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   191  	return hookstage.HookResult[hookstage.EntrypointPayload]{ModuleContext: miCtx.ModuleContext}, nil
   192  }
   193  
   194  func (e mockModuleContextHook) HandleRawAuctionHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
   195  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   196  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{ModuleContext: miCtx.ModuleContext}, nil
   197  }
   198  
   199  func (e mockModuleContextHook) HandleProcessedAuctionHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.ProcessedAuctionRequestPayload) (hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload], error) {
   200  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   201  	return hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload]{ModuleContext: miCtx.ModuleContext}, nil
   202  }
   203  
   204  func (e mockModuleContextHook) HandleBidderRequestHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
   205  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   206  	return hookstage.HookResult[hookstage.BidderRequestPayload]{ModuleContext: miCtx.ModuleContext}, nil
   207  }
   208  
   209  func (e mockModuleContextHook) HandleRawBidderResponseHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.RawBidderResponsePayload) (hookstage.HookResult[hookstage.RawBidderResponsePayload], error) {
   210  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   211  	return hookstage.HookResult[hookstage.RawBidderResponsePayload]{ModuleContext: miCtx.ModuleContext}, nil
   212  }
   213  
   214  func (e mockModuleContextHook) HandleAllProcessedBidResponsesHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
   215  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   216  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{ModuleContext: miCtx.ModuleContext}, nil
   217  }
   218  
   219  func (e mockModuleContextHook) HandleAuctionResponseHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.AuctionResponsePayload) (hookstage.HookResult[hookstage.AuctionResponsePayload], error) {
   220  	miCtx.ModuleContext = map[string]interface{}{e.key: e.val}
   221  	return hookstage.HookResult[hookstage.AuctionResponsePayload]{ModuleContext: miCtx.ModuleContext}, nil
   222  }
   223  
   224  type mockFailureHook struct{}
   225  
   226  func (h mockFailureHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
   227  	return hookstage.HookResult[hookstage.EntrypointPayload]{}, FailureError{Message: "attribute not found"}
   228  }
   229  
   230  func (h mockFailureHook) HandleRawAuctionHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
   231  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{}, FailureError{Message: "attribute not found"}
   232  }
   233  
   234  func (h mockFailureHook) HandleBidderRequestHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
   235  	return hookstage.HookResult[hookstage.BidderRequestPayload]{}, FailureError{Message: "attribute not found"}
   236  }
   237  
   238  func (h mockFailureHook) HandleAllProcessedBidResponsesHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
   239  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{}, FailureError{Message: "attribute not found"}
   240  }
   241  
   242  type mockErrorHook struct{}
   243  
   244  func (h mockErrorHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
   245  	return hookstage.HookResult[hookstage.EntrypointPayload]{}, errors.New("unexpected error")
   246  }
   247  
   248  func (h mockErrorHook) HandleRawAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
   249  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{}, errors.New("unexpected error")
   250  }
   251  
   252  func (h mockErrorHook) HandleBidderRequestHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
   253  	return hookstage.HookResult[hookstage.BidderRequestPayload]{}, errors.New("unexpected error")
   254  }
   255  
   256  func (h mockErrorHook) HandleAllProcessedBidResponsesHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
   257  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{}, errors.New("unexpected error")
   258  }
   259  
   260  func (h mockErrorHook) HandleAuctionResponseHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.AuctionResponsePayload) (hookstage.HookResult[hookstage.AuctionResponsePayload], error) {
   261  	return hookstage.HookResult[hookstage.AuctionResponsePayload]{}, errors.New("unexpected error")
   262  }
   263  
   264  type mockFailedMutationHook struct{}
   265  
   266  func (h mockFailedMutationHook) HandleEntrypointHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.EntrypointPayload) (hookstage.HookResult[hookstage.EntrypointPayload], error) {
   267  	changeSet := hookstage.ChangeSet[hookstage.EntrypointPayload]{}
   268  	changeSet.AddMutation(func(payload hookstage.EntrypointPayload) (hookstage.EntrypointPayload, error) {
   269  		return payload, errors.New("key not found")
   270  	}, hookstage.MutationUpdate, "header", "foo")
   271  
   272  	return hookstage.HookResult[hookstage.EntrypointPayload]{ChangeSet: changeSet}, nil
   273  }
   274  
   275  func (h mockFailedMutationHook) HandleRawAuctionHook(_ context.Context, miCtx hookstage.ModuleInvocationContext, _ hookstage.RawAuctionRequestPayload) (hookstage.HookResult[hookstage.RawAuctionRequestPayload], error) {
   276  	changeSet := hookstage.ChangeSet[hookstage.RawAuctionRequestPayload]{}
   277  	changeSet.AddMutation(func(payload hookstage.RawAuctionRequestPayload) (hookstage.RawAuctionRequestPayload, error) {
   278  		return payload, errors.New("key not found")
   279  	}, hookstage.MutationUpdate, "header", "foo")
   280  
   281  	return hookstage.HookResult[hookstage.RawAuctionRequestPayload]{ChangeSet: changeSet}, nil
   282  }
   283  
   284  func (h mockFailedMutationHook) HandleBidderRequestHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
   285  	changeSet := hookstage.ChangeSet[hookstage.BidderRequestPayload]{}
   286  	changeSet.AddMutation(func(payload hookstage.BidderRequestPayload) (hookstage.BidderRequestPayload, error) {
   287  		return payload, errors.New("key not found")
   288  	}, hookstage.MutationUpdate, "header", "foo")
   289  
   290  	return hookstage.HookResult[hookstage.BidderRequestPayload]{ChangeSet: changeSet}, nil
   291  }
   292  
   293  func (h mockFailedMutationHook) HandleAllProcessedBidResponsesHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
   294  	changeSet := hookstage.ChangeSet[hookstage.AllProcessedBidResponsesPayload]{}
   295  	changeSet.AddMutation(func(payload hookstage.AllProcessedBidResponsesPayload) (hookstage.AllProcessedBidResponsesPayload, error) {
   296  		return payload, errors.New("key not found")
   297  	}, hookstage.MutationUpdate, "some-bidder", "bids[0]", "deal_priority")
   298  
   299  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{ChangeSet: changeSet}, nil
   300  }
   301  
   302  type mockUpdateBidRequestHook struct{}
   303  
   304  func (e mockUpdateBidRequestHook) HandleProcessedAuctionHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.ProcessedAuctionRequestPayload) (hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload], error) {
   305  	c := hookstage.ChangeSet[hookstage.ProcessedAuctionRequestPayload]{}
   306  	c.AddMutation(
   307  		func(payload hookstage.ProcessedAuctionRequestPayload) (hookstage.ProcessedAuctionRequestPayload, error) {
   308  			payload.RequestWrapper.User.Yob = 2000
   309  			userExt, err := payload.RequestWrapper.GetUserExt()
   310  			if err != nil {
   311  				return payload, err
   312  			}
   313  			newPrebidExt := &openrtb_ext.ExtUserPrebid{
   314  				BuyerUIDs: map[string]string{"some": "id"},
   315  			}
   316  			userExt.SetPrebid(newPrebidExt)
   317  			return payload, nil
   318  		}, hookstage.MutationUpdate, "bidRequest", "user.yob",
   319  	).AddMutation(
   320  		func(payload hookstage.ProcessedAuctionRequestPayload) (hookstage.ProcessedAuctionRequestPayload, error) {
   321  			payload.RequestWrapper.User.Consent = "true"
   322  			return payload, nil
   323  		}, hookstage.MutationUpdate, "bidRequest", "user.consent",
   324  	)
   325  
   326  	return hookstage.HookResult[hookstage.ProcessedAuctionRequestPayload]{ChangeSet: c}, nil
   327  }
   328  
   329  func (e mockUpdateBidRequestHook) HandleBidderRequestHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.BidderRequestPayload) (hookstage.HookResult[hookstage.BidderRequestPayload], error) {
   330  	c := hookstage.ChangeSet[hookstage.BidderRequestPayload]{}
   331  	c.AddMutation(
   332  		func(payload hookstage.BidderRequestPayload) (hookstage.BidderRequestPayload, error) {
   333  			payload.BidRequest.User.Yob = 2000
   334  			return payload, nil
   335  		}, hookstage.MutationUpdate, "bidRequest", "user.yob",
   336  	).AddMutation(
   337  		func(payload hookstage.BidderRequestPayload) (hookstage.BidderRequestPayload, error) {
   338  			payload.BidRequest.User.Consent = "true"
   339  			return payload, nil
   340  		}, hookstage.MutationUpdate, "bidRequest", "user.consent",
   341  	)
   342  
   343  	return hookstage.HookResult[hookstage.BidderRequestPayload]{ChangeSet: c}, nil
   344  }
   345  
   346  type mockUpdateBidderResponseHook struct{}
   347  
   348  func (e mockUpdateBidderResponseHook) HandleRawBidderResponseHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.RawBidderResponsePayload) (hookstage.HookResult[hookstage.RawBidderResponsePayload], error) {
   349  	c := hookstage.ChangeSet[hookstage.RawBidderResponsePayload]{}
   350  	c.AddMutation(
   351  		func(payload hookstage.RawBidderResponsePayload) (hookstage.RawBidderResponsePayload, error) {
   352  			payload.Bids[0].DealPriority = 10
   353  			return payload, nil
   354  		}, hookstage.MutationUpdate, "bidderResponse", "bid.deal-priority",
   355  	)
   356  
   357  	return hookstage.HookResult[hookstage.RawBidderResponsePayload]{ChangeSet: c}, nil
   358  }
   359  
   360  type mockUpdateBiddersResponsesHook struct{}
   361  
   362  func (e mockUpdateBiddersResponsesHook) HandleAllProcessedBidResponsesHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AllProcessedBidResponsesPayload) (hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload], error) {
   363  	c := hookstage.ChangeSet[hookstage.AllProcessedBidResponsesPayload]{}
   364  	c.AddMutation(
   365  		func(payload hookstage.AllProcessedBidResponsesPayload) (hookstage.AllProcessedBidResponsesPayload, error) {
   366  			payload.Responses["some-bidder"].Bids[0].DealPriority = 10
   367  			return payload, nil
   368  		}, hookstage.MutationUpdate, "processedBidderResponse", "bid.deal-priority",
   369  	)
   370  
   371  	return hookstage.HookResult[hookstage.AllProcessedBidResponsesPayload]{ChangeSet: c}, nil
   372  }
   373  
   374  type mockUpdateBidResponseHook struct{}
   375  
   376  func (e mockUpdateBidResponseHook) HandleAuctionResponseHook(_ context.Context, _ hookstage.ModuleInvocationContext, _ hookstage.AuctionResponsePayload) (hookstage.HookResult[hookstage.AuctionResponsePayload], error) {
   377  	c := hookstage.ChangeSet[hookstage.AuctionResponsePayload]{}
   378  	c.AddMutation(
   379  		func(payload hookstage.AuctionResponsePayload) (hookstage.AuctionResponsePayload, error) {
   380  			payload.BidResponse.CustomData = "new-custom-data"
   381  			return payload, nil
   382  		}, hookstage.MutationUpdate, "auctionResponse", "bidResponse.custom-data")
   383  
   384  	return hookstage.HookResult[hookstage.AuctionResponsePayload]{ChangeSet: c}, nil
   385  }