Skip to content

Commit

Permalink
ORTB 2.6 upconvert, validation, usage and unit test updates (#3970)
Browse files Browse the repository at this point in the history
Co-authored-by: hhhjort <[email protected]>
Co-authored-by: Veronika Solovei <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent 87d4412 commit 9cf7495
Show file tree
Hide file tree
Showing 47 changed files with 743 additions and 743 deletions.
2 changes: 1 addition & 1 deletion adapters/openx/openx.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func preprocess(imp *openrtb2.Imp, reqExt *openxReqExt) error {

if imp.Video != nil {
videoCopy := *imp.Video
if bidderExt.Prebid != nil && bidderExt.Prebid.IsRewardedInventory != nil && *bidderExt.Prebid.IsRewardedInventory == 1 {
if imp.Rwdd == 1 {
videoCopy.Ext = json.RawMessage(`{"rewarded":1}`)
} else {
videoCopy.Ext = nil
Expand Down
7 changes: 3 additions & 4 deletions adapters/openx/openxtest/exemplary/video-rewarded.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
}
},
"instl": 1,
"rwdd": 1,
"ext": {
"bidder": {
"unit": "539439964",
"delDomain": "se-demo-d.openx.net"
},
"prebid": {
"is_rewarded_inventory": 1
}
}
}
Expand All @@ -46,7 +44,8 @@
}
},
"tagid": "539439964",
"instl": 1
"instl": 1,
"rwdd": 1
}
],
"ext": {
Expand Down
2 changes: 1 addition & 1 deletion amp/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func buildGdprTCF2ConsentWriter(ampParams Params) gdpr.ConsentWriter {
// set regs.ext.gdpr if non-nil gdpr_applies was set to true
gdprValue = parseGdprApplies(ampParams.GdprApplies)
}
writer.RegExtGDPR = &gdprValue
writer.GDPR = &gdprValue

return writer
}
Expand Down
40 changes: 20 additions & 20 deletions amp/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
RegExtGDPR: &int8One,
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
GDPR: &int8One,
},
warning: nil,
},
Expand Down Expand Up @@ -378,8 +378,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
RegExtGDPR: &int8One,
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
GDPR: &int8One,
},
warning: nil,
},
Expand All @@ -400,8 +400,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "INVALID_GDPR",
RegExtGDPR: &int8One,
Consent: "INVALID_GDPR",
GDPR: &int8One,
},
warning: &errortypes.Warning{
Message: "Consent string 'INVALID_GDPR' is not a valid TCF2 consent string.",
Expand All @@ -420,8 +420,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "INVALID_GDPR",
RegExtGDPR: &int8Zero,
Consent: "INVALID_GDPR",
GDPR: &int8Zero,
},
warning: &errortypes.Warning{
Message: "Consent string 'INVALID_GDPR' is not a valid TCF2 consent string.",
Expand All @@ -440,8 +440,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
RegExtGDPR: &int8Zero,
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
GDPR: &int8Zero,
},
warning: nil,
},
Expand All @@ -457,8 +457,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
RegExtGDPR: &int8One,
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
GDPR: &int8One,
},
warning: nil,
},
Expand All @@ -473,8 +473,8 @@ func TestPrivacyReader(t *testing.T) {
},
expected: expectedResults{
policyWriter: gdpr.ConsentWriter{
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
RegExtGDPR: &int8One,
Consent: "CPdiPIJPdiPIJACABBENAzCv_____3___wAAAQNd_X9cAAAAAAAA",
GDPR: &int8One,
},
warning: nil,
},
Expand Down Expand Up @@ -559,8 +559,8 @@ func TestBuildGdprTCF2ConsentWriter(t *testing.T) {
desc: "gdpr_applies not set",
inParams: Params{Consent: consentString},
expectedWriter: gdpr.ConsentWriter{
Consent: consentString,
RegExtGDPR: &int8One,
Consent: consentString,
GDPR: &int8One,
},
},
{
Expand All @@ -570,8 +570,8 @@ func TestBuildGdprTCF2ConsentWriter(t *testing.T) {
GdprApplies: &boolFalse,
},
expectedWriter: gdpr.ConsentWriter{
Consent: consentString,
RegExtGDPR: &int8Zero,
Consent: consentString,
GDPR: &int8Zero,
},
},
{
Expand All @@ -581,8 +581,8 @@ func TestBuildGdprTCF2ConsentWriter(t *testing.T) {
GdprApplies: &boolTrue,
},
expectedWriter: gdpr.ConsentWriter{
Consent: consentString,
RegExtGDPR: &int8One,
Consent: consentString,
GDPR: &int8One,
},
},
}
Expand Down
10 changes: 3 additions & 7 deletions analytics/agma/agma_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,11 @@ func (l *AgmaLogger) extractPublisherAndSite(requestWrapper *openrtb_ext.Request
}

