Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into v2.28.0-yahoo
Browse files Browse the repository at this point in the history
  • Loading branch information
scr-oath committed Sep 11, 2024
2 parents 8d7117d + baf9e51 commit 296c68e
Show file tree
Hide file tree
Showing 102 changed files with 14,033 additions and 731 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y wget
WORKDIR /tmp
RUN wget https://dl.google.com/go/go1.22.3.linux-amd64.tar.gz && \
tar -xf go1.22.3.linux-amd64.tar.gz && \
RUN wget https://edge.artifactory.ouroath.com:4443/artifactory/go_platform/golang/go1.22.6.linux-amd64.tar.gz && \
tar -xf go1.22.6.linux-amd64.tar.gz && \
mv go /usr/local
RUN mkdir -p /app/prebid-server/
WORKDIR /app/prebid-server/
Expand Down
48 changes: 26 additions & 22 deletions adapters/adapterstest/test_json.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package adapterstest

import (
"encoding/json"
encodingJson "encoding/json"
"fmt"
"io/fs"
"net/http"
Expand All @@ -12,6 +12,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
jsoniter "github.com/json-iterator/go"
"github.com/mitchellh/copystructure"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/adapters"
Expand All @@ -24,13 +25,16 @@ import (

const jsonFileExtension string = ".json"

var supportedDirs = map[string]struct{}{
"exemplary": {},
"supplemental": {},
"amp": {},
"video": {},
"videosupplemental": {},
}
var (
supportedDirs = map[string]struct{}{
"exemplary": {},
"supplemental": {},
"amp": {},
"video": {},
"videosupplemental": {},
}
json = jsoniter.ConfigCompatibleWithStandardLibrary
)

// RunJSONBidderTest is a helper method intended to unit test Bidders' adapters.
// It requires that:
Expand Down Expand Up @@ -199,16 +203,16 @@ func (req *httpRequest) ToRequestData(t *testing.T) *adapters.RequestData {
}

type httpRequest struct {
Body json.RawMessage `json:"body"`
Uri string `json:"uri"`
Headers http.Header `json:"headers"`
ImpIDs []string `json:"impIDs"`
Body encodingJson.RawMessage `json:"body"`
Uri string `json:"uri"`
Headers http.Header `json:"headers"`
ImpIDs []string `json:"impIDs"`
}

type httpResponse struct {
Status int `json:"status"`
Body json.RawMessage `json:"body"`
Headers http.Header `json:"headers"`
Status int `json:"status"`
Body encodingJson.RawMessage `json:"body"`
Headers http.Header `json:"headers"`
}

func (resp *httpResponse) ToResponseData(t *testing.T) *adapters.ResponseData {
Expand All @@ -220,15 +224,15 @@ func (resp *httpResponse) ToResponseData(t *testing.T) *adapters.ResponseData {
}

type expectedBidResponse struct {
Bids []expectedBid `json:"bids"`
Currency string `json:"currency"`
FledgeAuctionConfigs json.RawMessage `json:"fledgeauctionconfigs,omitempty"`
Bids []expectedBid `json:"bids"`
Currency string `json:"currency"`
FledgeAuctionConfigs encodingJson.RawMessage `json:"fledgeauctionconfigs,omitempty"`
}

type expectedBid struct {
Bid json.RawMessage `json:"bid"`
Type string `json:"type"`
Seat string `json:"seat"`
Bid encodingJson.RawMessage `json:"bid"`
Type string `json:"type"`
Seat string `json:"seat"`
}

// ---------------------------------------
Expand Down Expand Up @@ -345,7 +349,7 @@ func diffBids(t *testing.T, description string, actual *adapters.TypedBid, expec
}

// diffOrtbBids compares the actual Bid made by the adapter to the expectation from the JSON file.
func diffOrtbBids(description string, actual *openrtb2.Bid, expected json.RawMessage) error {
func diffOrtbBids(description string, actual *openrtb2.Bid, expected encodingJson.RawMessage) error {
if actual == nil {
return fmt.Errorf("Bidders cannot return nil Bids. %s was nil.", description)
}
Expand Down
21 changes: 13 additions & 8 deletions adapters/appnexus/appnexus.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appnexus

import (
"encoding/json"
encodingJson "encoding/json"
"errors"
"fmt"
"maps"
Expand All @@ -11,6 +11,7 @@ import (
"strings"

"github.com/buger/jsonparser"
jsoniter "github.com/json-iterator/go"
"github.com/prebid/openrtb/v20/adcom1"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/config"
Expand All @@ -28,6 +29,10 @@ const (
maxImpsPerReq = 10
)

var (
json = jsoniter.ConfigCompatibleWithStandardLibrary
)

type adapter struct {
uri url.URL
hbSource int
Expand Down Expand Up @@ -217,8 +222,8 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest
return bidderResponse, errs
}

func getRequestExt(ext json.RawMessage) (map[string]json.RawMessage, error) {
extMap := make(map[string]json.RawMessage)
func getRequestExt(ext encodingJson.RawMessage) (map[string]encodingJson.RawMessage, error) {
extMap := make(map[string]encodingJson.RawMessage)

if len(ext) > 0 {
if err := json.Unmarshal(ext, &extMap); err != nil {
Expand All @@ -229,7 +234,7 @@ func getRequestExt(ext json.RawMessage) (map[string]json.RawMessage, error) {
return extMap, nil
}

func (a *adapter) getAppnexusExt(extMap map[string]json.RawMessage, isAMP int, isVIDEO int) (bidReqExtAppnexus, error) {
func (a *adapter) getAppnexusExt(extMap map[string]encodingJson.RawMessage, isAMP int, isVIDEO int) (bidReqExtAppnexus, error) {
var appnexusExt bidReqExtAppnexus

if appnexusExtJson, exists := extMap["appnexus"]; exists && len(appnexusExtJson) > 0 {
Expand Down Expand Up @@ -305,7 +310,7 @@ func groupByPods(imps []openrtb2.Imp) map[string]([]openrtb2.Imp) {
return podImps
}

func splitRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExt map[string]json.RawMessage, requestExtAppnexus bidReqExtAppnexus, uri string) ([]*adapters.RequestData, []error) {
func splitRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExt map[string]encodingJson.RawMessage, requestExtAppnexus bidReqExtAppnexus, uri string) ([]*adapters.RequestData, []error) {
var errs []error
// Initial capacity for future array of requests, memory optimization.
// Let's say there are 35 impressions and limit impressions per request equals to 10.
Expand Down Expand Up @@ -457,12 +462,12 @@ func buildDisplayManageVer(req *openrtb2.BidRequest) string {
}

// moveSupplyChain moves the supply chain object from source.ext.schain to ext.schain.
func moveSupplyChain(request *openrtb2.BidRequest, extMap map[string]json.RawMessage) error {
func moveSupplyChain(request *openrtb2.BidRequest, extMap map[string]encodingJson.RawMessage) error {
if request == nil || request.Source == nil || len(request.Source.Ext) == 0 {
return nil
}

sourceExtMap := make(map[string]json.RawMessage)
sourceExtMap := make(map[string]encodingJson.RawMessage)
if err := json.Unmarshal(request.Source.Ext, &sourceExtMap); err != nil {
return err
}
Expand Down Expand Up @@ -491,7 +496,7 @@ func moveSupplyChain(request *openrtb2.BidRequest, extMap map[string]json.RawMes
return nil
}

func (a *adapter) buildAdPodRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExt map[string]json.RawMessage, requestExtAppnexus bidReqExtAppnexus, uri string) ([]*adapters.RequestData, []error) {
func (a *adapter) buildAdPodRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExt map[string]encodingJson.RawMessage, requestExtAppnexus bidReqExtAppnexus, uri string) ([]*adapters.RequestData, []error) {
var errs []error
podImps := groupByPods(imps)
requests := make([]*adapters.RequestData, 0, len(podImps))
Expand Down
16 changes: 8 additions & 8 deletions adapters/appnexus/models.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appnexus

import (
"encoding/json"
encodingJson "encoding/json"
)

// impExt defines the outgoing data contract.
Expand All @@ -11,13 +11,13 @@ type impExt struct {
}

type impExtAppnexus struct {
PlacementID int `json:"placement_id,omitempty"`
Keywords string `json:"keywords,omitempty"`
TrafficSourceCode string `json:"traffic_source_code,omitempty"`
UsePmtRule *bool `json:"use_pmt_rule,omitempty"`
PrivateSizes json.RawMessage `json:"private_sizes,omitempty"`
ExtInvCode string `json:"ext_inv_code,omitempty"`
ExternalImpID string `json:"external_imp_id,omitempty"`
PlacementID int `json:"placement_id,omitempty"`
Keywords string `json:"keywords,omitempty"`
TrafficSourceCode string `json:"traffic_source_code,omitempty"`
UsePmtRule *bool `json:"use_pmt_rule,omitempty"`
PrivateSizes encodingJson.RawMessage `json:"private_sizes,omitempty"`
ExtInvCode string `json:"ext_inv_code,omitempty"`
ExternalImpID string `json:"external_imp_id,omitempty"`
}

type bidExtVideo struct {
Expand Down
6 changes: 3 additions & 3 deletions adapters/appnexus/params_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appnexus

import (
"encoding/json"
encodingJson "encoding/json"
"testing"

"github.com/prebid/prebid-server/v2/openrtb_ext"
Expand All @@ -19,7 +19,7 @@ func TestValidParams(t *testing.T) {
}

for _, validParam := range validParams {
if err := validator.Validate(openrtb_ext.BidderAppnexus, json.RawMessage(validParam)); err != nil {
if err := validator.Validate(openrtb_ext.BidderAppnexus, encodingJson.RawMessage(validParam)); err != nil {
t.Errorf("Schema rejected appnexus params: %s", validParam)
}
}
Expand All @@ -33,7 +33,7 @@ func TestInvalidParams(t *testing.T) {
}

for _, invalidParam := range invalidParams {
if err := validator.Validate(openrtb_ext.BidderAppnexus, json.RawMessage(invalidParam)); err == nil {
if err := validator.Validate(openrtb_ext.BidderAppnexus, encodingJson.RawMessage(invalidParam)); err == nil {
t.Errorf("Schema allowed unexpected params: %s", invalidParam)
}
}
Expand Down
20 changes: 14 additions & 6 deletions adapters/bidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ func NewBidderResponse() *BidderResponse {
// TypedBid.BidVideo will become "response.seatbid[i].bid.ext.prebid.video" in the final OpenRTB response.
// TypedBid.DealPriority is optionally provided by adapters and used internally by the exchange to support deal targeted campaigns.
// TypedBid.Seat new seat under which the bid should pe placed. Default is adapter name
// TypedBid.DealWinPriority the priority of the deal, higher priorities wins against lower priorities
type TypedBid struct {
Bid *openrtb2.Bid
BidMeta *openrtb_ext.ExtBidPrebidMeta
BidType openrtb_ext.BidType
BidVideo *openrtb_ext.ExtBidPrebidVideo
DealPriority int
Seat openrtb_ext.BidderName
Bid *openrtb2.Bid
BidMeta *openrtb_ext.ExtBidPrebidMeta
BidType openrtb_ext.BidType
BidVideo *openrtb_ext.ExtBidPrebidVideo
DealPriority int
Seat openrtb_ext.BidderName
DealWinPriority int
}

// RequestData and ResponseData exist so that prebid-server core code can implement its "debug" functionality
Expand All @@ -124,6 +126,12 @@ type RequestData struct {
ImpIDs []string
}

type HttpInfo struct {
HttpRequest *RequestData
HttpResponse *ResponseData
BidRequest *openrtb2.BidRequest
}

// ExtImpBidder can be used by Bidders to unmarshal any request.imp[i].ext.
type ExtImpBidder struct {
Prebid *openrtb_ext.ExtImpPrebid `json:"prebid"`
Expand Down
6 changes: 5 additions & 1 deletion adapters/conversant/conversant.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package conversant

import (
"encoding/json"
"fmt"
"net/http"
"strings"

jsoniter "github.com/json-iterator/go"
"github.com/prebid/openrtb/v20/adcom1"
"github.com/prebid/openrtb/v20/openrtb2"
"github.com/prebid/prebid-server/v2/adapters"
Expand All @@ -14,6 +14,10 @@ import (
"github.com/prebid/prebid-server/v2/openrtb_ext"
)

var (
json = jsoniter.ConfigCompatibleWithStandardLibrary
)

type ConversantAdapter struct {
URI string
}
Expand Down
Loading

0 comments on commit 296c68e

Please sign in to comment.