Skip to content

Commit

Permalink
FPD bidder specific user (#2348)
Browse files Browse the repository at this point in the history
  • Loading branch information
VeronikaSolovei9 authored Aug 15, 2022
1 parent f6dbf27 commit 1fa7cd8
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 17 deletions.
8 changes: 3 additions & 5 deletions firstpartydata/first_party_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ func resolveUser(fpdConfig *openrtb_ext.ORTB2, bidRequestUser *openrtb2.User, gl
return nil, nil
}

if bidRequestUser == nil && fpdConfigUser != nil {
return nil, &errortypes.BadInput{
Message: fmt.Sprintf("incorrect First Party Data for bidder %s: User object is not defined in request, but defined in FPD config", bidderName),
}
newUser := openrtb2.User{}
if bidRequestUser != nil {
newUser = *bidRequestUser
}

newUser := *bidRequestUser
var err error

//apply global fpd
Expand Down
11 changes: 0 additions & 11 deletions firstpartydata/first_party_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,17 +852,6 @@ func TestResolveUserNilValues(t *testing.T) {
assert.Nil(t, resultUser, "Result user should be nil")
}

func TestResolveUserBadInput(t *testing.T) {
fpdConfigUser := make(map[string]json.RawMessage, 0)
fpdConfigUser["id"] = []byte(`"fpdConfigUserId"`)
fpdConfig := &openrtb_ext.ORTB2{User: fpdConfigUser}

resultUser, err := resolveUser(fpdConfig, nil, nil, nil, "appnexus")
assert.Error(t, err, "Error should be returned")
assert.Equal(t, "incorrect First Party Data for bidder appnexus: User object is not defined in request, but defined in FPD config", err.Error(), "Incorrect error message")
assert.Nil(t, resultUser, "Result user should be nil")
}

func TestMergeUsers(t *testing.T) {

originalUser := &openrtb2.User{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"description": "req.user is not present but req.ext.prebid.bidderconfig contains user for bidder; expect req.user to present in the resolved bidders FPD",
"inputRequestData": {
"id": "bid_id",
"test": 1,
"ext": {
"prebid": {
"data": {
"bidders": ["appnexus"]
},
"bidderconfig": [
{
"bidders": [
"appnexus"
],
"config": {
"ortb2": {
"user": {
"id": "appnexusFpdUser",
"yob": 2011,
"gender": "F",
"keywords": "fpd keywords",
"data": [
{
"id": "FpdUserDataId1",
"name": "FpdUserDataName1"
},
{
"id": "FpdUserDataId2",
"name": "FpdUserDataName2"
}
],
"ext": {
"data": {
"userdata": "appnexusFpdUserExtData"
}
}
}
}
}
}
]
}
}
},
"outputRequestData": {
"id": "bid_id",
"test": 1
},
"biddersFPDResolved": {
"appnexus": {
"user": {
"yob": 2011,
"gender": "F",
"keywords": "fpd keywords",
"data": [
{
"id": "FpdUserDataId1",
"name": "FpdUserDataName1"
},
{
"id": "FpdUserDataId2",
"name": "FpdUserDataName2"
}
],
"ext": {
"data": {
"ext": {
"data": {
"userdata": "appnexusFpdUserExtData"
}
},
"id": "appnexusFpdUser"
}
}
}
}
},
"validationErrors": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"outputRequestData":{},
"biddersFPDResolved": {},
"validationErrors": [
{"Message": "incorrect First Party Data for bidder appnexus: User object is not defined in request, but defined in FPD config"},
{"Message": "incorrect First Party Data for bidder appnexus: App object is not defined in request, but defined in FPD config"},
{"Message": "incorrect First Party Data for bidder telaria: App object is not defined in request, but defined in FPD config"}
]
Expand Down

0 comments on commit 1fa7cd8

Please sign in to comment.