Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into EX-5595_Bidfloor_mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
ikagotso committed Oct 1, 2024
2 parents 743847d + 6c154e0 commit d08b508
Show file tree
Hide file tree
Showing 47 changed files with 4,025 additions and 24 deletions.
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ WORKDIR /app/prebid-server/
ENV GOROOT=/usr/local/go
ENV PATH=$GOROOT/bin:$PATH
ENV GOPROXY="https://proxy.golang.org"

# Installing gcc as cgo uses it to build native code of some modules
RUN apt-get update && \
apt-get install -y git && \
apt-get install -y git gcc && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ENV CGO_ENABLED 0

# CGO must be enabled because some modules depend on native C code
ENV CGO_ENABLED 1
COPY ./ ./
RUN go mod tidy
RUN go mod vendor
Expand All @@ -30,8 +34,10 @@ RUN chmod a+xr prebid-server
COPY static static/
COPY stored_requests/data stored_requests/data
RUN chmod -R a+r static/ stored_requests/data

# Installing libatomic1 as it is a runtime dependency for some modules
RUN apt-get update && \
apt-get install -y ca-certificates mtr && \
apt-get install -y ca-certificates mtr libatomic1 && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN adduser prebid_user
USER prebid_user
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ or compile a standalone binary using the command:
``` bash
go build .
```
**Note:** if building from source there are a couple dependencies to be aware of:
1. *Compile-time*. Some modules ship native code that requires `cgo` (comes with the `go` compiler) being enabled - by default it is and environment variable `CGO_ENABLED=1` do NOT set it to `0`.
2. *Compile-time*. `cgo` depends on the C-compiler, which usually is `gcc`, but can be changed by setting the value of `CC` env var, f.e. `CC=clang`. On ubuntu `gcc` can be installed via `sudo apt-get install gcc`.
3. *Runtime*. Some modules require `libatomic`. On ubuntu it is installed by running `sudo apt-get install libatomic1`. `libatomic1` is a dependency of `gcc`, so if you are building with `gcc` and running on the same machine, it is likely that `libatomic1` is already installed.

Ensure that you deploy the `/static` directory, as Prebid Server requires those files at startup.

