Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging master into cert-file-fix branch #17

Merged
merged 26 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a0cba28
Marsmedia - add new bidder (#1118)
vladi-mmg Dec 19, 2019
d31c072
Add Applogy adapter (#1151)
IncSW Jan 3, 2020
9ae9adc
enforce video.size_id for video imps in rubicon adapter (#1101)
Aadeshp Jan 6, 2020
e27b5b3
Updated PubMatic endpoint to use https (#1155)
PubMatic-OpenWrap Jan 9, 2020
eaed1c9
Update Example AppNexus Placement ID (#1160)
SyntaxNode Jan 9, 2020
2cb786a
Fix Currency Converter Doesn't Output CUR (#1154)
guscarreon Jan 10, 2020
072bf5b
Add custom JSON req/resp data to the analytics logging… (#1145)
jmaynardxandr Jan 10, 2020
3fc1685
CCPA User Sync URL Updates (#1157)
SyntaxNode Jan 14, 2020
b4ed836
Fixes audienceNetwork adapter ignoring banner.format sizes. (#1164)
hhhjort Jan 14, 2020
3a026fb
Adding changes for import statement
pm-isha-bharti Jan 16, 2020
a23b174
Merging master with branch: UOE-4837-V0.97.0
pm-isha-bharti Jan 18, 2020
1736ed6
Updating pubmatic default Usersync URL in config
pm-isha-bharti Jan 27, 2020
ffd379a
Removed check for bidder while setting secure flag
sachin-pubmatic Jan 28, 2020
0cc50e7
Updating usersync url for pubmatic
pm-isha-bharti Jan 28, 2020
1399e3f
Updating test case pubmatic usersync
pm-isha-bharti Jan 28, 2020
3eee611
Using macro for replacing sec param
sachin-pubmatic Jan 28, 2020
4cb0dc6
Revert "Using macro for replacing sec param"
sachin-pubmatic Jan 28, 2020
1682903
Revert "Removed check for bidder while setting secure flag"
sachin-pubmatic Jan 28, 2020
e4b3a11
Updated code for fixing secure flag issue
sachin-pubmatic Jan 28, 2020
2df8899
Changes for UOE-4861
sachin-pubmatic Jan 29, 2020
c10893e
Refacored code for extracting secure flag
sachin-pubmatic Jan 29, 2020
cae0908
Merge pull request #15 from PubMatic-OpenWrap/UOE-4837-V0.97.0
PubMatic-OpenWrap Jan 30, 2020
02434ea
Incorporated code review comments
sachin-pubmatic Jan 30, 2020
d8cf16d
Updated regex
sachin-pubmatic Jan 30, 2020
cfe4d17
Merged master
sachin-pubmatic Jan 30, 2020
14ba3fb
Merge pull request #16 from PubMatic-OpenWrap/UOE-4861
PubMatic-OpenWrap Feb 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions adapters/33across/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,30 @@ import (
"text/template"

"github.com/PubMatic-OpenWrap/prebid-server/privacy"
"github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa"
"github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr"
"github.com/stretchr/testify/assert"
)

func Test33AcrossSyncer(t *testing.T) {
syncURL := "https://ic.tynt.com/r/d?m=xch&rt=html&ri=123&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz"
syncURL := "https://ic.tynt.com/r/d?m=xch&rt=html&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz"
syncURLTemplate := template.Must(
template.New("sync-template").Parse(syncURL),
)

syncer := New33AcrossSyncer(syncURLTemplate)
syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{})
syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{
GDPR: gdpr.Policy{
Signal: "A",
Consent: "B",
},
CCPA: ccpa.Policy{
Value: "C",
},
})

assert.NoError(t, err)
assert.Equal(t, "https://ic.tynt.com/r/d?m=xch&rt=html&ri=123&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz", syncInfo.URL)
assert.Equal(t, "https://ic.tynt.com/r/d?m=xch&rt=html&gdpr=A&gdpr_consent=B&us_privacy=C&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz", syncInfo.URL)
assert.Equal(t, "iframe", syncInfo.Type)
assert.EqualValues(t, 58, syncer.GDPRVendorID())
assert.False(t, syncInfo.SupportCORS)
Expand Down
78 changes: 77 additions & 1 deletion adapters/adform/adform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ import (

"fmt"

"github.com/mxmCherry/openrtb"
"github.com/PubMatic-OpenWrap/prebid-server/adapters"
"github.com/PubMatic-OpenWrap/prebid-server/config"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"
"github.com/mxmCherry/openrtb"

"github.com/stretchr/testify/assert"
)

func TestJsonSamples(t *testing.T) {
Expand Down Expand Up @@ -597,3 +599,77 @@ func TestPriceTypeUrlParameterCreation(t *testing.T) {
}
}
}

// Asserts that toOpenRtbBidResponse() creates a *adapters.BidderResponse with
// the currency of the last valid []*adformBid element and the expected number of bids
func TestToOpenRtbBidResponse(t *testing.T) {
expectedBids := 3
lastCurrency, anotherCurrency, emptyCurrency := "EUR", "USD", ""

request := &openrtb.BidRequest{
ID: "test-request-id",
Imp: []openrtb.Imp{
{
ID: "banner-imp-no1",
Ext: json.RawMessage(`{"bidder1": { "mid": "32341" }}`),
Banner: &openrtb.Banner{},
},
{
ID: "banner-imp-no2",
Ext: json.RawMessage(`{"bidder1": { "mid": "32342" }}`),
Banner: &openrtb.Banner{},
},
{
ID: "banner-imp-no3",
Ext: json.RawMessage(`{"bidder1": { "mid": "32343" }}`),
Banner: &openrtb.Banner{},
},
{
ID: "banner-imp-no4",
Ext: json.RawMessage(`{"bidder1": { "mid": "32344" }}`),
Banner: &openrtb.Banner{},
},
},
Device: &openrtb.Device{UA: "ua", IP: "ip"},
User: &openrtb.User{BuyerUID: "buyerUID"},
}

testAdformBids := []*adformBid{
{
ResponseType: "banner",
Banner: "banner-content1",
Price: 1.23,
Currency: anotherCurrency,
Width: 300,
Height: 200,
DealId: "dealId1",
CreativeId: "creativeId1",
},
{},
{
ResponseType: "banner",
Banner: "banner-content3",
Price: 1.24,
Currency: emptyCurrency,
Width: 300,
Height: 200,
DealId: "dealId3",
CreativeId: "creativeId3",
},
{
ResponseType: "banner",
Banner: "banner-content4",
Price: 1.25,
Currency: lastCurrency,
Width: 300,
Height: 200,
DealId: "dealId4",
CreativeId: "creativeId4",
},
}

actualBidResponse := toOpenRtbBidResponse(testAdformBids, request)

assert.Equalf(t, expectedBids, len(actualBidResponse.Bids), "bid count")
assert.Equalf(t, lastCurrency, actualBidResponse.Currency, "currency")
}
8 changes: 6 additions & 2 deletions adapters/adkernel/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"text/template"

"github.com/PubMatic-OpenWrap/prebid-server/privacy"
"github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa"
"github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr"
"github.com/stretchr/testify/assert"
)

func TestAdkernelAdnSyncer(t *testing.T) {
syncURL := "https://sync.adkernel.com/user-sync?t=image&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D"
syncURL := "https://sync.adkernel.com/user-sync?t=image&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D"
syncURLTemplate := template.Must(
template.New("sync-template").Parse(syncURL),
)
Expand All @@ -21,10 +22,13 @@ func TestAdkernelAdnSyncer(t *testing.T) {
Signal: "1",
Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw",
},
CCPA: ccpa.Policy{
Value: "1NYN",
},
})

assert.NoError(t, err)
assert.Equal(t, "https://sync.adkernel.com/user-sync?t=image&gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%7BUID%7D", syncInfo.URL)
assert.Equal(t, "https://sync.adkernel.com/user-sync?t=image&gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&us_privacy=1NYN&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%7BUID%7D", syncInfo.URL)
assert.Equal(t, "redirect", syncInfo.Type)
assert.EqualValues(t, adkernelGDPRVendorID, syncer.GDPRVendorID())
assert.Equal(t, false, syncInfo.SupportCORS)
Expand Down
8 changes: 6 additions & 2 deletions adapters/adkernelAdn/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"text/template"

"github.com/PubMatic-OpenWrap/prebid-server/privacy"
"github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa"
"github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr"
"github.com/stretchr/testify/assert"
)

func TestAdkernelAdnSyncer(t *testing.T) {
syncURL := "https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D"
syncURL := "https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D"
syncURLTemplate := template.Must(
template.New("sync-template").Parse(syncURL),
)
Expand All @@ -21,10 +22,13 @@ func TestAdkernelAdnSyncer(t *testing.T) {
Signal: "1",
Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw",
},
CCPA: ccpa.Policy{
Value: "1NYN",
},
})

assert.NoError(t, err)
assert.Equal(t, "https://tag.adkernel.com/syncr?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D", syncInfo.URL)
assert.Equal(t, "https://tag.adkernel.com/syncr?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&us_privacy=1NYN&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%7BUID%7D", syncInfo.URL)
assert.Equal(t, "redirect", syncInfo.Type)
assert.EqualValues(t, adkernelGDPRVendorID, syncer.GDPRVendorID())
assert.Equal(t, false, syncInfo.SupportCORS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"ext": {
"bidder": {
"placementId": 10433394
"placementId": 1
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"ext": {
"bidder": {
"placementId": 10433394
"placementId": 1
}
}
}
Expand Down
160 changes: 160 additions & 0 deletions adapters/applogy/applogy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
package applogy

import (
"encoding/json"
"errors"
"net/http"
"strconv"

"github.com/mxmCherry/openrtb"
"github.com/PubMatic-OpenWrap/prebid-server/adapters"
"github.com/PubMatic-OpenWrap/prebid-server/errortypes"
"github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext"
)

type ApplogyAdapter struct {
endpoint string
}

func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
headers := http.Header{}
headers.Add("Content-Type", "application/json;charset=utf-8")
headers.Add("Accept", "application/json")
impressions := request.Imp
result := make([]*adapters.RequestData, 0, len(impressions))
errs := make([]error, 0, len(impressions))

for i, impression := range impressions {
if impression.Banner == nil && impression.Video == nil && impression.Native == nil {
errs = append(errs, &errortypes.BadInput{
Message: "Applogy only supports banner, video or native ads",
})
continue
}
if impression.Banner != nil {
banner := impression.Banner
if banner.W == nil || banner.H == nil || *banner.W == 0 || *banner.H == 0 {
if len(banner.Format) == 0 {
errs = append(errs, &errortypes.BadInput{
Message: "banner size information missing",
})
continue
}
format := banner.Format[0]
banner.W = &format.W
banner.H = &format.H
}
}
if len(impression.Ext) == 0 {
errs = append(errs, errors.New("impression extensions required"))
continue
}
var bidderExt adapters.ExtImpBidder
err := json.Unmarshal(impression.Ext, &bidderExt)
if err != nil {
errs = append(errs, err)
continue
}
if len(bidderExt.Bidder) == 0 {
errs = append(errs, errors.New("bidder required"))
continue
}
var impressionExt openrtb_ext.ExtImpApplogy
err = json.Unmarshal(bidderExt.Bidder, &impressionExt)
if err != nil {
errs = append(errs, err)
continue
}
if impressionExt.Token == "" {
errs = append(errs, errors.New("Applogy token required"))
continue
}
request.Imp = impressions[i : i+1]
body, err := json.Marshal(request)
if err != nil {
errs = append(errs, err)
continue
}
result = append(result, &adapters.RequestData{
Method: "POST",
Uri: a.endpoint + "/" + impressionExt.Token,
Body: body,
Headers: headers,
})
}

request.Imp = impressions

if len(result) == 0 {
return nil, errs
}
return result, errs
}

func (a *ApplogyAdapter) MakeBids(request *openrtb.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
var errs []error

switch responseData.StatusCode {
case http.StatusNoContent:
return nil, nil
case http.StatusBadRequest:
return nil, []error{&errortypes.BadInput{
Message: "unexpected status code: " + strconv.Itoa(responseData.StatusCode),
}}
case http.StatusOK:
break
default:
return nil, []error{&errortypes.BadServerResponse{
Message: "unexpected status code: " + strconv.Itoa(responseData.StatusCode),
}}
}

var bidResponse openrtb.BidResponse
err := json.Unmarshal(responseData.Body, &bidResponse)
if err != nil {
return nil, []error{&errortypes.BadServerResponse{
Message: err.Error(),
}}
}

response := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))

for _, seatBid := range bidResponse.SeatBid {
for _, bid := range seatBid.Bid {
bid := bid // pin https://github.com/kyoh86/scopelint#whats-this
var bidType openrtb_ext.BidType
for _, impression := range request.Imp {
if impression.ID != bid.ImpID {
continue
}
switch {
case impression.Banner != nil:
bidType = openrtb_ext.BidTypeBanner
case impression.Video != nil:
bidType = openrtb_ext.BidTypeVideo
case impression.Native != nil:
bidType = openrtb_ext.BidTypeNative
}
break
}
if bidType == "" {
errs = append(errs, &errortypes.BadServerResponse{
Message: "ignoring bid id=" + bid.ID + ", request doesn't contain any valid impression with id=" + bid.ImpID,
})
continue
}
response.Bids = append(response.Bids, &adapters.TypedBid{
Bid: &bid,
BidType: bidType,
})
}
}

return response, errs
}

func NewApplogyBidder(endpoint string) *ApplogyAdapter {
return &ApplogyAdapter{
endpoint: endpoint,
}
}
11 changes: 11 additions & 0 deletions adapters/applogy/applogy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package applogy

import (
"testing"

"github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest"
)

func TestJsonSamples(t *testing.T) {
adapterstest.RunJSONBidderTest(t, "applogytest", NewApplogyBidder("http://example.com/prebid"))
}
Loading