func (l *AgmaLogger) shouldTrackEvent(requestWrapper *openrtb_ext.RequestWrapper) (bool, string) {
userExt, err := requestWrapper.GetUserExt()
if err != nil || userExt == nil {
if requestWrapper.User == nil {
return false, ""
}
consent := userExt.GetConsent()
if consent == nil {
return false, ""
}
consentStr := *consent
consentStr := requestWrapper.User.Consent

parsedConsent, err := vendorconsent.ParseString(consentStr)
if err != nil {
return false, ""
Expand Down
25 changes: 12 additions & 13 deletions analytics/agma/agma_module_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package agma

import (
"encoding/json"
"io"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -37,7 +36,7 @@ var mockValidAuctionObject = analytics.AuctionObject{
UA: "ua",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
},
Expand All @@ -59,7 +58,7 @@ var mockValidVideoObject = analytics.VideoObject{
UA: "ua",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
},
Expand All @@ -81,7 +80,7 @@ var mockValidAmpObject = analytics.AmpObject{
UA: "ua",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
},
Expand Down Expand Up @@ -212,7 +211,7 @@ func TestShouldTrackEvent(t *testing.T) {
},
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
})
Expand Down Expand Up @@ -245,7 +244,7 @@ func TestShouldTrackEvent(t *testing.T) {
},
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "CP4LywcP4LywcLRAAAENCZCAAAIAAAIAAAAAIxQAQIwgAAAA.II7Nd_X__bX9n-_7_6ft0eY1f9_r37uQzDhfNs-8F3L_W_LwX32E7NF36tq4KmR4ku1bBIQNtHMnUDUmxaolVrzHsak2cpyNKJ_JkknsZe2dYGF9Pn9lD-YKZ7_5_9_f52T_9_9_-39z3_9f___dv_-__-vjf_599n_v9fV_78_Kf9______-____________8A"}`),
Consent: "CP4LywcP4LywcLRAAAENCZCAAAIAAAIAAAAAIxQAQIwgAAAA.II7Nd_X__bX9n-_7_6ft0eY1f9_r37uQzDhfNs-8F3L_W_LwX32E7NF36tq4KmR4ku1bBIQNtHMnUDUmxaolVrzHsak2cpyNKJ_JkknsZe2dYGF9Pn9lD-YKZ7_5_9_f52T_9_9_-39z3_9f___dv_-__-vjf_599n_v9fV_78_Kf9______-____________8A",
},
},
})
Expand All @@ -263,7 +262,7 @@ func TestShouldTrackEvent(t *testing.T) {
},
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "CP4LywcP4LywcLRAAAENCZCAAIAAAAAAAAAAIxQAQIxAAAAA.II7Nd_X__bX9n-_7_6ft0eY1f9_r37uQzDhfNs-8F3L_W_LwX32E7NF36tq4KmR4ku1bBIQNtHMnUDUmxaolVrzHsak2cpyNKJ_JkknsZe2dYGF9Pn9lD-YKZ7_5_9_f52T_9_9_-39z3_9f___dv_-__-vjf_599n_v9fV_78_Kf9______-____________8A"}`),
Consent: "CP4LywcP4LywcLRAAAENCZCAAIAAAAAAAAAAIxQAQIxAAAAA.II7Nd_X__bX9n-_7_6ft0eY1f9_r37uQzDhfNs-8F3L_W_LwX32E7NF36tq4KmR4ku1bBIQNtHMnUDUmxaolVrzHsak2cpyNKJ_JkknsZe2dYGF9Pn9lD-YKZ7_5_9_f52T_9_9_-39z3_9f___dv_-__-vjf_599n_v9fV_78_Kf9______-____________8A",
},
},
})
Expand All @@ -281,7 +280,7 @@ func TestShouldTrackEvent(t *testing.T) {
},
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
})
Expand All @@ -296,7 +295,7 @@ func TestShouldTrackEvent(t *testing.T) {
ID: "track-me",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
})
Expand All @@ -311,7 +310,7 @@ func TestShouldTrackEvent(t *testing.T) {
Bundle: "track-me",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
})
Expand Down Expand Up @@ -359,7 +358,7 @@ func TestShouldTrackMultipleAccounts(t *testing.T) {
},
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
})
Expand All @@ -377,7 +376,7 @@ func TestShouldTrackMultipleAccounts(t *testing.T) {
},
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
Consent: agmaConsent,
},
},
})
Expand Down Expand Up @@ -691,7 +690,7 @@ func TestRaceEnd2End(t *testing.T) {

time.Sleep(250 * time.Millisecond)

expected := "[{\"type\":\"amp\",\"id\":\"some-id\",\"code\":\"abcd\",\"site\":{\"id\":\"track-me-site\",\"publisher\":{\"id\":\"track-me\"}},\"device\":{\"ua\":\"ua\"},\"user\":{\"ext\":{\"consent\": \"" + agmaConsent + "\"}},\"created_at\":\"2023-02-01T00:00:00Z\"},{\"type\":\"amp\",\"id\":\"some-id\",\"code\":\"abcd\",\"site\":{\"id\":\"track-me-site\",\"publisher\":{\"id\":\"track-me\"}},\"device\":{\"ua\":\"ua\"},\"user\":{\"ext\":{\"consent\": \"" + agmaConsent + "\"}},\"created_at\":\"2023-02-01T00:00:00Z\"}]"
expected := "[{\"type\":\"amp\",\"id\":\"some-id\",\"code\":\"abcd\",\"site\":{\"id\":\"track-me-site\",\"publisher\":{\"id\":\"track-me\"}},\"device\":{\"ua\":\"ua\"},\"user\":{\"consent\":\"" + agmaConsent + "\"},\"created_at\":\"2023-02-01T00:00:00Z\"},{\"type\":\"amp\",\"id\":\"some-id\",\"code\":\"abcd\",\"site\":{\"id\":\"track-me-site\",\"publisher\":{\"id\":\"track-me\"}},\"device\":{\"ua\":\"ua\"},\"user\":{\"consent\":\"" + agmaConsent + "\"},\"created_at\":\"2023-02-01T00:00:00Z\"}]"

mu.Lock()
actual := requestBodyAsString
Expand Down
9 changes: 9 additions & 0 deletions endpoints/openrtb2/amp_auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ func (deps *endpointDeps) parseAmpRequest(httpRequest *http.Request) (req *openr
// move to using the request wrapper
req = &openrtb_ext.RequestWrapper{BidRequest: reqNormal}

// upgrade to 2.6 here
err := openrtb_ext.ConvertUpTo26(req)
if err != nil {
errs = append(errs, err)
}
if errortypes.ContainsFatalError(errs) {
return
}

// Need to ensure cache and targeting are turned on
e = initAmpTargetingAndCache(req)
if errs = append(errs, e...); errortypes.ContainsFatalError(errs) {
Expand Down
Loading

0 comments on commit 9cf7495

Please sign in to comment.