## Developing
Expand Down
28 changes: 15 additions & 13 deletions adapters/inmobi/inmobi.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ func (a *InMobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalR

for _, sb := range serverBidResponse.SeatBid {
for i := range sb.Bid {
mediaType := getMediaTypeForImp(sb.Bid[i].ImpID, internalRequest.Imp)
mediaType, err := getMediaTypeForImp(sb.Bid[i])
if err != nil {
return nil, []error{err}
}
bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{
Bid: &sb.Bid[i],
BidType: mediaType,
Expand Down Expand Up @@ -118,18 +121,17 @@ func preprocess(imp *openrtb2.Imp) error {
return nil
}

func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType {
mediaType := openrtb_ext.BidTypeBanner
for _, imp := range imps {
if imp.ID == impId {
if imp.Video != nil {
mediaType = openrtb_ext.BidTypeVideo
}
if imp.Native != nil {
mediaType = openrtb_ext.BidTypeNative
}
break
func getMediaTypeForImp(bid openrtb2.Bid) (openrtb_ext.BidType, error) {
switch bid.MType {
case openrtb2.MarkupBanner:
return openrtb_ext.BidTypeBanner, nil
case openrtb2.MarkupVideo:
return openrtb_ext.BidTypeVideo, nil
case openrtb2.MarkupNative:
return openrtb_ext.BidTypeNative, nil
default:
return "", &errortypes.BadServerResponse{
Message: fmt.Sprintf("Unsupported mtype %d for bid %s", bid.MType, bid.ID),
}
}
return mediaType
}
4 changes: 3 additions & 1 deletion adapters/inmobi/inmobitest/exemplary/simple-app-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"price": 2.0,
"id": "1234",
"adm": "bannerhtml",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 1
}
]
}
Expand All @@ -94,6 +95,7 @@
"adm": "bannerhtml",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 1,
"ext": {
"prebid": {
"meta": {
Expand Down
4 changes: 3 additions & 1 deletion adapters/inmobi/inmobitest/exemplary/simple-app-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"price": 2.0,
"id": "1234",
"adm": "native-json",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 4
}
]
}
Expand All @@ -92,6 +93,7 @@
"adm": "native-json",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 4,
"ext": {
"prebid": {
"meta": {
Expand Down
4 changes: 3 additions & 1 deletion adapters/inmobi/inmobitest/exemplary/simple-app-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"price": 2.0,
"id": "1234",
"adm": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <VAST version=\"3.0\"></VAST>",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 2
}
]
}
Expand All @@ -96,6 +97,7 @@
"adm": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <VAST version=\"3.0\"></VAST>",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 2,
"ext": {
"prebid": {
"meta": {
Expand Down
4 changes: 3 additions & 1 deletion adapters/inmobi/inmobitest/exemplary/simple-web-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"price": 2.0,
"id": "1234",
"adm": "bannerhtml",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 1
}
]
}
Expand All @@ -92,6 +93,7 @@
"adm": "bannerhtml",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 1,
"ext": {
"prebid": {
"meta": {
Expand Down
4 changes: 3 additions & 1 deletion adapters/inmobi/inmobitest/exemplary/simple-web-native.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"price": 2.0,
"id": "1234",
"adm": "native-json",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 4
}
]
}
Expand All @@ -90,6 +91,7 @@
"adm": "native-json",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 4,
"ext": {
"prebid": {
"meta": {
Expand Down
4 changes: 3 additions & 1 deletion adapters/inmobi/inmobitest/exemplary/simple-web-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"price": 2.0,
"id": "1234",
"adm": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <VAST version=\"3.0\"></VAST>",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 2
}
]
}
Expand All @@ -94,6 +95,7 @@
"adm": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <VAST version=\"3.0\"></VAST>",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 2,
"ext": {
"prebid": {
"meta": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"price": 2.0,
"id": "1234",
"adm": "bannerhtml",
"impid": "imp-id"
"impid": "imp-id",
"mtype": 1
}
]
}
Expand All @@ -100,6 +101,7 @@
"adm": "bannerhtml",
"crid": "123456789",
"nurl": "https://some.event.url/params",
"mtype": 1,
"ext": {
"prebid": {
"meta": {
Expand Down
97 changes: 97 additions & 0 deletions adapters/inmobi/inmobitest/supplemental/invalid-mtype.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"mockBidRequest": {
"site": {
"page": "https://www.inmobi.com"
},
"id": "req-id",
"device": {
"ip": "1.1.1.1",
"ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36"
},
"imp": [
{
"ext": {
"bidder": {
"plc": "1621323101291"
}
},
"video": {
"w": 640,
"h": 360,
"mimes": ["video/mp4"]
},
"id": "imp-id"
}
]
},
"httpCalls": [{
"expectedRequest": {
"uri": "https://api.w.inmobi.com/showad/openrtb/bidder/prebid",
"body": {
"site": {
"page": "https://www.inmobi.com"
},
"id": "req-id",
"device": {
"ip": "1.1.1.1",
"ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36"
},
"imp": [
{
"ext": {
"bidder": {
"plc": "1621323101291"
}
},
"video": {
"w": 640,
"h": 360,
"mimes": ["video/mp4"]
},
"id": "imp-id"
}
]
},
"impIDs":["imp-id"]
},
"mockResponse": {
"status": 200,
"body": {
"id": "req-id",
"seatbid": [
{
"bid": [
{
"ext": {
"prebid": {
"meta": {
"networkName": "inmobi"
}
}
},
"nurl": "https://some.event.url/params",
"crid": "123456789",
"adomain": [],
"price": 2.0,
"id": "1234",
"adm": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <VAST version=\"3.0\"></VAST>",
"impid": "imp-id",
"mtype": 0
}
]
}
]
}
}
}],

"expectedBidResponses":[],
"expectedMakeBidsErrors":[
{
"value":"Unsupported mtype 0 for bid 1234",
"comparison":"literal"
}
]
}


Loading

0 comments on commit d08b508

Please sign in to comment.